Constant¶
Generates an output tensor based on input values.
Attributes¶
shape
: Shape of the output tensor.
weights
: Weights of type T
. Must match the number of elements in the output tensor.
Outputs¶
output: Tensor of type T
.
Data Types¶
T: int32
, float16
, float32
Shape Information¶
output is a tensor with a shape of shape
.
DLA Restrictions¶
DLA supports this operator only when it’s connected to a PReLU operator as a second input.
Examples¶
Constant
input_shape = [1, 3, 3, 3]
w = np.arange(0.0, 27.0, dtype=np.dtype("f4"))
layer = network.add_constant(shape=input_shape, weights=trt.Weights(w))
network.mark_output(layer.get_output(0))
outputs[layer.get_output(0).name] = layer.get_output(0).shape
expected[layer.get_output(0).name] = w.reshape(input_shape)
C++ API¶
For more information about the C++ IConstantLayer operator, refer to the C++ IConstantLayer documentation.
Python API¶
For more information about the Python IConstantLayer operator, refer to the Python IConstantLayer documentation.