LeakyRelu plugins lead to crash by call enqueue?

Hello,
here is my LeakReluPlugin code, It’s normal when call caffeparser, but when I am going do infernce, It’s crash by call context->enqueue(). what’s the problem?

class LeakyReluPlugin : public IPluginExt
{
public:
    LeakyReluPlugin() { printf("LeakyReluPlugin()\n"); }
    LeakyReluPlugin(const void* buffer, size_t size)
    {
    	printf("LeakyReluPlugin(const void* buffer, size_t size)\n");
        assert(size == sizeof(mSize));
        mSize = *reinterpret_cast<const size_t*>(buffer);
    }

    ~LeakyReluPlugin()
    {
    	printf("~LeakyReluPlugin()\n");
    }

    int getNbOutputs() const override
    {
    	printf("getNbOutputs\n");
        return 1;
    }
    Dims getOutputDimensions(int index, const Dims* inputs, int nbInputDims) override
    {
    	printf("getOutputDimensions\n");
        assert(nbInputDims == 1);
        assert(index == 0);
        assert(inputs[index].nbDims == 3);
        return DimsCHW(inputs[0].d[0], inputs[0].d[1], inputs[0].d[2]);
    }

    int initialize() override
    {
    	printf("initialize\n");
        return 0;
    }

    void terminate() override
    {
    	printf("terminate\n");
    }

    size_t getWorkspaceSize(int) const override
    {
    	printf("getWorkspaceSize\n");
        return 0;
    }

    // currently it is not possible for a plugin to execute "in place". Therefore we memcpy the data from the input to the output buffer
    int enqueue(int batchSize, const void*const *inputs, void** outputs, void*, cudaStream_t stream) override
    {
    	printf("enqueue()\n");
//        int block_size = 256;
//        int grid_size = (mSize + block_size - 1) / block_size;
//        _leakyReluKer<<<grid_size, block_size>>>(
//            reinterpret_cast<float const*>(inputs[0]),
//            reinterpret_cast<float*>(outputs[0]), mSize);
//        getLastCudaError("_leakyReluKer");
        return 0;
    }

    size_t getSerializationSize() override
    {
    	printf("getSerializationSize\n");
        return sizeof(mSize);
    }

    void serialize(void* buffer) override
    {
    	printf("serialize\n");
        *reinterpret_cast<size_t*>(buffer) = mSize;
    }

    virtual bool supportsFormat(DataType type, PluginFormat format) const
    {
    	printf("supportsFormat\n");
    	return (type == DataType::kFLOAT) && format == PluginFormat::kNCHW;
    }

    virtual void configureWithFormat(const Dims* inputDims, int nbInputs, const Dims* outputDims, int nbOutputs, DataType type, PluginFormat format, int maxBatchSize)
    {
    	printf("configureWithFormat\n");
    	mSize = inputDims[0].d[0] * inputDims[0].d[1] * inputDims[0].d[2];
    }

protected:
    size_t mSize;
};

besides, the log “enquque()” don’t show when I call context->enqueue()

Hi,

Do you have any issue when creating a model with the plugin?
By the way, have you passed the plugin function to TensorRT?
[url]Face-Recognition/tensorNet.cpp at master · AastaNV/Face-Recognition · GitHub

Thanks.

thank you,
your example is helpful,now I solve this problem.