|
def | __init__ (self, str name, np.ndarray values) |
|
def | to_variable (self, np.dtype dtype=None, Sequence[Union[int, str]] shape=[]) |
|
def | copy (self) |
|
def | shape (self) |
|
def | dtype (self) |
|
def | __repr__ (self) |
|
def | __setattr__ (self, name, value) |
|
def | is_empty (self) |
|
def | to_constant (self, np.ndarray values) |
|
def | i (self, tensor_idx=0, producer_idx=0) |
|
def | o (self, consumer_idx=0, tensor_idx=0) |
|
def | __str__ (self) |
|
def | __eq__ (self, other) |
|
◆ __init__()
def onnx_graphsurgeon.ir.tensor.Constant.__init__ |
( |
|
self, |
|
|
str |
name, |
|
|
np.ndarray |
values |
|
) |
| |
Represents a Tensor whose value is known.
Args:
name (str): The name of the tensor.
values (numpy.ndarray): The values in this tensor, in the form of a NumPy array.
dtype (numpy.dtype): The data type of the tensor.
shape (Sequence[Union[int, str]]): The shape of the tensor.
◆ to_variable()
def onnx_graphsurgeon.ir.tensor.Constant.to_variable |
( |
|
self, |
|
|
np.dtype |
dtype = None , |
|
|
Sequence[Union[int, str]] |
shape = [] |
|
) |
| |
Modifies this tensor in-place to convert it to a Variable. This means that all consumers/producers of the tensor will see the update.
Args:
dtype (np.dtype): The data type of the tensor.
shape (Sequence[int]): The shape of the tensor.
Returns:
self
Reimplemented from onnx_graphsurgeon.ir.tensor.Tensor.
◆ copy()
def onnx_graphsurgeon.ir.tensor.Constant.copy |
( |
|
self | ) |
|
Makes a shallow copy of this tensor, omitting input and output information.
Note: Generally, you should only ever make a deep copy of a Graph.
◆ shape()
def onnx_graphsurgeon.ir.tensor.Constant.shape |
( |
|
self | ) |
|
◆ dtype()
def onnx_graphsurgeon.ir.tensor.Constant.dtype |
( |
|
self | ) |
|
◆ __repr__()
def onnx_graphsurgeon.ir.tensor.Constant.__repr__ |
( |
|
self | ) |
|
◆ __setattr__()
def onnx_graphsurgeon.ir.tensor.Tensor.__setattr__ |
( |
|
self, |
|
|
|
name, |
|
|
|
value |
|
) |
| |
|
inherited |
◆ is_empty()
def onnx_graphsurgeon.ir.tensor.Tensor.is_empty |
( |
|
self | ) |
|
|
inherited |
Returns whether this tensor is considered empty in the graph.
*Note: 'Empty' here refers to the name of the tensor, which is omitted for
optional tensors, NOT the shape of the tensor*
Returns:
bool: Whether the tensor is empty, meaning that it is used for an omitted optional input or output.
◆ to_constant()
def onnx_graphsurgeon.ir.tensor.Tensor.to_constant |
( |
|
self, |
|
|
np.ndarray |
values |
|
) |
| |
|
inherited |
Modifies this tensor in-place to convert it to a Constant. This means that all consumers/producers of the tensor will see the update.
Args:
values (np.ndarray): The values in this tensor
Returns:
self
Reimplemented in onnx_graphsurgeon.ir.tensor.Variable.
◆ i()
def onnx_graphsurgeon.ir.tensor.Tensor.i |
( |
|
self, |
|
|
|
tensor_idx = 0 , |
|
|
|
producer_idx = 0 |
|
) |
| |
|
inherited |
Convenience function to get an input tensor of one of this tensor's input nodes.
Note that the parameters are swapped compared to the o() function; this is because tensors are likely to have only a single producer
For example:
::
assert tensor.i() == tensor.inputs[0].inputs[0]
assert tensor.i(1, 2) == tensor.inputs[2].inputs[1]
Args:
tensor_idx (int): The index of the input tensor of the input node. Defaults to 0.
producer_idx (int): The index of the producer node of the input tensor, if the tensor has multiple producers. Defaults to 0.
Returns:
Tensor: The specified producer (input) tensor.
◆ o()
def onnx_graphsurgeon.ir.tensor.Tensor.o |
( |
|
self, |
|
|
|
consumer_idx = 0 , |
|
|
|
tensor_idx = 0 |
|
) |
| |
|
inherited |
Convenience function to get an output tensor of one of this tensor's output nodes.
For example:
::
assert tensor.o() == tensor.outputs[0].outputs[0]
assert tensor.o(2, 1) == tensor.outputs[2].outputs[1]
Args:
consumer_idx (int): The index of the consumer of the input tensor. Defaults to 0.
tensor_idx (int): The index of the output tensor of the node, if the node has multiple outputs. Defaults to 0.
Returns:
Tensor: The specified consumer (output) tensor
◆ __str__()
def onnx_graphsurgeon.ir.tensor.Tensor.__str__ |
( |
|
self | ) |
|
|
inherited |
◆ __eq__()
def onnx_graphsurgeon.ir.tensor.Tensor.__eq__ |
( |
|
self, |
|
|
|
other |
|
) |
| |
|
inherited |
Perform a check to see if two tensors are equal.
Tensors are considered equal if they share the same name. A Graph must not include Tensors with duplicate names.
◆ name
onnx_graphsurgeon.ir.tensor.Constant.name |
◆ inputs
onnx_graphsurgeon.ir.tensor.Constant.inputs |
◆ outputs
onnx_graphsurgeon.ir.tensor.Constant.outputs |
◆ values
onnx_graphsurgeon.ir.tensor.Constant.values |
◆ DYNAMIC
int onnx_graphsurgeon.ir.tensor.Tensor.DYNAMIC = -1 |
|
staticinherited |
◆ __class__
onnx_graphsurgeon.ir.tensor.Tensor.__class__ |
|
privateinherited |
◆ dtype
onnx_graphsurgeon.ir.tensor.Tensor.dtype |
|
inherited |
◆ shape
onnx_graphsurgeon.ir.tensor.Tensor.shape |
|
inherited |
The documentation for this class was generated from the following file: