3eb079dd13
Signed-off-by: xavier <micaelaverucchi@gmail.com>
62 lines
1.3 KiB
C++
62 lines
1.3 KiB
C++
#include<cassert>
|
|
|
|
class ReshapeRT : public IPlugin {
|
|
|
|
public:
|
|
ReshapeRT(dataDim_t new_dim) {
|
|
n = new_dim.n;
|
|
c = new_dim.c;
|
|
h = new_dim.h;
|
|
w = new_dim.w;
|
|
}
|
|
|
|
~ReshapeRT(){
|
|
|
|
}
|
|
|
|
int getNbOutputs() const override {
|
|
return 1;
|
|
}
|
|
|
|
Dims getOutputDimensions(int index, const Dims* inputs, int nbInputDims) override {
|
|
return DimsCHW{ c,h,w};
|
|
}
|
|
|
|
void configure(const Dims* inputDims, int nbInputs, const Dims* outputDims, int nbOutputs, int maxBatchSize) override {
|
|
}
|
|
|
|
int initialize() override {
|
|
return 0;
|
|
}
|
|
|
|
virtual void terminate() override {
|
|
}
|
|
|
|
virtual size_t getWorkspaceSize(int maxBatchSize) const override {
|
|
return 0;
|
|
}
|
|
|
|
virtual int enqueue(int batchSize, const void*const * inputs, void** outputs, void* workspace, cudaStream_t stream) override {
|
|
dnnType *srcData = (dnnType*)reinterpret_cast<const dnnType*>(inputs[0]);
|
|
dnnType *dstData = reinterpret_cast<dnnType*>(outputs[0]);
|
|
|
|
checkCuda( cudaMemcpy(dstData, srcData, c*h*w*sizeof(dnnType), cudaMemcpyDeviceToDevice));
|
|
return 0;
|
|
}
|
|
|
|
|
|
virtual size_t getSerializationSize() override {
|
|
return 4*sizeof(int);
|
|
}
|
|
|
|
virtual void serialize(void* buffer) override {
|
|
char *buf = reinterpret_cast<char*>(buffer);
|
|
tk::dnn::writeBUF(buf, n);
|
|
tk::dnn::writeBUF(buf, c);
|
|
tk::dnn::writeBUF(buf, h);
|
|
tk::dnn::writeBUF(buf, w);
|
|
}
|
|
|
|
int n, c, h, w;
|
|
};
|