def allocate_buffers(engine):
    "Allocates host and device buffer for TRT engine inference.\n\n    This function is similair to the one in ../../common.py, but\n    converts network outputs (which are np.float32) appropriately\n    before writing them to Python buffer. This is needed, since\n    TensorRT plugins doesn't support output type description, and\n    in our particular case, we use NMS plugin as network output.\n\n    Args:\n        engine (trt.ICudaEngine): TensorRT engine\n\n    Returns:\n        inputs [HostDeviceMem]: engine input memory\n        outputs [HostDeviceMem]: engine output memory\n        bindings [int]: buffer to device bindings\n        stream (cuda.Stream): cuda stream for engine inference synchronization\n    "
    inputs = []
    outputs = []
    bindings = []
    stream = cuda.Stream()
    binding_to_type = {'Input': np.float32, 'NMS': np.float32, 'NMS_1': np.int32}
    for binding in engine:
        size = (trt.volume(engine.get_binding_shape(binding)) * engine.max_batch_size)
        dtype = binding_to_type[str(binding)]
        host_mem = cuda.pagelocked_empty(size, dtype)
        device_mem = cuda.mem_alloc(host_mem.nbytes)
        bindings.append(int(device_mem))
        if engine.binding_is_input(binding):
            inputs.append(HostDeviceMem(host_mem, device_mem))
        else:
            outputs.append(HostDeviceMem(host_mem, device_mem))
    return (inputs, outputs, bindings, stream)
Allocates host and device buffer for TRT engine inference.

This function is similair to the one in ../../common.py, but
converts network outputs (which are np.float32) appropriately
before writing them to Python buffer. This is needed, since
TensorRT plugins doesn't support output type description, and
in our particular case, we use NMS plugin as network output.

Args:
    engine (trt.ICudaEngine): TensorRT engine

Returns:
    inputs [HostDeviceMem]: engine input memory
    outputs [HostDeviceMem]: engine output memory
    bindings [int]: buffer to device bindings
    stream (cuda.Stream): cuda stream for engine inference synchronization
def allocate_buffers(engine):
    "Allocates host and device buffer for TRT engine inference.\n\n    This function is similair to the one in ../../common.py, but\n    converts network outputs (which are np.float32) appropriately\n    before writing them to Python buffer. This is needed, since\n    TensorRT plugins doesn't support output type description, and\n    in our particular case, we use NMS plugin as network output.\n\n    Args:\n        engine (trt.ICudaEngine): TensorRT engine\n\n    Returns:\n        inputs [HostDeviceMem]: engine input memory\n        outputs [HostDeviceMem]: engine output memory\n        bindings [int]: buffer to device bindings\n        stream (cuda.Stream): cuda stream for engine inference synchronization\n    "
    inputs = []
    outputs = []
    bindings = []
    stream = cuda.Stream()
    binding_to_type = {'Input': np.float32, 'NMS': np.float32, 'NMS_1': np.int32}
    for binding in engine:
        size = (trt.volume(engine.get_binding_shape(binding)) * engine.max_batch_size)
        dtype = binding_to_type[str(binding)]
        host_mem = cuda.pagelocked_empty(size, dtype)
        device_mem = cuda.mem_alloc(host_mem.nbytes)
        bindings.append(int(device_mem))
        if engine.binding_is_input(binding):
            inputs.append(HostDeviceMem(host_mem, device_mem))
        else:
            outputs.append(HostDeviceMem(host_mem, device_mem))
    return (inputs, outputs, bindings, stream)