Binding

class dragon.vm.tensorrt.Binding(
  cuda_engine,
  execution_context,
  idx_or_name,
  device_id
)[source]

The binding wrapper for an input or output.

__init__

Binding.__init__(
  cuda_engine,
  execution_context,
  idx_or_name,
  device_id
)[source]

Create a Binding.

Parameters:
  • cuda_engine (tensorrt.ICudaEngine) The built cuda engine.
  • execution_context (tensorrt.IExecutionContext) The execution context.
  • idx_or_name (Union[int, str]) The binding index or name.
  • device_id (int, optional, default=0) The index of executing device.

Properties

device_buffer

Binding.device_buffer

Return the device buffer.

Returns:
pycuda.gpuarray.GPUArray The pycuda array taking the data.

device_dlpack

Binding.device_dlpack

Return the dlpack tensor wrapping device buffer.

Returns:
PyCapsule The dlpack tensor object.

device_id

Binding.device_id

Return the index of binding device.

Returns:
int The device index.

dtype

Binding.dtype

Return binding data type.

Returns:
str The binding data type.

host_buffer

Binding.host_buffer

Return the host buffer.

Returns:
numpy.array The numpy array taking the data.

host_dlpack

Binding.host_dlpack

Return the dlpack tensor wrapping host buffer.

Returns:
PyCapsule The dlpack tensor object.

index

Binding.index

Return the binding index.

Returns:
int The binding index.

is_input

Binding.is_input

Whether this binding is an input.

Returns:
bool True if binding is an input.

name

Binding.name

Return the binding name.

Returns:
str The binding name.

shape

Binding.shape

Return the binding shape.

Returns:
Tuple[int] The binging shape.

Methods

get_async

Binding.get_async(stream)[source]

Copy and return the host buffer data.

Parameters:
  • stream (pycuda.driver.Stream) The cuda stream to copy data.
Returns:

numpy.array The numpy array taking the data.