From a996ee3ee058eec2e88e35c47a11c2c9a3810be7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=BC=BA?= Date: Tue, 15 Apr 2025 10:47:41 +0800 Subject: [PATCH] c21 add scope --- .../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..e8a87e6a0 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 \ No newline at end of file -- Gitee