对自定义算子添加record func

This commit is contained in:
shibo19
2022-04-28 19:18:02 +08:00
parent a2f2b15f9b
commit 5e93ed8d85
2 changed files with 15 additions and 0 deletions
+11
View File
@@ -981,6 +981,17 @@ def dispatch_lambda_return_str(f: NativeFunction) -> str:
raise RuntimeError(f'{f.func.name} returns unsupported type {return_str}')
return return_str
def cpp_record_func(f: NativeFunction, custom=False) -> str:
name = cpp.name(f.func)
if Variant.function in f.variants:
if custom:
record_func = f'RECORD_FUNCTION("{name}", std::vector<c10::IValue>({{}}));'
else:
record_func = f'// RECORD_FUNCTION("{name}")'
return record_func
raise RuntimeError(f'could not dispatch, neither function nor method: {f.func}')
def cpp_dispatch_target(f: NativeFunction, custom=False) -> str:
name = cpp.name(f.func)
if Variant.method in f.variants and not custom: