Coverage for /opt/cloud/slavespace/usr1/096471637100f3de0fcfc01072822a80/dttest/api/python/ge/ge/passes/fuse_inspector.py: 100%
12 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-27 10:03 +0800
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-27 10:03 +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"""Fusion feasibility checks and reporting helpers for Python GE passes."""
15from __future__ import annotations
17from dataclasses import dataclass
18from typing import TYPE_CHECKING, Iterable
20from . import _native
22if TYPE_CHECKING:
23 from ge.graph.node import Node
26@dataclass(frozen=True)
27class FuseCheckResult:
28 """Result of checking whether a node set can be safely fused."""
30 ok: bool
31 reason: str = ""
34report_fuse = _native.report_fuse
37def can_fuse(nodes: Iterable["Node"]) -> FuseCheckResult:
38 """Check whether ``nodes`` can be safely fused into one node."""
39 ok, reason = _native.can_fuse(nodes)
40 return FuseCheckResult(ok=ok, reason=reason)