已合并
update MIN_SUPPORTED to 2.13 #45447
huangyunlong创建于 8 天前
update MIN_SUPPORTED to 2.13 #45447
已合并
huangyunlong创建于 8 天前
17 个文件变更+29-129
@@ -33,15 +33,15 @@ docker run -it -v /{code_path}/pytorch:/home/pytorch manylinux-builder:v1 bash
33 33 
34**Compile torch_npu**34**Compile torch_npu**
35 35 
36-Take Python 3.9 as an example36+Take Python 3.10 as an example
37 37 
38```Shell38```Shell
39cd /home/pytorch39cd /home/pytorch
40-bash ci/build.sh --python=3.940+bash ci/build.sh --python=3.10
41```41```
42 42 
43-Use `--torch=<version>` to target a specific PyTorch version (supported: 2.10.0, 2.11.0, 2.12.0, 2.13.0). The installed PyTorch must match.43+Use `--torch=<version>` to target a specific PyTorch version (supported: 2.13.0, 2.14.0). The installed PyTorch must match.
44 44 
45```Shell45```Shell
46-bash ci/build.sh --python=3.9 --torch=2.11.046+bash ci/build.sh --python=3.10 --torch=2.13.0
47```47```
@@ -2,17 +2,11 @@ from torch_npu._compat.version import CURRENT_VERSION
2 2 
3__all__ = [3__all__ = [
4 "register_op_strategy",4 "register_op_strategy",
5- "register_prop_rule",
6 "_mm_like_strategy",5 "_mm_like_strategy",
7]6]
8 7 
9-# COMPAT(>= 2.11): register_op_strategy / register_prop_rule moved from8+# register_op_strategy moved from _ops.registration to _ops.utils in PyTorch 2.11.
10-# _ops.registration to _ops.utils in PyTorch 2.11.9+from torch.distributed.tensor._ops.utils import register_op_strategy
11-# CAN REMOVE else branch when MIN_SUPPORTED >= (2, 11)
12-if CURRENT_VERSION >= (2, 11):
13- from torch.distributed.tensor._ops.utils import register_op_strategy, register_prop_rule
14-else:
15- from torch.distributed.tensor._ops.registration import register_op_strategy, register_prop_rule
16 10 
17 11 
18# COMPAT(>= 2.14): upstream pytorch#186667 removed the helper12# COMPAT(>= 2.14): upstream pytorch#186667 removed the helper
@@ -1,18 +0,0 @@
1-from torch_npu._compat.version import CURRENT_VERSION
2- 
3-# COMPAT(>= 2.11): sizevars.var_to_val renamed to sizevars.backed_var_to_val.
4-# CAN REMOVE when MIN_SUPPORTED >= (2, 11): use sizevars.backed_var_to_val directly
5-def get_sizevars_backed_var_to_val(sizevars):
6- if hasattr(sizevars, "backed_var_to_val"):
7- return sizevars.backed_var_to_val
8- return sizevars.var_to_val
9- 
10- 
11-# COMPAT(>= 2.11): gen_common_triton_imports changed from module-level function
12-# to instance method on the kernel object.
13-# CAN REMOVE when MIN_SUPPORTED >= (2, 11): call kernel.gen_common_triton_imports() directly
14-def gen_common_triton_imports(kernel):
15- if CURRENT_VERSION >= (2, 11):
16- return kernel.gen_common_triton_imports()
17- from torch._inductor.codegen.triton import gen_common_triton_imports as _fn
18- return _fn()
@@ -1,11 +0,0 @@
1-from torch_npu._compat.version import CURRENT_VERSION
2- 
3- 
4-# COMPAT(>= 2.12): _ConfigEntry.__init__ gained a required `name` parameter.
5-# Always pass `name=` at call sites; this wrapper drops it for older versions.
6-# CAN REMOVE when MIN_SUPPORTED >= (2, 12): construct _ConfigEntry directly.
7-def make_config_entry(config, *, name: str):
8- from torch.utils._config_module import _ConfigEntry
9- if CURRENT_VERSION >= (2, 12):
10- return _ConfigEntry(config, name=name)
11- return _ConfigEntry(config) # type: ignore[call-arg] - may missing `name` args for 2.13+ versions
@@ -9,4 +9,4 @@ def _parse(version_str: str) -> tuple:
9CURRENT_VERSION: tuple = _parse(torch.__version__)9CURRENT_VERSION: tuple = _parse(torch.__version__)
10 10 
11# Bump this when dropping old version support; run tools/check_compat.py to find stale COMPAT blocks.11# Bump this when dropping old version support; run tools/check_compat.py to find stale COMPAT blocks.
12-MIN_SUPPORTED_VERSION: tuple = (2, 10)12+MIN_SUPPORTED_VERSION: tuple = (2, 13)
@@ -119,14 +119,13 @@ def _normalize_npu_arch_to_atlas(arch: str) -> str:
119 else:119 else:
120 raise NotImplementedError(f"Unsupported npu arch: {arch}")120 raise NotImplementedError(f"Unsupported npu arch: {arch}")
121 121 
122-from torch_npu._compat.inductor import get_sizevars_backed_var_to_val
123def _trans_sympy_to_int(input_tuple, default_shape=8192):122def _trans_sympy_to_int(input_tuple, default_shape=8192):
124 output = []123 output = []
125 for x in input_tuple:124 for x in input_tuple:
126 if isinstance(x, (int, sympy.Integer)):125 if isinstance(x, (int, sympy.Integer)):
127 output.append(int(x))126 output.append(int(x))
128 elif isinstance(x, (sympy.Symbol, sympy.Expr)):127 elif isinstance(x, (sympy.Symbol, sympy.Expr)):
129- x = x.subs(get_sizevars_backed_var_to_val(V.graph.sizevars))128+ x = x.subs(V.graph.sizevars.backed_var_to_val)
130 try:129 try:
131 output.append(int(x))130 output.append(int(x))
132 except Exception:131 except Exception:
@@ -28,7 +28,6 @@ from . import catlass_utils
28from .catlass_python_evg import CatlassEVGCodegen28from .catlass_python_evg import CatlassEVGCodegen
29from .catlass_kernel import CATLASSTemplateBuffer, CATLASSTemplateKernel29from .catlass_kernel import CATLASSTemplateBuffer, CATLASSTemplateKernel
30from .catlass_template import CATLASSTemplate30from .catlass_template import CATLASSTemplate
31-from torch_npu._compat.inductor import get_sizevars_backed_var_to_val
32 31 
33log = logging.getLogger("torch._inductor")32log = logging.getLogger("torch._inductor")
34 33 
@@ -173,7 +172,7 @@ class CATLASSGemmTemplate(CATLASSTemplate, ABC):
173 if isinstance(x, (int, sympy.Integer)):172 if isinstance(x, (int, sympy.Integer)):
174 shape_desc[i] = int(x)173 shape_desc[i] = int(x)
175 elif isinstance(x, (sympy.Symbol, sympy.Expr)):174 elif isinstance(x, (sympy.Symbol, sympy.Expr)):
176- x = x.subs(get_sizevars_backed_var_to_val(V.graph.sizevars))175+ x = x.subs(V.graph.sizevars.backed_var_to_val)
177 try:176 try:
178 shape_desc[i] = int(x)177 shape_desc[i] = int(x)
179 except Exception:178 except Exception:
@@ -111,7 +111,6 @@ def _kernel_axis_vars(kernel):
111 return axis_vars111 return axis_vars
112 112 
113 113 
114-from torch_npu._compat.inductor import get_sizevars_backed_var_to_val
115class IndexAnalysis:114class IndexAnalysis:
116 def __init__(self, kernel, raw_index, is_store_index=False, is_index_expr=False):115 def __init__(self, kernel, raw_index, is_store_index=False, is_index_expr=False):
117 self.kernel = kernel116 self.kernel = kernel
@@ -121,7 +120,7 @@ class IndexAnalysis:
121 # only contains tiling axis vars120 # only contains tiling axis vars
122 self.var_list = tuple(x[0] for x in self.var_stride if x[0] in self.tiling_axis)121 self.var_list = tuple(x[0] for x in self.var_stride if x[0] in self.tiling_axis)
123 self.stride_list = tuple(x[1] for x in self.var_stride if x[0] in self.tiling_axis)122 self.stride_list = tuple(x[1] for x in self.var_stride if x[0] in self.tiling_axis)
124- self.index = raw_index.subs(get_sizevars_backed_var_to_val(V.graph.sizevars))123+ self.index = raw_index.subs(V.graph.sizevars.backed_var_to_val)
125 all_var_stride = [124 all_var_stride = [
126 (key, coeff)125 (key, coeff)
127 for key, coeff in self.index.as_coefficients_dict().items()126 for key, coeff in self.index.as_coefficients_dict().items()
@@ -12,7 +12,6 @@ from .triton_utils import get_byte_per_numel
12from .. import config as npu_config12from .. import config as npu_config
13from ..config import num_vector_core, log13from ..config import num_vector_core, log
14from ..runtime.symbolic_grouping import GroupFeatureSpec, GroupedKernelMeta14from ..runtime.symbolic_grouping import GroupFeatureSpec, GroupedKernelMeta
15-from torch_npu._compat.inductor import get_sizevars_backed_var_to_val
16 15 
17 16 
18_ELEMENTWISE_UNSUPPORTED_OPS = ("masked", "scan", "sort", "rand", "randn", "load_seed")17_ELEMENTWISE_UNSUPPORTED_OPS = ("masked", "scan", "sort", "rand", "randn", "load_seed")
@@ -67,7 +66,7 @@ class SplitTiling:
67 def get_length_val(x):66 def get_length_val(x):
68 length_expr = x.length67 length_expr = x.length
69 if not isinstance(length_expr, sympy.Integer):68 if not isinstance(length_expr, sympy.Integer):
70- return length_expr.subs(get_sizevars_backed_var_to_val(V.graph.sizevars))69+ return length_expr.subs(V.graph.sizevars.backed_var_to_val)
71 else:70 else:
72 return length_expr71 return length_expr
73 72 
@@ -809,10 +808,10 @@ class SplitTiling:
809 xnumel = x808 xnumel = x
810 ynumel = y809 ynumel = y
811 if isinstance(xnumel, (sympy.Symbol, sympy.Expr)) and not isinstance(xnumel, sympy.Integer):810 if isinstance(xnumel, (sympy.Symbol, sympy.Expr)) and not isinstance(xnumel, sympy.Integer):
812- xnumel = xnumel.subs(get_sizevars_backed_var_to_val(V.graph.sizevars))811+ xnumel = xnumel.subs(V.graph.sizevars.backed_var_to_val)
813 812 
814 if isinstance(ynumel, (sympy.Symbol, sympy.Expr)) and not isinstance(ynumel, sympy.Integer):813 if isinstance(ynumel, (sympy.Symbol, sympy.Expr)) and not isinstance(ynumel, sympy.Integer):
815- ynumel = ynumel.subs(get_sizevars_backed_var_to_val(V.graph.sizevars))814+ ynumel = ynumel.subs(V.graph.sizevars.backed_var_to_val)
816 815 
817 if isinstance(xnumel, sympy.Integer) and isinstance(ynumel, int):816 if isinstance(xnumel, sympy.Integer) and isinstance(ynumel, int):
818 ynumel = sympy.Integer(ynumel)817 ynumel = sympy.Integer(ynumel)
@@ -92,7 +92,6 @@ from .split_tiling import SplitTiling
92from .triton_utils import NPUKernelType92from .triton_utils import NPUKernelType
93from torch._inductor.shape_propagation import BlockShapeType93from torch._inductor.shape_propagation import BlockShapeType
94from enum import auto, Enum94from enum import auto, Enum
95-from torch_npu._compat.inductor import get_sizevars_backed_var_to_val
96 95 
97class NPUSymT(Enum):96class NPUSymT(Enum):
98 SIZE = auto()97 SIZE = auto()
@@ -3115,7 +3114,7 @@ class NPUIndexTritonKernel(TritonKernel):
3115 def load_store_index_in_all_tiling_list(self):3114 def load_store_index_in_all_tiling_list(self):
3116 res = False3115 res = False
3117 for index in self.load_store_indexing:3116 for index in self.load_store_indexing:
3118- index = index.subs(get_sizevars_backed_var_to_val(V.graph.sizevars))3117+ index = index.subs(V.graph.sizevars.backed_var_to_val)
3119 analyze = IndexAnalysis(self, index)3118 analyze = IndexAnalysis(self, index)
3120 res = res or self.all_tiling_in_var_list(analyze.var_list)3119 res = res or self.all_tiling_in_var_list(analyze.var_list)
3121 return res3120 return res
@@ -3613,7 +3612,7 @@ class NPUIndexTritonKernel(TritonKernel):
3613 longest = None3612 longest = None
3614 maximum_length = 03613 maximum_length = 0
3615 for index in self.load_store_indexing:3614 for index in self.load_store_indexing:
3616- index = index.subs(get_sizevars_backed_var_to_val(V.graph.sizevars))3615+ index = index.subs(V.graph.sizevars.backed_var_to_val)
3617 analyze = IndexAnalysis(self, index)3616 analyze = IndexAnalysis(self, index)
3618 if len(analyze.var_list) > maximum_length and self.all_tiling_in_var_list(3617 if len(analyze.var_list) > maximum_length and self.all_tiling_in_var_list(
3619 analyze.var_list3618 analyze.var_list
@@ -1,50 +0,0 @@
1-#pragma once
2- 
3-#include <c10/util/intrusive_ptr.h>
4-#include <torch/csrc/autograd/function.h>
5- 
6-#include <torch_npu/csrc/_compat/version.h>
7- 
8-#include <memory>
9-#include <utility>
10- 
11-// Compatibility layer for autograd Node smart-pointer changes introduced in
12-// PyTorch 2.13 (#181782): grad_fn allocation was migrated from
13-// std::shared_ptr<Op>(new Op(...), torch::autograd::deleteNode)
14-// to
15-// c10::make_intrusive<Op>(...)
16-// and SavedVariable::unpack() takes c10::intrusive_ptr<Node> instead of
17-// std::shared_ptr<Node>. deleteNode was removed entirely.
18-//
19-// CAN REMOVE the version branches below when MIN_SUPPORTED >= (2, 13).
20- 
21-namespace torch_npu {
22-namespace compat {
23- 
24-#if TORCH_NPU_VERSION_GE(2, 13)
25- 
26-template <typename T>
27-using GradFnPtr = c10::intrusive_ptr<T>;
28- 
29-template <typename Op, typename... Args>
30-inline GradFnPtr<Op> make_grad_fn(Args&&... args) {
L
Lli_jing_hw5 天前
已过期

这个是不是直接在引用源修改就行,这里可以删了

likedislike
huangyunlong
5 天前 评论:
31- return c10::make_intrusive<Op>(std::forward<Args>(args)...);
32-}
33- 
34-#else
35- 
36-template <typename T>
37-using GradFnPtr = std::shared_ptr<T>;
38- 
39-template <typename Op, typename... Args>
40-inline GradFnPtr<Op> make_grad_fn(Args&&... args) {
41- return std::shared_ptr<Op>(new Op(std::forward<Args>(args)...), torch::autograd::deleteNode);
42-}
43- 
44-#endif
45- 
46-// Type used by SavedVariable::unpack() — see comment at top of file.
47-using SavedForPtr = GradFnPtr<torch::autograd::Node>;
48- 
49-} // namespace compat
50-} // namespace torch_npu
@@ -15,4 +15,4 @@
15 15 
16// Keep in sync with MIN_SUPPORTED_VERSION in torch_npu/_compat/version.py.16// Keep in sync with MIN_SUPPORTED_VERSION in torch_npu/_compat/version.py.
17#define TORCH_NPU_MIN_SUPPORTED_MAJOR 217#define TORCH_NPU_MIN_SUPPORTED_MAJOR 2
18-#define TORCH_NPU_MIN_SUPPORTED_MINOR 1018+#define TORCH_NPU_MIN_SUPPORTED_MINOR 13
@@ -9,7 +9,6 @@
9#include <ATen/core/ivalue.h>9#include <ATen/core/ivalue.h>
10 10 
11#include <torch_npu/csrc/core/npu/NPUException.h>11#include <torch_npu/csrc/core/npu/NPUException.h>
12-#include <torch_npu/csrc/_compat/autograd.h>
13#include <torch_npu/csrc/framework/utils/CpuFallbackUtils.h>12#include <torch_npu/csrc/framework/utils/CpuFallbackUtils.h>
14 13 
15/*14/*
@@ -120,7 +119,7 @@ static void npuBasicAutogradNotImplementedFallbackImpl(
120 // by putting it after the requires_grad checks.119 // by putting it after the requires_grad checks.
121 any_input_requires_grad = any_input_requires_grad && at::GradMode::is_enabled();120 any_input_requires_grad = any_input_requires_grad && at::GradMode::is_enabled();
122 121 
123- torch_npu::compat::GradFnPtr<WarnNotImplemented> grad_fn;122+ c10::intrusive_ptr<WarnNotImplemented> grad_fn;
124 if (any_input_requires_grad) {123 if (any_input_requires_grad) {
125 // NB: It is standard to collect edges from all tensors124 // NB: It is standard to collect edges from all tensors
126 // (see generated/VariableTypeEverything.cpp for examples)125 // (see generated/VariableTypeEverything.cpp for examples)
@@ -130,7 +129,7 @@ static void npuBasicAutogradNotImplementedFallbackImpl(
130 stack,129 stack,
131 stack_start,130 stack_start,
132 num_arguments);131 num_arguments);
133- grad_fn = torch_npu::compat::make_grad_fn<WarnNotImplemented>(op_name, all_tensors_on_stack.size());132+ grad_fn = c10::make_intrusive<WarnNotImplemented>(op_name, all_tensors_on_stack.size());
134 grad_fn->set_next_edges(torch::autograd::collect_next_edges(all_tensors_on_stack));133 grad_fn->set_next_edges(torch::autograd::collect_next_edges(all_tensors_on_stack));
135 }134 }
136 135 
@@ -25,8 +25,6 @@
25#include <c10d/logger.hpp>25#include <c10d/logger.hpp>
26#include <c10d/debug.h>26#include <c10d/debug.h>
27 27 
28-#include <torch_npu/csrc/_compat/autograd.h>
29- 
30namespace c10d_npu {28namespace c10d_npu {
31 29 
32constexpr int kDefaultFirstBucketBytes = int(1024 * 1024);30constexpr int kDefaultFirstBucketBytes = int(1024 * 1024);
@@ -242,14 +240,11 @@ class Reducer {
242 // NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes)240 // NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes)
243 std::vector<bool> expect_sparse_gradients_;241 std::vector<bool> expect_sparse_gradients_;
244 242 
245- // COMPAT(>= 2.13): grad_accumulators_ and hooks_ element type changed from243+ std::vector<c10::intrusive_ptr<torch::autograd::Node>>
246- // std::shared_ptr<Node> to c10::intrusive_ptr<Node> (#181782).
247- // CAN REMOVE the alias indirection when MIN_SUPPORTED >= (2, 13).
248- std::vector<torch_npu::compat::GradFnPtr<torch::autograd::Node>>
249 grad_accumulators_; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes)244 grad_accumulators_; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes)
250 // NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes)245 // NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes)
251 std::unordered_map<torch::autograd::Node*, size_t> gradAccToVariableMap_;246 std::unordered_map<torch::autograd::Node*, size_t> gradAccToVariableMap_;
252- std::vector<std::pair<uintptr_t, torch_npu::compat::GradFnPtr<torch::autograd::Node>>>247+ std::vector<std::pair<uintptr_t, c10::intrusive_ptr<torch::autograd::Node>>>
253 hooks_; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes)248 hooks_; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes)
254 249 
255 // NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes)250 // NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes)
@@ -11,7 +11,6 @@
11 11 
12#include <torch_npu/csrc/framework/autograd/FunctionsManual.h>12#include <torch_npu/csrc/framework/autograd/FunctionsManual.h>
13#include <torch_npu/csrc/core/npu/NPUException.h>13#include <torch_npu/csrc/core/npu/NPUException.h>
14-#include <torch_npu/csrc/_compat/autograd.h>
15 14 
16using namespace at;15using namespace at;
17using namespace at_npu::autograd::generated;16using namespace at_npu::autograd::generated;
@@ -100,9 +99,9 @@ namespace {
100// Taken from codegened version99// Taken from codegened version
101Tensor _fw_primal(c10::DispatchKeySet ks, const Tensor& self, int64_t level) {100Tensor _fw_primal(c10::DispatchKeySet ks, const Tensor& self, int64_t level) {
102 auto& self_ = unpack(self, "self", 0);101 auto& self_ = unpack(self, "self", 0);
103- torch_npu::compat::GradFnPtr<Identity> grad_fn;102+ c10::intrusive_ptr<Identity> grad_fn;
104 if (compute_requires_grad(self)) {103 if (compute_requires_grad(self)) {
105- grad_fn = torch_npu::compat::make_grad_fn<Identity>();104+ grad_fn = c10::make_intrusive<Identity>();
106 grad_fn->set_next_edges(collect_next_edges(self));105 grad_fn->set_next_edges(collect_next_edges(self));
107 }106 }
108 107 
@@ -163,9 +163,7 @@ def patch_inductor_wrapper():
163 from typing import Any, Optional163 from typing import Any, Optional
164 164 
165 from torch import _TorchCompileInductorWrapper165 from torch import _TorchCompileInductorWrapper
166- from torch.utils._config_module import Config, ConfigModule166+ from torch.utils._config_module import Config, ConfigModule, _ConfigEntry
167- 
168- from torch_npu._compat.utils import make_config_entry
169 167 
170 src_apply_options = _TorchCompileInductorWrapper.apply_options168 src_apply_options = _TorchCompileInductorWrapper.apply_options
171 src_init = _TorchCompileInductorWrapper.__init__169 src_init = _TorchCompileInductorWrapper.__init__
@@ -190,28 +188,28 @@ def patch_inductor_wrapper():
190 return ori_dict188 return ori_dict
191 if "npu_backend" not in ori_dict:189 if "npu_backend" not in ori_dict:
192 ori_dict["npu_backend"] = "default"190 ori_dict["npu_backend"] = "default"
193- self._config["npu_backend"] = make_config_entry(191+ self._config["npu_backend"] = _ConfigEntry(
194 Config(default="default", value_type=str),192 Config(default="default", value_type=str),
195 name="npu_backend",193 name="npu_backend",
196 )194 )
197 195 
198 if "enable_shape_handling" not in ori_dict:196 if "enable_shape_handling" not in ori_dict:
199 ori_dict["enable_shape_handling"] = False197 ori_dict["enable_shape_handling"] = False
200- self._config["enable_shape_handling"] = make_config_entry(198+ self._config["enable_shape_handling"] = _ConfigEntry(
201 Config(default=False, value_type=bool),199 Config(default=False, value_type=bool),
202 name="enable_shape_handling",200 name="enable_shape_handling",
203 )201 )
204 202 
205 if "shape_handling_configs" not in ori_dict:203 if "shape_handling_configs" not in ori_dict:
206 ori_dict["shape_handling_configs"] = []204 ori_dict["shape_handling_configs"] = []
207- self._config["shape_handling_configs"] = make_config_entry(205+ self._config["shape_handling_configs"] = _ConfigEntry(
208 Config(default=[], value_type=list),206 Config(default=[], value_type=list),
209 name="shape_handling_configs",207 name="shape_handling_configs",
210 )208 )
211 209 
212 if "shape_handling_dict" not in ori_dict:210 if "shape_handling_dict" not in ori_dict:
213 ori_dict["shape_handling_dict"] = None211 ori_dict["shape_handling_dict"] = None
214- self._config["shape_handling_dict"] = make_config_entry(212+ self._config["shape_handling_dict"] = _ConfigEntry(
215 Config(default=None, value_type=dict),213 Config(default=None, value_type=dict),
216 name="shape_handling_dict",214 name="shape_handling_dict",
217 )215 )
@@ -12,7 +12,6 @@
12#include <torch/csrc/Export.h>12#include <torch/csrc/Export.h>
13 13 
14#include <c10/core/SymIntArrayRef.h>14#include <c10/core/SymIntArrayRef.h>
15-#include <torch_npu/csrc/_compat/autograd.h>
16 15 
17using namespace torch::autograd;16using namespace torch::autograd;
18 17 
@@ -28,7 +27,7 @@ using at::ScalarType;
28using c10::optional;27using c10::optional;
29using c10::fmap;28using c10::fmap;
30 29 
31-inline std::vector<Tensor> unpack_list(at::ArrayRef<SavedVariable> xs, torch_npu::compat::SavedForPtr saved_for = nullptr)30+inline std::vector<Tensor> unpack_list(at::ArrayRef<SavedVariable> xs, c10::intrusive_ptr<Node> saved_for = nullptr)
32{31{
33 // NB: we must explicitly do the conversion in the lambda, otherwise template32 // NB: we must explicitly do the conversion in the lambda, otherwise template
34 // deduction will give a Tensor of Variable which is not convertible33 // deduction will give a Tensor of Variable which is not convertible
@@ -37,7 +36,7 @@ inline std::vector<Tensor> unpack_list(at::ArrayRef<SavedVariable> xs, torch_npu
37 });36 });
38}37}
39 38 
40-inline c10::List<c10::optional<Tensor>> unpack_opt_list(at::ArrayRef<SavedVariable> xs, torch_npu::compat::SavedForPtr saved_for = nullptr)39+inline c10::List<c10::optional<Tensor>> unpack_opt_list(at::ArrayRef<SavedVariable> xs, c10::intrusive_ptr<Node> saved_for = nullptr)
41{40{
42 torch::List<c10::optional<Tensor>> result;41 torch::List<c10::optional<Tensor>> result;
43 result.reserve(xs.size());42 result.reserve(xs.size());