afe.ir.build_nodeο
Functions for building and initializing AwesomeNodes for specific operators. These functions provide a simpler way to create an instance of a chosen operator and initialize all the data structure fields. These functions are not used for transformations on arbitrary operators.
Attributesο
Classesο
Information about a SiMa IR node that can be used when creating other nodes. |
Functionsο
|
Creates a Tuple AwesomeNode. Used to accommodate AwesomeNet with multiple outputs. |
Creates a TupleGetItem node that is used to split the Tuple output node. |
|
|
Creates a Tuple AwesomeNode. Used to accommodate AwesomeNet with multiple outputs. |
|
Creates a Placeholder AwesomeNode. Each AwesomeNet must have PlaceholderNodes to |
|
Create a quantization node to quantize from float to integer (int8, int16) |
|
Create a dequantization node to dequantize from integer (int8, int16, int32) to float. |
|
Create requantization node that will be used for converting data from int32 to int16 or int8 type. |
|
Create a node that casts tensors from one scalar type to another. |
|
Create a softmax node. |
|
Create an argmax node. |
|
Create a broadcast_to node. |
|
Create a batch_matmul node. |
|
Create an add node. |
|
Create a subtract node. |
|
Create a multiply node. |
|
Create a sigmoid node. |
|
Create a swish node. |
|
Create a gelu node. |
|
Create a quick_gelu node. |
|
Create a slice_concat node. |
|
|
|
|
|
Create an RMSNorm node. |
|
|
|
Create a constant node. |
|
Create a node containing an AwesomeNet. |
Module Contentsο
- class afe.ir.build_node.NodeHandleο
Information about a SiMa IR node that can be used when creating other nodes.
- name: afe.ir.defines.NodeNameο
- quantization: afe.ir.defines.DataValue[afe.ir.defines.Quantization | None]ο
- static from_node(n: afe.ir.node.AwesomeNode) NodeHandleο
Create a NodeHandle representing a given node.
- Parameters:
n β Node to be represented by the handle
- afe.ir.build_node.NodeOrHandleο
- afe.ir.build_node.create_tuple_output_node(tuple_inputs: List[afe.ir.node.AwesomeNode], prefix: str) afe.ir.node.AwesomeNodeο
Creates a Tuple AwesomeNode. Used to accommodate AwesomeNet with multiple outputs.
- Parameters:
tuple_inputs β List of AwesomeNodes that serve as input nodes to resulting Tuple AwesomeNode.
- Returns:
The created Tuple AwesomeNode.
- afe.ir.build_node.create_tuple_get_item_nodes(input_node_name: afe.ir.defines.NodeName, output_types: List[afe.ir.tensor_type.TensorType], prefix: str, input_quant: afe.ir.defines.TupleValue[afe.ir.attributes.QuantResultTensorType] | None = None) List[afe.ir.node.AwesomeNode]ο
Creates a TupleGetItem node that is used to split the Tuple output node.
- Parameters:
input_node_name β The name of the input Tuple node.
output_types β List of types corresponding to the output types of the Tuple node.
prefix β The prefix string that is prepended to the TupleGetItem node name.
input_quant β Quantization parameters of the input nodes.
- Returns:
The list of TupleGtItem AwesomeNodes.
- afe.ir.build_node.create_tuple_node(fields: List[NodeOrHandle], name_counter: int) afe.ir.node.AwesomeNodeο
Creates a Tuple AwesomeNode. Used to accommodate AwesomeNet with multiple outputs.
- Parameters:
fields β List of AwesomeNodes that serve as input nodes to resulting Tuple AwesomeNode.
- Returns:
The created Tuple AwesomeNode.
- afe.ir.build_node.create_tuple_get_item_nodes_2(data: NodeOrHandle, name_counter: int) list[afe.ir.node.AwesomeNode]ο
- afe.ir.build_node.create_placeholder_node(node_name: str, input_type: afe.ir.tensor_type.TensorType) afe.ir.node.AwesomeNodeο
Creates a Placeholder AwesomeNode. Each AwesomeNet must have PlaceholderNodes to hold the input data.
- Parameters:
node_name β The name of the placeholder node to be created.
input_type β The input type for the placeholder node.
- Returns:
Placeholder node that is created.
- afe.ir.build_node.create_quantization_node(input_name: afe.ir.defines.NodeName, name_counter: int, cast: afe.ir.defines.QuantCast, backend: afe.backends.Backend = Backend.EV) afe.ir.node.AwesomeNodeο
Create a quantization node to quantize from float to integer (int8, int16)
- Parameters:
input_name β Input node name
name_counter β Node index
cast β Cast to perform quantization
backend β Backend on which node will be executed
- Returns:
AwesomeNode
- afe.ir.build_node.create_dequantization_node(input_name: afe.ir.defines.NodeName, name_counter: int, cast: afe.ir.defines.DequantCast, backend: afe.backends.Backend = Backend.EV) afe.ir.node.AwesomeNodeο
Create a dequantization node to dequantize from integer (int8, int16, int32) to float.
- Parameters:
input_name β Input node name
name_counter β Node index
cast β Cast to perform dequantization
backend β Backend on which node will be executed
- Returns:
AwesomeNode
- afe.ir.build_node.create_requantization_node(input_name: afe.ir.defines.NodeName, name_counter: int, input_type: afe.ir.tensor_type.TensorType, input_quant: afe.ir.defines.Quantization, output_quant: afe.ir.defines.Quantization, requant_method: afe.ir.defines.RequantMethod, requant: ml_kernels.requantization.BaseRequantization[numpy.ndarray]) afe.ir.node.AwesomeNodeο
Create requantization node that will be used for converting data from int32 to int16 or int8 type.
- Parameters:
input_name β Input node name
name_counter β Node index
input_type β TensorType of the input tensor
input_quant β Quantization of input tensor
output_quant β Quantization of output tensor
requant_method β Requantization method
requant β Requantization to perform
- Returns:
AwesomeNode
- afe.ir.build_node.create_cast_node(data: NodeOrHandle, name_counter: int, output_type: afe.ir.tensor_type.ScalarType) afe.ir.node.AwesomeNodeο
Create a node that casts tensors from one scalar type to another. Casting does not requantize, but only converts the data to a different numeric type.
- Parameters:
data β Input of the new cast node
name_counter β Node index
output_type β Scalar type of the output
- Returns:
New cast node.
- afe.ir.build_node.create_softmax_node(data: NodeOrHandle, name_counter: int, axis: int) afe.ir.node.AwesomeNodeο
Create a softmax node.
- Parameters:
data β Input node
name_counter β Node index
axis β Axis over which softmax is computed
- Returns:
Softmax node.
- afe.ir.build_node.create_argmax_node(data: NodeOrHandle, name_counter: int, output_type: afe.ir.tensor_type.ScalarType) afe.ir.node.AwesomeNodeο
Create an argmax node.
- Parameters:
data β Input node
name_counter β Node index
output_type β Type of output. Must be int8 or int32.
- Returns:
Argmax node.
- afe.ir.build_node.create_broadcast_to_node(data: NodeOrHandle, name_counter: int, output_shape: tuple[int, Ellipsis]) afe.ir.node.AwesomeNodeο
Create a broadcast_to node.
- Parameters:
data β Input of the new node
name_counter β Node index
output_shape β Shape of the output
- Returns:
Broadcast_to node.
- afe.ir.build_node.create_batch_matmul_node(lhs: NodeOrHandle, rhs: NodeOrHandle, name_counter: int, transpose_b: bool) afe.ir.node.AwesomeNodeο
Create a batch_matmul node.
- Parameters:
lhs β LHS input of the new node
rhs β RHS input of the new node
name_counter β Node index
transpose_b β Whether the batch_matmul computation transposes the rhs
- Returns:
batch_matmul node
- afe.ir.build_node.create_add_node(lhs: NodeOrHandle, rhs: NodeOrHandle, name_counter: int) afe.ir.node.AwesomeNodeο
Create an add node.
- Parameters:
lhs β LHS input of the new node
rhs β RHS input of the new node
name_counter β Node index
- Returns:
Add node
- afe.ir.build_node.create_subtract_node(lhs: NodeOrHandle, rhs: NodeOrHandle, name_counter: int) afe.ir.node.AwesomeNodeο
Create a subtract node.
- Parameters:
lhs β LHS input of the new node
rhs β RHS input of the new node
name_counter β Node index
- Returns:
subtract node
- afe.ir.build_node.create_mul_node(lhs: NodeOrHandle, rhs: NodeOrHandle, name_counter: int) afe.ir.node.AwesomeNodeο
Create a multiply node.
- Parameters:
lhs β LHS input of the new node
rhs β RHS input of the new node
name_counter β Node index
- Returns:
multiply node
- afe.ir.build_node.create_sigmoid_node(data: NodeOrHandle, name_counter: int) afe.ir.node.AwesomeNodeο
Create a sigmoid node.
- Parameters:
data β The input node
name_counter β Node index
- Returns:
sigmoid node
- afe.ir.build_node.create_swish_node(data: NodeOrHandle, name_counter: int) afe.ir.node.AwesomeNodeο
Create a swish node.
- Parameters:
data β The input node
name_counter β Node index
- Returns:
swish node
- afe.ir.build_node.create_gelu_node(data: NodeOrHandle, name_counter: int) afe.ir.node.AwesomeNodeο
Create a gelu node.
- Parameters:
data β The input node
name_counter β Node index
- Returns:
gelu node
- afe.ir.build_node.create_quick_gelu_node(data: NodeOrHandle, name_counter: int) afe.ir.node.AwesomeNodeο
Create a quick_gelu node.
- Parameters:
data β The input node
name_counter β Node index
- Returns:
quick_gelu node
- afe.ir.build_node.create_slice_concat_node(data: NodeOrHandle, name_counter: int, axis: int, split_axis: int, split_block: int, split_repeat: int)ο
Create a slice_concat node.
- Parameters:
data β Input of the slice_concat node
name_counter β Node index
axis β Axis to concatenate
split_axis β Axis to split
split_block β Number of parts to split into
split_repeat β Number of repetitions of split parts
- Returns:
Result of concatenation.
- afe.ir.build_node.create_slice_node(data: NodeOrHandle, name_counter: int, begin: list[int], end: list[int], strides: list[int], axes: list[int]) afe.ir.node.AwesomeNodeο
- afe.ir.build_node.create_conv_node(data: NodeOrHandle, name_counter: int, weights: numpy.ndarray, bias: numpy.ndarray | None, conv_attrs: afe.ir.attributes.ConvAttrs, activation: None, scales: numpy.ndarray | None = None)ο
- afe.ir.build_node.create_rms_norm_node(data: NodeOrHandle, name_counter: int, epsilon: float, scale: numpy.ndarray) afe.ir.node.AwesomeNodeο
Create an RMSNorm node.
- Parameters:
data β Input of node
name_counter β Node index
epsilon β Epsilon value used in RMSNorm calculation
scale β Output scale factor. This is a 1D array used in per-channel multiplication as part of the RMSNorm operator.
- Returns:
RMSNorm node
- afe.ir.build_node.create_concat_node(tensors: Sequence[NodeOrHandle], name_counter: int, axis: int) afe.ir.node.AwesomeNodeο
- afe.ir.build_node.create_constant_node(name_counter: int, value: numpy.ndarray) afe.ir.node.AwesomeNodeο
Create a constant node.
- Parameters:
name_counter β Node index
value β Constant tensor value
- Returns:
Constant node
- afe.ir.build_node.create_net_node(net: afe.ir.net.AwesomeNet, input_names: list[afe.ir.defines.NodeName]) afe.ir.node.AwesomeNodeο
Create a node containing an AwesomeNet.
- Parameters:
net β Net to put into the node
input_names β Inputs of the node. These are values from the network.
- Returns:
Node containing the AwesomeNet.