Computes the volume of an iterable.


iterable – Any python iterable, including a Dims object.


The volume of the iterable. This will return 1 for empty iterables, as a scalar has an empty shape and the volume of a tensor with empty shape is 1.


class tensorrt.Dims(*args, **kwargs)

Structure to define the dimensions of a tensor. Dims and all derived classes behave like Python tuple s. Furthermore, the TensorRT API can implicitly convert Python iterables to Dims objects, so tuple or list can be used in place of this class.

Overloaded function.

  1. __init__(self: tensorrt.tensorrt.Dims) -> None

  2. __init__(self: tensorrt.tensorrt.Dims, shape: List[int]) -> None

property MAX_DIMS

The maximum number of dimensions supported by Dims.


class tensorrt.Dims2(*args, **kwargs)

Structure to define 2D shape.

Overloaded function.

  1. __init__(self: tensorrt.tensorrt.Dims2) -> None

  2. __init__(self: tensorrt.tensorrt.Dims2, dim0: int, dim1: int) -> None

  3. __init__(self: tensorrt.tensorrt.Dims2, shape: List[int]) -> None


class tensorrt.DimsHW(*args, **kwargs)

Structure to define 2D shape with height and width.

  • hint The first dimension (height).

  • wint The second dimension (width).

Overloaded function.

  1. __init__(self: tensorrt.tensorrt.DimsHW) -> None

  2. __init__(self: tensorrt.tensorrt.DimsHW, h: int, w: int) -> None

  3. __init__(self: tensorrt.tensorrt.DimsHW, shape: List[int]) -> None


class tensorrt.Dims3(*args, **kwargs)

Structure to define 3D shape.

Overloaded function.

  1. __init__(self: tensorrt.tensorrt.Dims3) -> None

  2. __init__(self: tensorrt.tensorrt.Dims3, dim0: int, dim1: int, dim2: int) -> None

  3. __init__(self: tensorrt.tensorrt.Dims3, shape: List[int]) -> None


class tensorrt.Dims4(*args, **kwargs)

Structure to define 4D tensor.

Overloaded function.

  1. __init__(self: tensorrt.tensorrt.Dims4) -> None

  2. __init__(self: tensorrt.tensorrt.Dims4, dim0: int, dim1: int, dim2: int, dim3: int) -> None

  3. __init__(self: tensorrt.tensorrt.Dims4, shape: List[int]) -> None