Weights

tensorrt.WeightsRole

How a layer uses particular Weights. The power weights of an IScaleLayer are omitted. Refitting those is not supported.

Members:

KERNEL : Kernel for IConvolutionLayer or IDeconvolutionLayer .

BIAS : Bias for IConvolutionLayer or IDeconvolutionLayer .

SHIFT : Shift part of IScaleLayer .

SCALE : Scale part of IScaleLayer .

CONSTANT : Weights for IConstantLayer .

ANY : Any other weights role.

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

An array of weights used as a layer parameter. The weights are held by reference until the engine has been built - deep copies are not made automatically.

Variables
  • dtypeDataType The type of the weights.

  • sizeint The number of weights in the array.

  • nbytesint Total bytes consumed by the elements of the weights buffer.

Overloaded function.

  1. __init__(self: tensorrt.tensorrt.Weights, type: tensorrt.tensorrt.DataType = <DataType.FLOAT: 0>) -> None

    Initializes an empty (0-length) Weights object with the specified type.

    type

    A type to initialize the weights with. Default: tensorrt.float32

  2. __init__(self: tensorrt.tensorrt.Weights, type: tensorrt.tensorrt.DataType, ptr: int, count: int) -> None

    Initializes a Weights object with the specified data.

    type

    A type to initialize the weights with.

    ptr

    A pointer to the data.

    count

    The number of weights.

  3. __init__(self: tensorrt.tensorrt.Weights, a: numpy.ndarray) -> None

    a

    A numpy array whose values to use. No deep copies are made.

numpy(self: tensorrt.tensorrt.Weights) object

Create a numpy array using the underlying buffer of this weights object. The resulting array is just a view over the existing data, i.e. no deep copy is made.

If the weights cannot be converted to NumPy (e.g. due to unsupported data type), the original weights are returned.

Returns

The NumPy array or the original weights.