m2m模型翻译
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
1.0 KiB

6 months ago
  1. # -------------------------------------------------------------------------
  2. # Copyright (c) Microsoft Corporation. All rights reserved.
  3. # Licensed under the MIT License.
  4. # --------------------------------------------------------------------------
  5. from logging import getLogger
  6. from fusion_base import Fusion
  7. from onnx import helper
  8. from onnx_model import OnnxModel
  9. class FusionGeluApproximation(Fusion):
  10. def __init__(self, model: OnnxModel):
  11. super().__init__(model, "FastGelu", ["Gelu", "BiasGelu"], "GeluApproximation")
  12. def fuse(self, node, input_name_to_nodes, output_name_to_node):
  13. new_node = helper.make_node(
  14. "FastGelu",
  15. inputs=node.input,
  16. outputs=node.output,
  17. name=self.model.create_node_name("FastGelu", node.op_type + "_Approximation"),
  18. )
  19. new_node.domain = "com.microsoft"
  20. self.nodes_to_remove.append(node)
  21. self.nodes_to_add.append(new_node)
  22. self.node_name_to_graph_name[new_node.name] = self.this_graph_name