Coverage for /opt/cloud/slavespace/usr1/096471637100f3de0fcfc01072822a80/dttest/api/python/ge/ge/onnx_plugin/_bridge.py: 100%
16 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-18 20:50 +0800
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-18 20:50 +0800
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# -----------------------------------------------------------------------------------------------------------
4# Copyright (c) 2026 Huawei Technologies Co., Ltd.
5# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
6# CANN Open Software License Agreement Version 2.0 (the "License").
7# Please refer to the License for details. You may not use this file except in compliance with the License.
8# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
9# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10# See LICENSE in the root of the software repository for the full text of the License.
11# -----------------------------------------------------------------------------------------------------------
13"""Bridge-facing callback dispatch for Python ONNX Plugins."""
15from ge.graph.operator import create_operator
17from .bootstrap import load_onnx_plugins
18from .onnx_node import create_onnx_node
19from .registry import (
20 get_registered_onnx_plugin_by_origin_type,
21 get_registered_onnx_plugin_dicts,
22)
25def load_and_get_onnx_plugin_descriptors() -> list:
26 load_onnx_plugins()
27 return get_registered_onnx_plugin_dicts()
30def call_parse_node(origin_type: str, node_values: dict, operator_backend) -> None:
31 """Dispatch one flattened ONNX node to its registered parse_node callback."""
33 descriptor = get_registered_onnx_plugin_by_origin_type(origin_type)
34 if descriptor is None:
35 raise KeyError(f"python ONNX Plugin is not registered: {origin_type}")
37 node = create_onnx_node(**node_values)
38 with create_operator(operator_backend) as target:
39 result = descriptor.parser_node(node, target)
40 if result is not None:
41 raise TypeError("ONNX Plugin parse_node callback must return None")