Fill¶
Generates an output tensor based on input attributes.
Attributes¶
dimensions The shape of the output tensor.
operation Fill operation can be one of:
LINSPACEGenerate evenly spaced numbers over a specified interval. \(output[a_0,...,a_n] = \alpha + \beta[0,...,n] \cdot [0,...,n]\)RANDOM_UNIFORMGenerate a tensor with random values drawn from a uniform distribution. \(output[a_0,...,a_n] = random(min = \alpha, max = \beta)\)RANDOM_NORMALGenerate a tensor with random values drawn from a normal distribution. \(output[a_0,...,a_n] = normal(mean = \alpha, scale = \beta)\)
alpha parameter used in the Fill operation. Defaults to 0.
beta parameter used in the Fill operation. Defaults to 1.
toType The DataType of the output tensor. Defaults to float32.
Outputs¶
output: tensor of type T.
Data Types¶
Operation |
T |
|
|---|---|---|
|
||
|
||
|
||
Shape Information¶
output is a tensor with a shape of \([a_0,...,a_n]\), based on the dimensions attribute.
Examples¶
Fill
alpha = network.add_input("alpha", dtype=trt.float32, shape=())
beta = network.add_input("beta", dtype=trt.float32, shape=(2,))
layer = network.add_fill(shape=(2, 3), op=trt.FillOperation.LINSPACE)
layer.set_input(1, alpha)
layer.set_input(2, beta)
network.mark_output(layer.get_output(0))
inputs[alpha.name] = np.array([0.0])
inputs[beta.name] = np.array([3.0, 1.0])
outputs[layer.get_output(0).name] = layer.get_output(0).shape
expected[layer.get_output(0).name] = np.array([[0.0, 1.0, 2.0], [3.0, 4.0, 5.0]])
Fill Random
alpha = network.add_input("alpha", dtype=trt.float32, shape=())
beta = network.add_input("beta", dtype=trt.float32, shape=())
layer = network.add_fill(shape=(2, 3), op=trt.FillOperation.RANDOM_UNIFORM)
layer.set_input(1, alpha)
layer.set_input(2, beta)
network.mark_output(layer.get_output(0))
inputs[alpha.name] = np.array([2.0])
inputs[beta.name] = np.array([3.0])
outputs[layer.get_output(0).name] = layer.get_output(0).shape
# note: expected values should be in range of [2. ,3.]
C++ API¶
For more information about the C++ IFillLayer operator, refer to the C++ IFillLayer documentation.
Python API¶
For more information about the Python IFillLayer operator, refer to the Python IFillLayer documentation.