From b8cef83386af748233759534f559fa046d424fdf Mon Sep 17 00:00:00 2001 From: xiao-daipeng Date: Mon, 27 Jun 2022 19:59:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=AE=97=E5=AD=90uniqueconse?= =?UTF-8?q?cutive=E9=80=82=E9=85=8DV2,=E5=8C=85=E8=A3=B9V2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- third_party/acl/inc/acl/acl_op_compiler.h | 6 ------ third_party/acl/libs/acl_op_compiler.cpp | 16 -------------- torch_npu/csrc/framework/OpParamMaker.cpp | 2 +- .../interface/AclOpCompileInterface.cpp | 21 +++++++++++++++++++ .../interface/AclOpCompileInterface.h | 6 ++++++ 5 files changed, 28 insertions(+), 23 deletions(-) diff --git a/third_party/acl/inc/acl/acl_op_compiler.h b/third_party/acl/inc/acl/acl_op_compiler.h index 338ec40e4c..0807efbd8e 100644 --- a/third_party/acl/inc/acl/acl_op_compiler.h +++ b/third_party/acl/inc/acl/acl_op_compiler.h @@ -93,12 +93,6 @@ ACL_FUNC_VISIBILITY aclError aclopCompileAndExecute(const char *opType, const aclopAttr *attr, aclopEngineType engineType, aclopCompileType compileFlag, const char *opPath, aclrtStream stream); -ACL_FUNC_VISIBILITY aclError aclopCompileAndExecuteV2(const char *opType, - int numInputs, aclTensorDesc *inputDesc[], aclDataBuffer *inputs[], - int numOutputs, aclTensorDesc *outputDesc[], aclDataBuffer *outputs[], - aclopAttr *attr, aclopEngineType engineType, aclopCompileType compileFlag, - const char *opPath, aclrtStream stream); - /** * @ingroup AscendCL * @brief set compile option diff --git a/third_party/acl/libs/acl_op_compiler.cpp b/third_party/acl/libs/acl_op_compiler.cpp index aaa4886cd7..ea5feee968 100644 --- a/third_party/acl/libs/acl_op_compiler.cpp +++ b/third_party/acl/libs/acl_op_compiler.cpp @@ -43,22 +43,6 @@ aclError aclopCompileAndExecute( return 0; } -aclError aclopCompileAndExecuteV2( - const char* opType, - int numInputs, - aclTensorDesc *inputDesc[], - aclDataBuffer *inputs[], - int numOutputs, - aclTensorDesc *outputDesc[], - aclDataBuffer *outputs[], - aclopAttr* attr, - aclopEngineType engineType, - aclopCompileType compileFlag, - const char* opPath, - aclrtStream stream) { - return 0; -} - void GeGeneratorFinalize() { return; } diff --git a/torch_npu/csrc/framework/OpParamMaker.cpp b/torch_npu/csrc/framework/OpParamMaker.cpp index 710b6d0508..b573ba30e4 100644 --- a/torch_npu/csrc/framework/OpParamMaker.cpp +++ b/torch_npu/csrc/framework/OpParamMaker.cpp @@ -177,7 +177,7 @@ namespace at_npu stream); } else { int64_t dimSize; - ret = aclopCompileAndExecuteV2( + ret = at_npu::native::AclopCompileAndExecuteV2( name.c_str(), inputSize, const_cast(params.inDesc.data()), diff --git a/torch_npu/csrc/framework/interface/AclOpCompileInterface.cpp b/torch_npu/csrc/framework/interface/AclOpCompileInterface.cpp index dd464b3a68..0c1b7f1d44 100644 --- a/torch_npu/csrc/framework/interface/AclOpCompileInterface.cpp +++ b/torch_npu/csrc/framework/interface/AclOpCompileInterface.cpp @@ -33,6 +33,7 @@ namespace at_npu REGISTER_LIBRARY(libacl_op_compiler) LOAD_FUNCTION(aclopSetCompileFlag) LOAD_FUNCTION(aclGenGraphAndDumpForOp) + LOAD_FUNCTION(aclopCompileAndExecuteV2) LOAD_FUNCTION(aclCreateGraphDumpOpt) LOAD_FUNCTION(aclDestroyGraphDumpOpt) @@ -67,6 +68,26 @@ aclError AclGenGraphAndDumpForOp(const char *opType, return ret; } +aclError AclopCompileAndExecuteV2(const char *opType, + int numInputs, aclTensorDesc *inputDesc[], aclDataBuffer *inputs[], + int numOutputs, aclTensorDesc *outputDesc[], aclDataBuffer *outputs[], + aclopAttr *attr, aclopEngineType engineType, aclopCompileType compileFlag, + const char *opPath, aclrtStream stream) { + typedef aclError(*AclopCompileAndExecuteV2Func)(const char *, + int, aclTensorDesc * [], aclDataBuffer * [], + int, aclTensorDesc * [], aclDataBuffer * [], + aclopAttr *, aclopEngineType, aclopCompileType, + const char *, aclrtStream); + static AclopCompileAndExecuteV2Func func = nullptr; + if (func == nullptr) { + func = (AclopCompileAndExecuteV2Func)GET_FUNC(aclGenGraphAndDumpForOp); + } + TORCH_CHECK(func, "Failed to find function ", "aclGenGraphAndDumpForOp"); + auto ret = func(opType, numInputs, inputDesc, inputs, numOutputs, + outputDesc, outputs, attr, engineType, compileFlag, opPath, stream); + return ret; +} + aclGraphDumpOption* AclCreateGraphDumpOpt() { typedef aclGraphDumpOption*(*AclCreateGraphDumpOptFunc)(); static AclCreateGraphDumpOptFunc func = nullptr; diff --git a/torch_npu/csrc/framework/interface/AclOpCompileInterface.h b/torch_npu/csrc/framework/interface/AclOpCompileInterface.h index f59f7fe841..911a8b5578 100644 --- a/torch_npu/csrc/framework/interface/AclOpCompileInterface.h +++ b/torch_npu/csrc/framework/interface/AclOpCompileInterface.h @@ -58,6 +58,12 @@ aclError AclGenGraphAndDumpForOp(const char *opType, const aclopAttr *attr, aclopEngineType engineType, const char *graphDumpPath, aclGraphDumpOption* graphdumpOpt); +aclError AclopCompileAndExecuteV2(const char *opType, + int numInputs, aclTensorDesc *inputDesc[], aclDataBuffer *inputs[], + int numOutputs, aclTensorDesc *outputDesc[], aclDataBuffer *outputs[], + aclopAttr *attr, aclopEngineType engineType, aclopCompileType compileFlag, + const char *opPath, aclrtStream stream); + /** * @brief create the dump option for AclGenGraphAndDumpForOp API, used for AOE * @retval created aclGraphDumpOption -- Gitee