Notas de razonamiento por lotes de TensorRT C++

Cuando el lote es 1, es como sigue:

vacío* búferes[2];
buffers[inputIndex] = inputbuffer;
buffers[outputIndex] = outputBuffer;

Pero cuando batch_size es mayor que 1, ¿cómo configurar inputbuffer y outputBuffer, y cómo construir el motor?

Prepare los datos para la inferencia por lotes:

void parseYolov5(cv::Mat& img,ICudaEngine* engine,IExecutionContext* context,std::vector<Yolo::Detection>& batch_res)
{
    // 准备数据 ---------------------------
    static float data[BATCH_SIZE * 3 * INPUT_H * INPUT_W];  //输入
    static float prob[BATCH_SIZE * OUTPUT_SIZE];            //输出

    assert(engine->getNbBindings() == 2);
    void* buffers[2];
    // In order to bind the buffers, we need to know the names of the input and output tensors.
    // Note that indices are guaranteed to be less than IEngine::getNbBindings()
    const int inputIndex = engine->getBindingIndex(INPUT_BLOB_NAME);
    const int outputIndex = engine->getBindin

Supongo que te gusta

Origin blog.csdn.net/jacke121/article/details/123750675
Recomendado
Clasificación