.. _l-onnx-doc-Constant: ======== Constant ======== .. contents:: :local: .. _l-onnx-op-constant-13: Constant - 13 ============= **Version** * **name**: `Constant (GitHub) `_ * **domain**: **main** * **since_version**: **13** * **function**: False * **support_level**: SupportType.COMMON * **shape inference**: True This version of the operator has been available **since version 13**. **Summary** This operator produces a constant tensor. Exactly one of the provided attributes, either value, sparse_value, or value_* must be specified. **Attributes** * **sparse_value**: The value for the elements of the output tensor in sparse format. * **value**: The value for the elements of the output tensor. * **value_float**: The value for the sole element for the scalar, float32, output tensor. * **value_floats**: The values for the elements for the 1D, float32, output tensor. * **value_int**: The value for the sole element for the scalar, int64, output tensor. * **value_ints**: The values for the elements for the 1D, int64, output tensor. * **value_string**: The value for the sole element for the scalar, UTF-8 string, output tensor. * **value_strings**: The values for the elements for the 1D, UTF-8 string, output tensor. **Outputs** * **output** (heterogeneous) - **T**: Output tensor containing the same value of the provided tensor. **Type Constraints** * **T** in ( 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) ): Constrain input and output types to all tensor types. **Examples** **default** :: values = np.random.randn(5, 5).astype(np.float32) node = onnx.helper.make_node( "Constant", inputs=[], outputs=["values"], value=onnx.helper.make_tensor( name="const_tensor", data_type=onnx.TensorProto.FLOAT, dims=values.shape, vals=values.flatten().astype(float), ), ) expect(node, inputs=[], outputs=[values], name="test_constant") **Differences** .. raw:: html
00This operator produces a constant tensor. Exactly one of the provided attributes, either value, sparse_value,This operator produces a constant tensor. Exactly one of the provided attributes, either value, sparse_value,
11or value_* must be specified.or value_* must be specified.
22
33**Attributes****Attributes**
44
55* **sparse_value**:* **sparse_value**:
66 The value for the elements of the output tensor in sparse format. The value for the elements of the output tensor in sparse format.
77* **value**:* **value**:
88 The value for the elements of the output tensor. The value for the elements of the output tensor.
99* **value_float**:* **value_float**:
1010 The value for the sole element for the scalar, float32, output The value for the sole element for the scalar, float32, output
1111 tensor. tensor.
1212* **value_floats**:* **value_floats**:
1313 The values for the elements for the 1D, float32, output tensor. The values for the elements for the 1D, float32, output tensor.
1414* **value_int**:* **value_int**:
1515 The value for the sole element for the scalar, int64, output tensor. The value for the sole element for the scalar, int64, output tensor.
1616* **value_ints**:* **value_ints**:
1717 The values for the elements for the 1D, int64, output tensor. The values for the elements for the 1D, int64, output tensor.
1818* **value_string**:* **value_string**:
1919 The value for the sole element for the scalar, UTF-8 string, output The value for the sole element for the scalar, UTF-8 string, output
2020 tensor. tensor.
2121* **value_strings**:* **value_strings**:
2222 The values for the elements for the 1D, UTF-8 string, output tensor. The values for the elements for the 1D, UTF-8 string, output tensor.
2323
2424**Outputs****Outputs**
2525
2626* **output** (heterogeneous) - **T**:* **output** (heterogeneous) - **T**:
2727 Output tensor containing the same value of the provided tensor. Output tensor containing the same value of the provided tensor.
2828
2929**Type Constraints****Type Constraints**
3030
3131* **T** in (* **T** in (
32 tensor(bfloat16),
3233 tensor(bool), tensor(bool),
3334 tensor(complex128), tensor(complex128),
3435 tensor(complex64), tensor(complex64),
3536 tensor(double), tensor(double),
3637 tensor(float), tensor(float),
3738 tensor(float16), tensor(float16),
3839 tensor(int16), tensor(int16),
3940 tensor(int32), tensor(int32),
4041 tensor(int64), tensor(int64),
4142 tensor(int8), tensor(int8),
4243 tensor(string), tensor(string),
4344 tensor(uint16), tensor(uint16),
4445 tensor(uint32), tensor(uint32),
4546 tensor(uint64), tensor(uint64),
4647 tensor(uint8) tensor(uint8)
4748 ): ):
4849 Constrain input and output types to all tensor types. Constrain input and output types to all tensor types.
.. _l-onnx-op-constant-12: Constant - 12 ============= **Version** * **name**: `Constant (GitHub) `_ * **domain**: **main** * **since_version**: **12** * **function**: False * **support_level**: SupportType.COMMON * **shape inference**: True This version of the operator has been available **since version 12**. **Summary** This operator produces a constant tensor. Exactly one of the provided attributes, either value, sparse_value, or value_* must be specified. **Attributes** * **sparse_value**: The value for the elements of the output tensor in sparse format. * **value**: The value for the elements of the output tensor. * **value_float**: The value for the sole element for the scalar, float32, output tensor. * **value_floats**: The values for the elements for the 1D, float32, output tensor. * **value_int**: The value for the sole element for the scalar, int64, output tensor. * **value_ints**: The values for the elements for the 1D, int64, output tensor. * **value_string**: The value for the sole element for the scalar, UTF-8 string, output tensor. * **value_strings**: The values for the elements for the 1D, UTF-8 string, output tensor. **Outputs** * **output** (heterogeneous) - **T**: Output tensor containing the same value of the provided tensor. **Type Constraints** * **T** in ( 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) ): Constrain input and output types to all tensor types. **Differences** .. raw:: html
00A constant tensor. Exactly one of the two attributes, either value or sparse_value,This operator produces a constant tensor. Exactly one of the provided attributes, either value, sparse_value,
11must be specified.or value_* must be specified.
22
33**Attributes****Attributes**
44
55* **sparse_value**:* **sparse_value**:
66 The value for the elements of the output tensor in sparse format. The value for the elements of the output tensor in sparse format.
77* **value**:* **value**:
88 The value for the elements of the output tensor. The value for the elements of the output tensor.
9* **value_float**:
10 The value for the sole element for the scalar, float32, output
11 tensor.
12* **value_floats**:
13 The values for the elements for the 1D, float32, output tensor.
14* **value_int**:
15 The value for the sole element for the scalar, int64, output tensor.
16* **value_ints**:
17 The values for the elements for the 1D, int64, output tensor.
18* **value_string**:
19 The value for the sole element for the scalar, UTF-8 string, output
20 tensor.
21* **value_strings**:
22 The values for the elements for the 1D, UTF-8 string, output tensor.
923
1024**Outputs****Outputs**
1125
1226* **output** (heterogeneous) - **T**:* **output** (heterogeneous) - **T**:
1327 Output tensor containing the same value of the provided tensor. Output tensor containing the same value of the provided tensor.
1428
1529**Type Constraints****Type Constraints**
1630
1731* **T** in (* **T** in (
1832 tensor(bool), tensor(bool),
1933 tensor(complex128), tensor(complex128),
2034 tensor(complex64), tensor(complex64),
2135 tensor(double), tensor(double),
2236 tensor(float), tensor(float),
2337 tensor(float16), tensor(float16),
2438 tensor(int16), tensor(int16),
2539 tensor(int32), tensor(int32),
2640 tensor(int64), tensor(int64),
2741 tensor(int8), tensor(int8),
2842 tensor(string), tensor(string),
2943 tensor(uint16), tensor(uint16),
3044 tensor(uint32), tensor(uint32),
3145 tensor(uint64), tensor(uint64),
3246 tensor(uint8) tensor(uint8)
3347 ): ):
3448 Constrain input and output types to all tensor types. Constrain input and output types to all tensor types.
.. _l-onnx-op-constant-11: Constant - 11 ============= **Version** * **name**: `Constant (GitHub) `_ * **domain**: **main** * **since_version**: **11** * **function**: False * **support_level**: SupportType.COMMON * **shape inference**: True This version of the operator has been available **since version 11**. **Summary** A constant tensor. Exactly one of the two attributes, either value or sparse_value, must be specified. **Attributes** * **sparse_value**: The value for the elements of the output tensor in sparse format. * **value**: The value for the elements of the output tensor. **Outputs** * **output** (heterogeneous) - **T**: Output tensor containing the same value of the provided tensor. **Type Constraints** * **T** in ( 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) ): Constrain input and output types to all tensor types. **Differences** .. raw:: html
00A constant tensor.A constant tensor. Exactly one of the two attributes, either value or sparse_value,
1must be specified.
12
23**Attributes****Attributes**
34
5* **sparse_value**:
46* **value** (required): The value for the elements of the output tensor in sparse format.
7* **value**:
58 The value for the elements of the output tensor. The value for the elements of the output tensor.
69
710**Outputs****Outputs**
811
912* **output** (heterogeneous) - **T**:* **output** (heterogeneous) - **T**:
1013 Output tensor containing the same value of the provided tensor. Output tensor containing the same value of the provided tensor.
1114
1215**Type Constraints****Type Constraints**
1316
1417* **T** in (* **T** in (
1518 tensor(bool), tensor(bool),
1619 tensor(complex128), tensor(complex128),
1720 tensor(complex64), tensor(complex64),
1821 tensor(double), tensor(double),
1922 tensor(float), tensor(float),
2023 tensor(float16), tensor(float16),
2124 tensor(int16), tensor(int16),
2225 tensor(int32), tensor(int32),
2326 tensor(int64), tensor(int64),
2427 tensor(int8), tensor(int8),
2528 tensor(string), tensor(string),
2629 tensor(uint16), tensor(uint16),
2730 tensor(uint32), tensor(uint32),
2831 tensor(uint64), tensor(uint64),
2932 tensor(uint8) tensor(uint8)
3033 ): ):
3134 Constrain input and output types to all tensor types. Constrain input and output types to all tensor types.
.. _l-onnx-op-constant-9: Constant - 9 ============ **Version** * **name**: `Constant (GitHub) `_ * **domain**: **main** * **since_version**: **9** * **function**: False * **support_level**: SupportType.COMMON * **shape inference**: True This version of the operator has been available **since version 9**. **Summary** A constant tensor. **Attributes** * **value** (required): The value for the elements of the output tensor. **Outputs** * **output** (heterogeneous) - **T**: Output tensor containing the same value of the provided tensor. **Type Constraints** * **T** in ( 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) ): Constrain input and output types to all tensor types. **Differences** .. raw:: html
00A constant tensor.A constant tensor.
11
22**Attributes****Attributes**
33
44* **value** (required):* **value** (required):
55 The value for the elements of the output tensor. The value for the elements of the output tensor.
66
77**Outputs****Outputs**
88
99* **output** (heterogeneous) - **T**:* **output** (heterogeneous) - **T**:
1010 Output tensor containing the same value of the provided tensor. Output tensor containing the same value of the provided tensor.
1111
1212**Type Constraints****Type Constraints**
1313
1414* **T** in (* **T** in (
15 tensor(bool),
16 tensor(complex128),
17 tensor(complex64),
1518 tensor(double), tensor(double),
1619 tensor(float), tensor(float),
1720 tensor(float16) tensor(float16),
21 tensor(int16),
22 tensor(int32),
23 tensor(int64),
24 tensor(int8),
25 tensor(string),
26 tensor(uint16),
27 tensor(uint32),
28 tensor(uint64),
29 tensor(uint8)
1830 ): ):
1931 Constrain input and output types to float tensors. Constrain input and output types to all tensor types.
.. _l-onnx-op-constant-1: Constant - 1 ============ **Version** * **name**: `Constant (GitHub) `_ * **domain**: **main** * **since_version**: **1** * **function**: False * **support_level**: SupportType.COMMON * **shape inference**: True This version of the operator has been available **since version 1**. **Summary** A constant tensor. **Attributes** * **value** (required): The value for the elements of the output tensor. **Outputs** * **output** (heterogeneous) - **T**: Output tensor containing the same value of the provided tensor. **Type Constraints** * **T** in ( tensor(double), tensor(float), tensor(float16) ): Constrain input and output types to float tensors.