Constant - version 13#
This page documents version 13 of operator Constant. See Constant for the latest version (since version 25).
Domain:
ai.onnxSince version: 13
This operator produces a constant tensor. Exactly one of the provided attributes, either value, sparse_value, or value* must be specified.
Outputs
output (T): Output tensor containing the same value of the provided tensor.
Type Constraints
T: Constrain input and output types to all tensor types. Allowed types: tensor(bfloat16), tensor(bool), tensor(complex128), tensor(complex64), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8).
Examples#
test_cc_constant
Node:
Constant() -> (y)
Attributes:
value = <tensor>
Inputs:
Outputs:
y: shape=(2, 3), dtype=float32
[[-1. , 0. , 1.5 ],
[-2.25, 3.5 , -4.75]]
test_constant
Node:
Constant() -> (values)
Attributes:
value = <tensor>
Inputs:
Outputs:
values: shape=(5, 5), dtype=float32
[[ 1.7640524 , 0.4001572 , 0.978738 , 2.2408931 , 1.867558 ],
[-0.9772779 , 0.95008844, -0.1513572 , -0.10321885, 0.41059852],
[ 0.14404356, 1.4542735 , 0.7610377 , 0.12167501, 0.44386324],
[ 0.33367434, 1.4940791 , -0.20515826, 0.3130677 , -0.85409576],
[-2.5529897 , 0.6536186 , 0.8644362 , -0.742165 , 2.2697546 ]]
Differences with previous version (12)#
SchemaDiff: Constant (domain 'ai.onnx')
old version: 12
new version: 13
breaking: no
Type constraints:
changed ‘T’: added types: [‘tensor(bfloat16)’]