Commit 54cfa83e authored by xin.wang.waytous's avatar xin.wang.waytous

in

parent 9ac67037
...@@ -2,18 +2,21 @@ ...@@ -2,18 +2,21 @@
#define DEEPINFER_COMMON_H_ #define DEEPINFER_COMMON_H_
#include <cublas_v2.h>
#include <cuda_runtime.h>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <iomanip> #include <iomanip>
#include <cmath> #include <cmath>
#include <assert.h> #include <assert.h>
#define BLOCK 512
#define iMAX(a, b) ((a) > (b) ? (a) : (b)) #define iMAX(a, b) ((a) > (b) ? (a) : (b))
#define iMIN(a, b) ((a) > (b) ? (b) : (a)) #define iMIN(a, b) ((a) > (b) ? (b) : (a))
// #ifdef USE_CUDA
#include <cublas_v2.h>
#include <cuda_runtime.h>
#define BLOCK 512
#ifndef CUDA_CHECK #ifndef CUDA_CHECK
#define CUDA_CHECK(callstr) \ #define CUDA_CHECK(callstr) \
{ \ { \
...@@ -24,6 +27,7 @@ ...@@ -24,6 +27,7 @@
} \ } \
} }
#endif #endif
// #endif // USE_CUDA
#ifndef PI #ifndef PI
#define PI 3.1415926 #define PI 3.1415926
...@@ -33,6 +37,7 @@ namespace waytous{ ...@@ -33,6 +37,7 @@ namespace waytous{
namespace deepinfer{ namespace deepinfer{
namespace common{ namespace common{
// #ifdef USE_CUDA
inline dim3 cudaGridSize(uint n, uint block) inline dim3 cudaGridSize(uint n, uint block)
{ {
uint k = (n - 1) / block + 1; uint k = (n - 1) / block + 1;
...@@ -46,7 +51,7 @@ inline dim3 cudaGridSize(uint n, uint block) ...@@ -46,7 +51,7 @@ inline dim3 cudaGridSize(uint n, uint block)
dim3 d = {x, y, 1} ; dim3 d = {x, y, 1} ;
return d; return d;
} }
// #endif // USE_CUDA
inline std::string formatValue(float val, int fixed) { inline std::string formatValue(float val, int fixed) {
std::ostringstream oss; std::ostringstream oss;
......
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
#ifndef DEEPINFER_POSTPROCESS_MOBILEFACENET_H_ #ifndef DEEPINFER_POSTPROCESS_MOBILEFACENET_H_
#define DEEPINFER_POSTPROCESS_MOBILEFACENET_H_ #define DEEPINFER_POSTPROCESS_MOBILEFACENET_H_
#include <cuda_runtime.h>
#include <cstdint>
#include "interfaces/base_unit.h" #include "interfaces/base_unit.h"
#include "base/image.h" #include "base/image.h"
......
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
#ifndef DEEPINFER_POSTPROCESS_TRDES_H_ #ifndef DEEPINFER_POSTPROCESS_TRDES_H_
#define DEEPINFER_POSTPROCESS_TRDES_H_ #define DEEPINFER_POSTPROCESS_TRDES_H_
#include <cuda_runtime.h>
#include <cstdint>
#include "interfaces/base_unit.h" #include "interfaces/base_unit.h"
#include "base/image.h" #include "base/image.h"
......
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
#ifndef DEEPINFER_POSTPROCESS_WHENet_H_ #ifndef DEEPINFER_POSTPROCESS_WHENet_H_
#define DEEPINFER_POSTPROCESS_WHENet_H_ #define DEEPINFER_POSTPROCESS_WHENet_H_
#include <cuda_runtime.h>
#include <cstdint>
#include "interfaces/base_unit.h" #include "interfaces/base_unit.h"
#include "base/image.h" #include "base/image.h"
......
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
#ifndef DEEPINFER_POSTPROCESS_YOLOV5_H_ #ifndef DEEPINFER_POSTPROCESS_YOLOV5_H_
#define DEEPINFER_POSTPROCESS_YOLOV5_H_ #define DEEPINFER_POSTPROCESS_YOLOV5_H_
#include <cuda_runtime.h>
#include <cstdint>
#include "interfaces/base_unit.h" #include "interfaces/base_unit.h"
#include "base/image.h" #include "base/image.h"
......
...@@ -95,8 +95,9 @@ __global__ void warpaffine_kernel( ...@@ -95,8 +95,9 @@ __global__ void warpaffine_kernel(
void resizeGPU(uint8_t* src, int src_width, int src_height, int step_width, void resizeGPU(uint8_t* src, int src_width, int src_height, int step_width,
float* dst, int dst_width, int dst_height, float* input_mean, float* input_std, float* dst, int dst_width, int dst_height, float* input_mean, float* input_std,
bool bgr, bool resizeFixAspectRatio, cudaStream_t stream){ bool bgr, bool resizeFixAspectRatio)
{
AffineMatrix s2d, d2s; AffineMatrix s2d, d2s;
float scalex = dst_width / (float)src_width; float scalex = dst_width / (float)src_width;
float scaley = dst_height / (float)src_height; float scaley = dst_height / (float)src_height;
...@@ -121,7 +122,7 @@ void resizeGPU(uint8_t* src, int src_width, int src_height, int step_width, ...@@ -121,7 +122,7 @@ void resizeGPU(uint8_t* src, int src_width, int src_height, int step_width,
int jobs = dst_height * dst_width; int jobs = dst_height * dst_width;
int threads = 256; int threads = 256;
int blocks = ceil(jobs / (float)threads); int blocks = ceil(jobs / (float)threads);
warpaffine_kernel<<<blocks, threads, 0, stream>>>( warpaffine_kernel<<<blocks, threads, 0>>>( //, stream
src, step_width, src_width, src, step_width, src_width,
src_height, dst, dst_width, src_height, dst, dst_width,
dst_height, 128, d2s, jobs, input_mean, input_std, bgr); dst_height, 128, d2s, jobs, input_mean, input_std, bgr);
......
...@@ -18,7 +18,7 @@ struct AffineMatrix{ ...@@ -18,7 +18,7 @@ struct AffineMatrix{
void resizeGPU(uint8_t* src, int src_width, int src_height, int step_width, void resizeGPU(uint8_t* src, int src_width, int src_height, int step_width,
float* dst, int dst_width, int dst_height, float* input_mean, float* input_std, float* dst, int dst_width, int dst_height, float* input_mean, float* input_std,
bool bgr, bool resizeFixAspectRatio, cudaStream_t stream); bool bgr, bool resizeFixAspectRatio);
} //namespace preprocess } //namespace preprocess
......
...@@ -7,7 +7,7 @@ namespace preprocess { ...@@ -7,7 +7,7 @@ namespace preprocess {
bool ResizeNorm::Init(YAML::Node& node){ bool ResizeNorm::Init(YAML::Node& node){
CUDA_CHECK(cudaStreamCreate(&stream_)); // CUDA_CHECK(cudaStreamCreate(&stream_));
if(!BaseUnit::Init(node)){ if(!BaseUnit::Init(node)){
LOG_WARN << "Init resize_norm error"; LOG_WARN << "Init resize_norm error";
return false; return false;
...@@ -56,7 +56,7 @@ bool ResizeNorm::Exec(){ ...@@ -56,7 +56,7 @@ bool ResizeNorm::Exec(){
inputWidth, inputHeight, inputWidth, inputHeight,
mean->mutable_gpu_data(), mean->mutable_gpu_data(),
std->mutable_gpu_data(), std->mutable_gpu_data(),
useBGR, fixAspectRatio, stream_ useBGR, fixAspectRatio
); );
} }
// ios::NormalIOPtr dst_ptr = std::make_shared<ios::NormalIO>(ios::NormalIO(dst)); // ios::NormalIOPtr dst_ptr = std::make_shared<ios::NormalIO>(ios::NormalIO(dst));
......
#ifndef DEEPINFER_PREPROCESS_RESIZE_NORM_H_ #ifndef DEEPINFER_PREPROCESS_RESIZE_NORM_H_
#define DEEPINFER_PREPROCESS_RESIZE_NORM_H_ #define DEEPINFER_PREPROCESS_RESIZE_NORM_H_
#include <cuda_runtime.h>
#include <cstdint>
#include "interfaces/base_unit.h" #include "interfaces/base_unit.h"
#include "base/image.h" #include "base/image.h"
...@@ -33,7 +30,6 @@ public: ...@@ -33,7 +30,6 @@ public:
bool fixAspectRatio = true; bool fixAspectRatio = true;
bool useBGR = false; bool useBGR = false;
base::BlobPtr<float> dst, mean, std; base::BlobPtr<float> dst, mean, std;
cudaStream_t stream_;
}; };
......
#ifndef DEEPINFER_CAMERA_SOURCE_H_ #ifndef DEEPINFER_CAMERA_SOURCE_H_
#define DEEPINFER_CAMERA_SOURCE_H_ #define DEEPINFER_CAMERA_SOURCE_H_
#include <cuda_runtime.h>
#include <cstdint>
#include "base/image.h" #include "base/image.h"
#include "interfaces/base_unit.h" #include "interfaces/base_unit.h"
#include "libs/ios/camera_ios.h" #include "libs/ios/camera_ios.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment