retinafaceAntiCov tensorrt8 (#1366)
* retinafaceAntiCov tensorrt8 * Update decode.h
This commit is contained in:
parent
24811e0520
commit
12c19acce8
@ -10,6 +10,7 @@ set(CMAKE_BUILD_TYPE Debug)
|
|||||||
|
|
||||||
find_package(CUDA REQUIRED)
|
find_package(CUDA REQUIRED)
|
||||||
|
|
||||||
|
|
||||||
include_directories(${PROJECT_SOURCE_DIR}/include)
|
include_directories(${PROJECT_SOURCE_DIR}/include)
|
||||||
if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
|
if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
|
||||||
message("embed_platform on")
|
message("embed_platform on")
|
||||||
@ -17,10 +18,18 @@ if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
|
|||||||
link_directories(/usr/local/cuda/targets/aarch64-linux/lib)
|
link_directories(/usr/local/cuda/targets/aarch64-linux/lib)
|
||||||
else()
|
else()
|
||||||
message("embed_platform off")
|
message("embed_platform off")
|
||||||
|
# cuda
|
||||||
include_directories(/usr/local/cuda/include)
|
include_directories(/usr/local/cuda/include)
|
||||||
link_directories(/usr/local/cuda/lib64)
|
link_directories(/usr/local/cuda/lib64)
|
||||||
endif()
|
|
||||||
|
|
||||||
|
# tensorrt
|
||||||
|
include_directories(/home/lindsay/TensorRT-8.6.1.6/include)
|
||||||
|
link_directories(/home/lindsay/TensorRT-8.6.1.6/lib)
|
||||||
|
# include_directories(/home/lindsay/TensorRT-7.2.3.4/include)
|
||||||
|
# link_directories(/home/lindsay/TensorRT-7.2.3.4/lib)
|
||||||
|
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Ofast -Wfatal-errors -D_MWAITXINTRIN_H_INCLUDED")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Ofast -Wfatal-errors -D_MWAITXINTRIN_H_INCLUDED")
|
||||||
|
|
||||||
|
|||||||
@ -16,21 +16,21 @@ namespace nvinfer1
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void DecodePlugin::serialize(void* buffer) const
|
void DecodePlugin::serialize(void* buffer) const TRT_NOEXCEPT
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t DecodePlugin::getSerializationSize() const
|
size_t DecodePlugin::getSerializationSize() const TRT_NOEXCEPT
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DecodePlugin::initialize()
|
int DecodePlugin::initialize() TRT_NOEXCEPT
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dims DecodePlugin::getOutputDimensions(int index, const Dims* inputs, int nbInputDims)
|
Dims DecodePlugin::getOutputDimensions(int index, const Dims* inputs, int nbInputDims) TRT_NOEXCEPT
|
||||||
{
|
{
|
||||||
//output the result to channel
|
//output the result to channel
|
||||||
int totalCount = 0;
|
int totalCount = 0;
|
||||||
@ -42,63 +42,63 @@ namespace nvinfer1
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set plugin namespace
|
// Set plugin namespace
|
||||||
void DecodePlugin::setPluginNamespace(const char* pluginNamespace)
|
void DecodePlugin::setPluginNamespace(const char* pluginNamespace) TRT_NOEXCEPT
|
||||||
{
|
{
|
||||||
mPluginNamespace = pluginNamespace;
|
mPluginNamespace = pluginNamespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* DecodePlugin::getPluginNamespace() const
|
const char* DecodePlugin::getPluginNamespace() const TRT_NOEXCEPT
|
||||||
{
|
{
|
||||||
return mPluginNamespace;
|
return mPluginNamespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the DataType of the plugin output at the requested index
|
// Return the DataType of the plugin output at the requested index
|
||||||
DataType DecodePlugin::getOutputDataType(int index, const nvinfer1::DataType* inputTypes, int nbInputs) const
|
DataType DecodePlugin::getOutputDataType(int index, const nvinfer1::DataType* inputTypes, int nbInputs) const TRT_NOEXCEPT
|
||||||
{
|
{
|
||||||
return DataType::kFLOAT;
|
return DataType::kFLOAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true if output tensor is broadcast across a batch.
|
// Return true if output tensor is broadcast across a batch.
|
||||||
bool DecodePlugin::isOutputBroadcastAcrossBatch(int outputIndex, const bool* inputIsBroadcasted, int nbInputs) const
|
bool DecodePlugin::isOutputBroadcastAcrossBatch(int outputIndex, const bool* inputIsBroadcasted, int nbInputs) const TRT_NOEXCEPT
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true if plugin can use input that is broadcast across batch without replication.
|
// Return true if plugin can use input that is broadcast across batch without replication.
|
||||||
bool DecodePlugin::canBroadcastInputAcrossBatch(int inputIndex) const
|
bool DecodePlugin::canBroadcastInputAcrossBatch(int inputIndex) const TRT_NOEXCEPT
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DecodePlugin::configurePlugin(const PluginTensorDesc* in, int nbInput, const PluginTensorDesc* out, int nbOutput)
|
void DecodePlugin::configurePlugin(const PluginTensorDesc* in, int nbInput, const PluginTensorDesc* out, int nbOutput) TRT_NOEXCEPT
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach the plugin object to an execution context and grant the plugin the access to some context resource.
|
// Attach the plugin object to an execution context and grant the plugin the access to some context resource.
|
||||||
void DecodePlugin::attachToContext(cudnnContext* cudnnContext, cublasContext* cublasContext, IGpuAllocator* gpuAllocator)
|
void DecodePlugin::attachToContext(cudnnContext* cudnnContext, cublasContext* cublasContext, IGpuAllocator* gpuAllocator) TRT_NOEXCEPT
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detach the plugin object from its execution context.
|
// Detach the plugin object from its execution context.
|
||||||
void DecodePlugin::detachFromContext() {}
|
void DecodePlugin::detachFromContext() TRT_NOEXCEPT {}
|
||||||
|
|
||||||
const char* DecodePlugin::getPluginType() const
|
const char* DecodePlugin::getPluginType() const TRT_NOEXCEPT
|
||||||
{
|
{
|
||||||
return "Decode_TRT";
|
return "Decode_TRT";
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* DecodePlugin::getPluginVersion() const
|
const char* DecodePlugin::getPluginVersion() const TRT_NOEXCEPT
|
||||||
{
|
{
|
||||||
return "1";
|
return "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
void DecodePlugin::destroy()
|
void DecodePlugin::destroy() TRT_NOEXCEPT
|
||||||
{
|
{
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clone the plugin
|
// Clone the plugin
|
||||||
IPluginV2IOExt* DecodePlugin::clone() const
|
IPluginV2IOExt* DecodePlugin::clone() const TRT_NOEXCEPT
|
||||||
{
|
{
|
||||||
DecodePlugin *p = new DecodePlugin();
|
DecodePlugin *p = new DecodePlugin();
|
||||||
p->setPluginNamespace(mPluginNamespace);
|
p->setPluginNamespace(mPluginNamespace);
|
||||||
@ -172,7 +172,7 @@ namespace nvinfer1
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int DecodePlugin::enqueue(int batchSize, const void*const * inputs, void** outputs, void* workspace, cudaStream_t stream)
|
int DecodePlugin::enqueue(int batchSize, const void*const * inputs, void*TRT_CONST_ENQUEUE* outputs, void* workspace, cudaStream_t stream) TRT_NOEXCEPT
|
||||||
{
|
{
|
||||||
//assert(batchSize == 1);
|
//assert(batchSize == 1);
|
||||||
//GPU
|
//GPU
|
||||||
@ -193,29 +193,29 @@ namespace nvinfer1
|
|||||||
mFC.fields = mPluginAttributes.data();
|
mFC.fields = mPluginAttributes.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* DecodePluginCreator::getPluginName() const
|
const char* DecodePluginCreator::getPluginName() const TRT_NOEXCEPT
|
||||||
{
|
{
|
||||||
return "Decode_TRT";
|
return "Decode_TRT";
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* DecodePluginCreator::getPluginVersion() const
|
const char* DecodePluginCreator::getPluginVersion() const TRT_NOEXCEPT
|
||||||
{
|
{
|
||||||
return "1";
|
return "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
const PluginFieldCollection* DecodePluginCreator::getFieldNames()
|
const PluginFieldCollection* DecodePluginCreator::getFieldNames() TRT_NOEXCEPT
|
||||||
{
|
{
|
||||||
return &mFC;
|
return &mFC;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPluginV2IOExt* DecodePluginCreator::createPlugin(const char* name, const PluginFieldCollection* fc)
|
IPluginV2IOExt* DecodePluginCreator::createPlugin(const char* name, const PluginFieldCollection* fc) TRT_NOEXCEPT
|
||||||
{
|
{
|
||||||
DecodePlugin* obj = new DecodePlugin();
|
DecodePlugin* obj = new DecodePlugin();
|
||||||
obj->setPluginNamespace(mNamespace.c_str());
|
obj->setPluginNamespace(mNamespace.c_str());
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPluginV2IOExt* DecodePluginCreator::deserializePlugin(const char* name, const void* serialData, size_t serialLength)
|
IPluginV2IOExt* DecodePluginCreator::deserializePlugin(const char* name, const void* serialData, size_t serialLength) TRT_NOEXCEPT
|
||||||
{
|
{
|
||||||
// This object will be deleted when the network is destroyed, which will
|
// This object will be deleted when the network is destroyed, which will
|
||||||
// call PReluPlugin::destroy()
|
// call PReluPlugin::destroy()
|
||||||
|
|||||||
@ -3,7 +3,11 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <iostream>
|
||||||
#include "NvInfer.h"
|
#include "NvInfer.h"
|
||||||
|
#include "macros.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace decodeplugin
|
namespace decodeplugin
|
||||||
{
|
{
|
||||||
@ -15,8 +19,16 @@ namespace decodeplugin
|
|||||||
};
|
};
|
||||||
static const int INPUT_H = 640;
|
static const int INPUT_H = 640;
|
||||||
static const int INPUT_W = 640;
|
static const int INPUT_W = 640;
|
||||||
|
|
||||||
|
// std::ostream& operator << (std::ostream& os, const decodeplugin::Detection& det) {
|
||||||
|
// for(int i = 0; i < 10; i += 2){
|
||||||
|
// os << det.mask_confidence << " ";
|
||||||
|
// }
|
||||||
|
// return os;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace nvinfer1
|
namespace nvinfer1
|
||||||
{
|
{
|
||||||
class DecodePlugin: public IPluginV2IOExt
|
class DecodePlugin: public IPluginV2IOExt
|
||||||
@ -27,53 +39,53 @@ namespace nvinfer1
|
|||||||
|
|
||||||
~DecodePlugin();
|
~DecodePlugin();
|
||||||
|
|
||||||
int getNbOutputs() const override
|
int getNbOutputs() const TRT_NOEXCEPT override
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dims getOutputDimensions(int index, const Dims* inputs, int nbInputDims) override;
|
Dims getOutputDimensions(int index, const Dims* inputs, int nbInputDims) TRT_NOEXCEPT override;
|
||||||
|
|
||||||
int initialize() override;
|
int initialize() TRT_NOEXCEPT override;
|
||||||
|
|
||||||
virtual void terminate() override {};
|
virtual void terminate() TRT_NOEXCEPT override {};
|
||||||
|
|
||||||
virtual size_t getWorkspaceSize(int maxBatchSize) const override { return 0;}
|
virtual size_t getWorkspaceSize(int maxBatchSize) const TRT_NOEXCEPT override { return 0;}
|
||||||
|
|
||||||
virtual int enqueue(int batchSize, const void*const * inputs, void** outputs, void* workspace, cudaStream_t stream) override;
|
virtual int enqueue(int batchSize, const void*const * inputs, void*TRT_CONST_ENQUEUE* outputs, void* workspace, cudaStream_t stream) TRT_NOEXCEPT override;
|
||||||
|
|
||||||
virtual size_t getSerializationSize() const override;
|
virtual size_t getSerializationSize() const TRT_NOEXCEPT override;
|
||||||
|
|
||||||
virtual void serialize(void* buffer) const override;
|
virtual void serialize(void* buffer) const TRT_NOEXCEPT override;
|
||||||
|
|
||||||
bool supportsFormatCombination(int pos, const PluginTensorDesc* inOut, int nbInputs, int nbOutputs) const override {
|
bool supportsFormatCombination(int pos, const PluginTensorDesc* inOut, int nbInputs, int nbOutputs) const TRT_NOEXCEPT override {
|
||||||
return inOut[pos].format == TensorFormat::kLINEAR && inOut[pos].type == DataType::kFLOAT;
|
return inOut[pos].format == TensorFormat::kLINEAR && inOut[pos].type == DataType::kFLOAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* getPluginType() const override;
|
const char* getPluginType() const TRT_NOEXCEPT override;
|
||||||
|
|
||||||
const char* getPluginVersion() const override;
|
const char* getPluginVersion() const TRT_NOEXCEPT override;
|
||||||
|
|
||||||
void destroy() override;
|
void destroy() TRT_NOEXCEPT override;
|
||||||
|
|
||||||
IPluginV2IOExt* clone() const override;
|
IPluginV2IOExt* clone() const TRT_NOEXCEPT override;
|
||||||
|
|
||||||
void setPluginNamespace(const char* pluginNamespace) override;
|
void setPluginNamespace(const char* pluginNamespace) TRT_NOEXCEPT override;
|
||||||
|
|
||||||
const char* getPluginNamespace() const override;
|
const char* getPluginNamespace() const TRT_NOEXCEPT override;
|
||||||
|
|
||||||
DataType getOutputDataType(int index, const nvinfer1::DataType* inputTypes, int nbInputs) const override;
|
DataType getOutputDataType(int index, const nvinfer1::DataType* inputTypes, int nbInputs) const TRT_NOEXCEPT override;
|
||||||
|
|
||||||
bool isOutputBroadcastAcrossBatch(int outputIndex, const bool* inputIsBroadcasted, int nbInputs) const override;
|
bool isOutputBroadcastAcrossBatch(int outputIndex, const bool* inputIsBroadcasted, int nbInputs) const TRT_NOEXCEPT override;
|
||||||
|
|
||||||
bool canBroadcastInputAcrossBatch(int inputIndex) const override;
|
bool canBroadcastInputAcrossBatch(int inputIndex) const TRT_NOEXCEPT override;
|
||||||
|
|
||||||
void attachToContext(
|
void attachToContext(
|
||||||
cudnnContext* cudnnContext, cublasContext* cublasContext, IGpuAllocator* gpuAllocator) override;
|
cudnnContext* cudnnContext, cublasContext* cublasContext, IGpuAllocator* gpuAllocator) TRT_NOEXCEPT override;
|
||||||
|
|
||||||
void configurePlugin(const PluginTensorDesc* in, int nbInput, const PluginTensorDesc* out, int nbOutput) override;
|
void configurePlugin(const PluginTensorDesc* in, int nbInput, const PluginTensorDesc* out, int nbOutput) TRT_NOEXCEPT override;
|
||||||
|
|
||||||
void detachFromContext() override;
|
void detachFromContext() TRT_NOEXCEPT override;
|
||||||
|
|
||||||
int input_size_;
|
int input_size_;
|
||||||
private:
|
private:
|
||||||
@ -87,24 +99,24 @@ namespace nvinfer1
|
|||||||
public:
|
public:
|
||||||
DecodePluginCreator();
|
DecodePluginCreator();
|
||||||
|
|
||||||
~DecodePluginCreator() override = default;
|
~DecodePluginCreator() TRT_NOEXCEPT override = default;
|
||||||
|
|
||||||
const char* getPluginName() const override;
|
const char* getPluginName() const TRT_NOEXCEPT override;
|
||||||
|
|
||||||
const char* getPluginVersion() const override;
|
const char* getPluginVersion() const TRT_NOEXCEPT override;
|
||||||
|
|
||||||
const PluginFieldCollection* getFieldNames() override;
|
const PluginFieldCollection* getFieldNames() TRT_NOEXCEPT override;
|
||||||
|
|
||||||
IPluginV2IOExt* createPlugin(const char* name, const PluginFieldCollection* fc) override;
|
IPluginV2IOExt* createPlugin(const char* name, const PluginFieldCollection* fc) TRT_NOEXCEPT override;
|
||||||
|
|
||||||
IPluginV2IOExt* deserializePlugin(const char* name, const void* serialData, size_t serialLength) override;
|
IPluginV2IOExt* deserializePlugin(const char* name, const void* serialData, size_t serialLength) TRT_NOEXCEPT override;
|
||||||
|
|
||||||
void setPluginNamespace(const char* libNamespace) override
|
void setPluginNamespace(const char* libNamespace) TRT_NOEXCEPT override
|
||||||
{
|
{
|
||||||
mNamespace = libNamespace;
|
mNamespace = libNamespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* getPluginNamespace() const override
|
const char* getPluginNamespace() const TRT_NOEXCEPT override
|
||||||
{
|
{
|
||||||
return mNamespace.c_str();
|
return mNamespace.c_str();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "macros.h"
|
||||||
using Severity = nvinfer1::ILogger::Severity;
|
using Severity = nvinfer1::ILogger::Severity;
|
||||||
|
|
||||||
class LogStreamConsumerBuffer : public std::stringbuf
|
class LogStreamConsumerBuffer : public std::stringbuf
|
||||||
@ -236,7 +236,7 @@ public:
|
|||||||
//! Note samples should not be calling this function directly; it will eventually go away once we eliminate the
|
//! Note samples should not be calling this function directly; it will eventually go away once we eliminate the
|
||||||
//! inheritance from nvinfer1::ILogger
|
//! inheritance from nvinfer1::ILogger
|
||||||
//!
|
//!
|
||||||
void log(Severity severity, const char* msg) override
|
void log(Severity severity, const char* msg) TRT_NOEXCEPT override
|
||||||
{
|
{
|
||||||
LogStreamConsumer(mReportableSeverity, severity) << "[TRT] " << std::string(msg) << std::endl;
|
LogStreamConsumer(mReportableSeverity, severity) << "[TRT] " << std::string(msg) << std::endl;
|
||||||
}
|
}
|
||||||
|
|||||||
12
retinafaceAntiCov/macros.h
Normal file
12
retinafaceAntiCov/macros.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef __MACROS_H
|
||||||
|
#define __MACROS_H
|
||||||
|
|
||||||
|
#if NV_TENSORRT_MAJOR >= 8
|
||||||
|
#define TRT_NOEXCEPT noexcept
|
||||||
|
#define TRT_CONST_ENQUEUE const
|
||||||
|
#else
|
||||||
|
#define TRT_NOEXCEPT
|
||||||
|
#define TRT_CONST_ENQUEUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // __MACROS_H
|
||||||
Loading…
Reference in New Issue
Block a user