-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5055d7e
commit 0227f54
Showing
22 changed files
with
280 additions
and
324 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,9 @@ | ||
import logging | ||
from typing import Any | ||
|
||
from onnx import ModelProto, NodeProto | ||
from zigzag.parser.onnx.MatMulParser import MatMulParser as MatMulParserZigZag | ||
|
||
from stream.classes.hardware.architecture.accelerator import Accelerator | ||
from stream.classes.workload.computation_node import ComputationNode | ||
from stream.classes.io.onnx.gemm import GemmParser | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class MatMulParser(MatMulParserZigZag): | ||
"""Parses an ONNX MatMul operator into a ComputationNode""" | ||
|
||
def __init__( | ||
self, | ||
node_id: int, | ||
node: NodeProto, | ||
nodes_outputs: dict[int, Any], | ||
mapping_data: list[dict[str, Any]], | ||
onnx_model: ModelProto, | ||
accelerator: Accelerator, | ||
) -> None: | ||
super().__init__(node_id, node, nodes_outputs, mapping_data, onnx_model) | ||
self.accelerator = accelerator | ||
|
||
def run(self): | ||
"""Run the parser""" | ||
return self.generate_node() | ||
|
||
def generate_node(self): | ||
layer_node = self.generate_layer_node() | ||
node_attrs = layer_node.extract_node_attr() | ||
|
||
# Override spatial mapping by the one defined in the core's dataflows | ||
core_allocation = node_attrs.core_allocation | ||
spatial_mapping = self.accelerator.get_spatial_mapping_from_core(core_allocation) | ||
node_attrs.spatial_mapping = spatial_mapping | ||
|
||
# Get the node's input(s) and output(s) tensor names | ||
node_input_names = list(self.node.input) | ||
node_output_names = list(self.node.output) | ||
return ComputationNode( | ||
node_id=self.node_id, | ||
node_name=self.node.name, | ||
node_attr=node_attrs, | ||
input_names=node_input_names, | ||
output_names=node_output_names, | ||
op_type=node_attrs.layer_type, | ||
operand_tensor_reshape=None, | ||
) | ||
class MatMulParser(GemmParser): | ||
"""! Parses an ONNX MatMul operator into a ComputationNode. Exactly the same as Gemm Parser""" |
Oops, something went wrong.