From abf939cbeb107b09c430e7748f37bae386caea67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=BC=BA?= Date: Tue, 15 Apr 2025 02:31:30 +0000 Subject: [PATCH] =?UTF-8?q?!2941=20autofuse=20lowering=20add=20scope=20Mer?= =?UTF-8?q?ge=20pull=20request=20!2941=20from=20=E5=88=98=E5=BC=BA/lowerin?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../python/npu_bridge/estimator/npu/npu_scope.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tf_adapter/python/npu_bridge/estimator/npu/npu_scope.py b/tf_adapter/python/npu_bridge/estimator/npu/npu_scope.py index 12f8075b9..63eb0ce65 100644 --- a/tf_adapter/python/npu_bridge/estimator/npu/npu_scope.py +++ b/tf_adapter/python/npu_bridge/estimator/npu/npu_scope.py @@ -206,3 +206,15 @@ def npu_graph_slice_scope(slice_num=None): if slice_num is not None: util.check_positive_integer(slice_num, "slice_num") return ops.name_scope_v2("".join(["SliceNum-", str(slice_num), "-NpuGraphSlicing", str(slice_num)])) + + +@contextlib.contextmanager +def disable_autofuse(): + """ + Disable the autofuse of operators within the scope. + """ + attrs = { + "_disable_autofuse_scope": attr_value_pb2.AttrValue(b=True) + } + with ops.get_default_graph()._attr_scope(attrs): + yield -- Gitee