Constant

class onnx_graphsurgeon.Constant(name: str, values: Union[numpy.ndarray, onnx_graphsurgeon.ir.tensor.LazyValues], data_location: Optional[int] = None)

Bases: onnx_graphsurgeon.ir.tensor.Tensor

Represents a Tensor whose value is known.

Parameters
  • name (str) – The name of the tensor.

  • values (numpy.ndarray) – The values in this tensor, in the form of a NumPy array.

  • data_location (int) – An enum value indicating the location where the tensor data is stored. Generally, this will come from onnx.TensorProto.DataLocation.

to_variable(dtype: Optional[numpy.dtype] = None, shape: Sequence[Union[int, str]] = [])

Modifies this tensor in-place to convert it to a Variable. This means that all consumers/producers of the tensor will see the update.

Parameters
  • dtype (np.dtype) – The data type of the tensor.

  • shape (Sequence[int]) – The shape of the tensor.

Returns

self

copy()

Makes a shallow copy of this tensor, omitting input and output information.

Note: Generally, you should only ever make a copy of a Graph.