From e8382c6187f3bb9c211bca227d22fa86dd04528b Mon Sep 17 00:00:00 2001 From: tanghuikang Date: Mon, 22 Mar 2021 21:03:58 +0800 Subject: [PATCH] Ingnore transpose with nop_op attr in pynative infer --- mindspore/ccsrc/runtime/device/kernel_runtime.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mindspore/ccsrc/runtime/device/kernel_runtime.cc b/mindspore/ccsrc/runtime/device/kernel_runtime.cc index 02b1e0beb45..9aecae33e74 100644 --- a/mindspore/ccsrc/runtime/device/kernel_runtime.cc +++ b/mindspore/ccsrc/runtime/device/kernel_runtime.cc @@ -946,6 +946,19 @@ bool KernelRuntime::LaunchKernelMod(const session::KernelGraph &graph) { auto &kernel = kernels[i]; auto kernel_mod = AnfAlgo::GetKernelMod(kernel); MS_EXCEPTION_IF_NULL(kernel_mod); + + // Skip transpose kernel with "nop_op" attr which is not hidden or removed in PyNative infer scenario. Transpose + // kernel, which is not supposed to be executed, is generated in TransDataSplit to support specific Transdata. And + // hard code here should be removed after new Transdata programme is implemented in the foreseeable future. + if (AnfAlgo::HasNodeAttr("nop_op", kernel)) { + for (size_t idx = 0; idx < AnfAlgo::GetOutputTensorNum(kernel); idx += 1) { + auto real_input = AnfAlgo::GetRealInputIndex(kernel, idx); + auto device_address = AnfAlgo::GetPrevNodeMutableOutputAddr(kernel, real_input); + AnfAlgo::SetOutputAddr(device_address, idx, kernel.get()); + } + continue; + } + AddressPtrList kernel_inputs; AddressPtrList kernel_workspaces; AddressPtrList kernel_outputs;