Constant#

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

import numpy as np
import onnx

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")

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.

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.

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.

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.