Public Member Functions | |
def | __init__ (self) |
def | __setattr__ (self, name, value) |
def | is_empty (self) |
def | to_constant (self, np.ndarray values) |
def | to_variable (self, np.dtype dtype=None, Sequence[Union[int, str]] shape=[]) |
def | i (self, tensor_idx=0, producer_idx=0) |
def | o (self, consumer_idx=0, tensor_idx=0) |
def | __str__ (self) |
def | __repr__ (self) |
def | __eq__ (self, other) |
Public Attributes | |
name | |
values | |
dtype | |
shape | |
Static Public Attributes | |
int | DYNAMIC = -1 |
Private Attributes | |
__class__ | |
Abstract base class for tensors in a graph
def onnx_graphsurgeon.ir.tensor.Tensor.__init__ | ( | self | ) |
**This class is abstract and cannot be constructed directly.**
def onnx_graphsurgeon.ir.tensor.Tensor.__setattr__ | ( | self, | |
name, | |||
value | |||
) |
def onnx_graphsurgeon.ir.tensor.Tensor.is_empty | ( | self | ) |
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.
def onnx_graphsurgeon.ir.tensor.Tensor.to_constant | ( | self, | |
np.ndarray | values | ||
) |
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.
def onnx_graphsurgeon.ir.tensor.Tensor.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 in onnx_graphsurgeon.ir.tensor.Constant.
def onnx_graphsurgeon.ir.tensor.Tensor.i | ( | self, | |
tensor_idx = 0 , |
|||
producer_idx = 0 |
|||
) |
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.
def onnx_graphsurgeon.ir.tensor.Tensor.o | ( | self, | |
consumer_idx = 0 , |
|||
tensor_idx = 0 |
|||
) |
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
def onnx_graphsurgeon.ir.tensor.Tensor.__str__ | ( | self | ) |
def onnx_graphsurgeon.ir.tensor.Tensor.__repr__ | ( | self | ) |
def onnx_graphsurgeon.ir.tensor.Tensor.__eq__ | ( | self, | |
other | |||
) |
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.
|
static |
onnx_graphsurgeon.ir.tensor.Tensor.name |
|
private |
onnx_graphsurgeon.ir.tensor.Tensor.values |
onnx_graphsurgeon.ir.tensor.Tensor.dtype |
onnx_graphsurgeon.ir.tensor.Tensor.shape |