TensorRT version
This commit is contained in:
+2
-1
@@ -11,11 +11,12 @@ cuda_add_library(kernels SHARED src/kernels/activation_elu.cu
|
|||||||
src/kernels/reorg.cu
|
src/kernels/reorg.cu
|
||||||
src/kernels/softmax.cu)
|
src/kernels/softmax.cu)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11")
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${CUDA_INCLUDE_DIRS})
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${CUDA_INCLUDE_DIRS})
|
||||||
add_library(tkDNN SHARED src/Layer.cpp src/LayerWgs.cpp
|
add_library(tkDNN SHARED src/Layer.cpp src/LayerWgs.cpp
|
||||||
src/Dense.cpp src/Activation.cpp src/Conv2d.cpp src/Flatten.cpp src/MulAdd.cpp src/Pooling.cpp src/Softmax.cpp
|
src/Dense.cpp src/Activation.cpp src/Conv2d.cpp src/Flatten.cpp src/MulAdd.cpp src/Pooling.cpp src/Softmax.cpp
|
||||||
src/Route.cpp src/Reorg.cpp src/Region.cpp src/Network.cpp src/utils.cpp)
|
src/Route.cpp src/Reorg.cpp src/Region.cpp src/Network.cpp src/utils.cpp)
|
||||||
target_link_libraries(tkDNN kernels ${CUDA_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES} -lcudnn)
|
target_link_libraries(tkDNN kernels ${CUDA_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES} -lcudnn -lnvinfer)
|
||||||
|
|
||||||
add_executable(test_simple tests/test/test.cpp)
|
add_executable(test_simple tests/test/test.cpp)
|
||||||
target_link_libraries(test_simple tkDNN)
|
target_link_libraries(test_simple tkDNN)
|
||||||
|
|||||||
+2
-2
@@ -1,10 +1,10 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "Layer.h"
|
|
||||||
|
|
||||||
void activationELUForward(value_type* srcData, value_type* dstData, int size);
|
void activationELUForward(value_type* srcData, value_type* dstData, int size);
|
||||||
void activationLEAKYForward(value_type* srcData, value_type* dstData, int size);
|
void activationLEAKYForward(value_type* srcData, value_type* dstData, int size);
|
||||||
void activationLOGISTICForward(value_type* srcData, value_type* dstData, int size);
|
void activationLOGISTICForward(value_type* srcData, value_type* dstData, int size);
|
||||||
|
|
||||||
void reorgForward(value_type* srcData, value_type* dstData, tkDNN::dataDim_t dim, int stride);
|
void reorgForward( value_type* srcData, value_type* dstData,
|
||||||
|
int n, int c, int h, int w, int stride);
|
||||||
void softmaxForward(float *input, int n, int batch, int batch_offset,
|
void softmaxForward(float *input, int n, int batch, int batch_offset,
|
||||||
int groups, int group_offset, int stride, float temp, float *output);
|
int groups, int group_offset, int stride, float temp, float *output);
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@ Conv2d::Conv2d( Network *net, dataDim_t in_dim, int out_ch,
|
|||||||
paddingH, paddingW, // padding
|
paddingH, paddingW, // padding
|
||||||
strideH, strideW, // stride
|
strideH, strideW, // stride
|
||||||
1,1, // upscale
|
1,1, // upscale
|
||||||
CUDNN_CROSS_CORRELATION) );
|
CUDNN_CROSS_CORRELATION, CUDNN_DATA_FLOAT) );
|
||||||
|
|
||||||
// find dimension of convolution output
|
// find dimension of convolution output
|
||||||
checkCUDNN( cudnnGetConvolution2dForwardOutputDim(
|
checkCUDNN( cudnnGetConvolution2dForwardOutputDim(
|
||||||
|
|||||||
+5
-2
@@ -1,4 +1,5 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include "NvInfer.h"
|
||||||
|
|
||||||
#include "tkdnn.h"
|
#include "tkdnn.h"
|
||||||
#include "Network.h"
|
#include "Network.h"
|
||||||
@@ -10,8 +11,10 @@ Network::Network() {
|
|||||||
|
|
||||||
float tk_ver = float(tkDNN::getVersion())/1000;
|
float tk_ver = float(tkDNN::getVersion())/1000;
|
||||||
float cu_ver = float(cudnnGetVersion())/1000;
|
float cu_ver = float(cudnnGetVersion())/1000;
|
||||||
|
float rt_ver = float(NV_TENSORRT_MAJOR) + float(NV_TENSORRT_MINOR)/10 + float(NV_TENSORRT_PATCH)/100;
|
||||||
|
|
||||||
std::cout<<"New NETWORK (tkDNN v"<<tk_ver<<", CUDNN v"<<cu_ver<<")\n";
|
std::cout<<"New NETWORK (tkDNN v"<<tk_ver
|
||||||
|
<<", CUDNN v"<<cu_ver<<", TensorRT v"<<rt_ver<<")\n";
|
||||||
dataType = CUDNN_DATA_FLOAT;
|
dataType = CUDNN_DATA_FLOAT;
|
||||||
tensorFormat = CUDNN_TENSOR_NCHW;
|
tensorFormat = CUDNN_TENSOR_NCHW;
|
||||||
|
|
||||||
@@ -32,7 +35,7 @@ value_type* Network::infer(dataDim_t &dim, value_type* data) {
|
|||||||
//do infer for every layer
|
//do infer for every layer
|
||||||
for(int i=0; i<num_layers; i++)
|
for(int i=0; i<num_layers; i++)
|
||||||
data = layers[i]->infer(dim, data);
|
data = layers[i]->infer(dim, data);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ Reorg::~Reorg() {
|
|||||||
|
|
||||||
value_type* Reorg::infer(dataDim_t &dim, value_type* srcData) {
|
value_type* Reorg::infer(dataDim_t &dim, value_type* srcData) {
|
||||||
|
|
||||||
reorgForward(srcData, dstData, dim, stride);
|
reorgForward(srcData, dstData, dim.n, dim.c, dim.h, dim.w, stride);
|
||||||
|
|
||||||
dim = output_dim;
|
dim = output_dim;
|
||||||
return dstData;
|
return dstData;
|
||||||
|
|||||||
@@ -35,14 +35,15 @@ __global__ void reorg_kernel(int N, float *x, int w, int h, int c, int batch, in
|
|||||||
/**
|
/**
|
||||||
reorg function function
|
reorg function function
|
||||||
*/
|
*/
|
||||||
void reorgForward(value_type* srcData, value_type* dstData, tkDNN::dataDim_t dim, int stride)
|
void reorgForward(value_type* srcData, value_type* dstData,
|
||||||
{
|
int n, int c, int h, int w, int stride) {
|
||||||
int size = dim.tot();
|
|
||||||
|
int size = n*c*h*w;
|
||||||
|
|
||||||
int blocks = (size+255)/256;
|
int blocks = (size+255)/256;
|
||||||
int threads = 256;
|
int threads = 256;
|
||||||
|
|
||||||
reorg_kernel<<<blocks, threads>>>(size, srcData, dim.w, dim.h, dim.c, dim.n, stride, false, dstData);
|
reorg_kernel<<<blocks, threads>>>(size, srcData, w, h, c, n, stride, false, dstData);
|
||||||
checkCuda( cudaDeviceSynchronize() );
|
checkCuda( cudaDeviceSynchronize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user