Modify codegen & add cpp file for autograd

This commit is contained in:
刘嘉巍
2023-03-23 22:37:53 +08:00
parent 4d4c86e4fc
commit dec4263ecd
10 changed files with 385 additions and 6 deletions
+5 -2
View File
@@ -992,13 +992,16 @@ def cpp_record_func(f: NativeFunction, custom=False) -> str:
return record_func
raise RuntimeError(f'could not dispatch, neither function nor method: {f.func}')
def cpp_dispatch_target(f: NativeFunction, custom=False) -> str:
def cpp_dispatch_target(f: NativeFunction, custom=False, is_npu_autograd=False) -> str:
name = cpp.name(f.func)
if Variant.method in f.variants and not custom:
return f'self.{name}'
if Variant.function in f.variants:
if custom:
namespace = 'at_npu::native::NPUNativeFunctions'
if is_npu_autograd:
namespace = 'at_npu::autograd::VariableType'
else:
namespace = 'at_npu::native::NPUNativeFunctions'
elif has_tensor_options(f) or f.func.name.name.base.endswith('_like'):
namespace = 'torch'
else: