diff --git a/mindspore/ccsrc/kernel/CMakeLists.txt b/mindspore/ccsrc/kernel/CMakeLists.txt index f3ac99283a2d9225b5ef87c17eb7e64369c3d1c9..a3a5077a1a79ec7ffc31c088f6d445913b8198af 100644 --- a/mindspore/ccsrc/kernel/CMakeLists.txt +++ b/mindspore/ccsrc/kernel/CMakeLists.txt @@ -17,6 +17,12 @@ if (ENABLE_D) add_compile_definitions(ENABLE_D) endif () +if (ENABLE_CPU) + file(GLOB_RECURSE CPU_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + "cpu/*.cc" + ) +endif () + if (ENABLE_GPU) file(GLOB_RECURSE CUDA_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "gpu/*.cu" @@ -37,4 +43,4 @@ if (ENABLE_GPU) # add_library(_mindspore_kernel_cuda_obj OBJECT ${CUDA_SRC_LIST}) endif() -add_library(_mindspore_kernel_obj OBJECT ${KERNEL_SRC_LIST} ${GPU_SRC_LIST} ${D_SRC_LIST}) +add_library(_mindspore_kernel_obj OBJECT ${KERNEL_SRC_LIST} ${CPU_SRC_LIST} ${GPU_SRC_LIST} ${D_SRC_LIST}) diff --git a/mindspore/ccsrc/device/cpu/kernel/apply_momentum_cpu_kernel.cc b/mindspore/ccsrc/kernel/cpu/apply_momentum_cpu_kernel.cc similarity index 90% rename from mindspore/ccsrc/device/cpu/kernel/apply_momentum_cpu_kernel.cc rename to mindspore/ccsrc/kernel/cpu/apply_momentum_cpu_kernel.cc index 94b6c306ef76c1688acc4f17e3bcb7721899c1c7..3cd6c5741398bb802d673b6ebe94073ebe7362cf 100644 --- a/mindspore/ccsrc/device/cpu/kernel/apply_momentum_cpu_kernel.cc +++ b/mindspore/ccsrc/kernel/cpu/apply_momentum_cpu_kernel.cc @@ -13,14 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "device/cpu/kernel/apply_momentum_cpu_kernel.h" -#include "device/cpu/kernel/mkldnn/mkl_kernel_engine.h" +#include "kernel/cpu/apply_momentum_cpu_kernel.h" +#include "kernel/cpu/mkldnn/mkl_kernel_engine.h" #include "device/cpu/cpu_device_address.h" #include "common/utils.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { void ApplyMomentumCPUKernel::InitKernel(const CNodePtr & /*kernel_node*/) {} bool ApplyMomentumCPUKernel::Launch(const std::vector &inputs, @@ -44,6 +43,5 @@ bool ApplyMomentumCPUKernel::Launch(const std::vector &input } return true; } -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/device/cpu/kernel/apply_momentum_cpu_kernel.h b/mindspore/ccsrc/kernel/cpu/apply_momentum_cpu_kernel.h similarity index 77% rename from mindspore/ccsrc/device/cpu/kernel/apply_momentum_cpu_kernel.h rename to mindspore/ccsrc/kernel/cpu/apply_momentum_cpu_kernel.h index 84ed340430940a0fe2ac629a179ad83ffc601598..91e159cf7431d67952e837e5e318389e64026509 100644 --- a/mindspore/ccsrc/device/cpu/kernel/apply_momentum_cpu_kernel.h +++ b/mindspore/ccsrc/kernel/cpu/apply_momentum_cpu_kernel.h @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MINDSPORE_CCSRC_DEVICE_CPU_APPLY_MOMENTUM_CPU_KERNEL_H_ -#define MINDSPORE_CCSRC_DEVICE_CPU_APPLY_MOMENTUM_CPU_KERNEL_H_ +#ifndef MINDSPORE_CCSRC_KERNEL_CPU_APPLY_MOMENTUM_CPU_KERNEL_H_ +#define MINDSPORE_CCSRC_KERNEL_CPU_APPLY_MOMENTUM_CPU_KERNEL_H_ #include #include -#include "device/cpu/kernel/mkldnn/mkl_cpu_kernel.h" +#include "kernel/cpu/mkldnn/mkl_cpu_kernel.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { class ApplyMomentumCPUKernel : public MKLCPUKernel { public: ApplyMomentumCPUKernel() = default; @@ -35,8 +34,7 @@ class ApplyMomentumCPUKernel : public MKLCPUKernel { }; MS_REG_CPU_KERNEL(ApplyMomentum, ApplyMomentumCPUKernel); -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore -#endif // MINDSPORE_CCSRC_DEVICE_CPU_APPLY_MOMENTUM_CPU_KERNEL_H_ +#endif // MINDSPORE_CCSRC_KERNEL_CPU_APPLY_MOMENTUM_CPU_KERNEL_H_ diff --git a/mindspore/ccsrc/device/cpu/kernel/argmax_cpu_kernel.cc b/mindspore/ccsrc/kernel/cpu/argmax_cpu_kernel.cc similarity index 94% rename from mindspore/ccsrc/device/cpu/kernel/argmax_cpu_kernel.cc rename to mindspore/ccsrc/kernel/cpu/argmax_cpu_kernel.cc index a492bf79696f053f1c4640cbdbe08c3ef757d509..ee328df7218f6c10e16041dd92fa0dcbec2303c3 100644 --- a/mindspore/ccsrc/device/cpu/kernel/argmax_cpu_kernel.cc +++ b/mindspore/ccsrc/kernel/cpu/argmax_cpu_kernel.cc @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "device/cpu/kernel/argmax_cpu_kernel.h" +#include "kernel/cpu/argmax_cpu_kernel.h" #include "device/cpu/cpu_device_address.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { void ArgmaxCPUKernel::InitKernel(const CNodePtr &kernel_node) { MS_EXCEPTION_IF_NULL(kernel_node); std::vector shape = AnfAlgo::GetInputDeviceShape(kernel_node, 0); @@ -64,6 +63,5 @@ bool ArgmaxCPUKernel::Launch(const std::vector &inputs, } return true; } -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/device/cpu/kernel/argmax_cpu_kernel.h b/mindspore/ccsrc/kernel/cpu/argmax_cpu_kernel.h similarity index 77% rename from mindspore/ccsrc/device/cpu/kernel/argmax_cpu_kernel.h rename to mindspore/ccsrc/kernel/cpu/argmax_cpu_kernel.h index 993b012c4e0f7defeaa53ca46af6e7073aa2238f..b50b5fc27276d8abd79abef13e11a51613f89495 100644 --- a/mindspore/ccsrc/device/cpu/kernel/argmax_cpu_kernel.h +++ b/mindspore/ccsrc/kernel/cpu/argmax_cpu_kernel.h @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MINDSPORE_CCSRC_DEVICE_CPU_ARGMAX_CPU_KERNEL_H_ -#define MINDSPORE_CCSRC_DEVICE_CPU_ARGMAX_CPU_KERNEL_H_ +#ifndef MINDSPORE_CCSRC_KERNEL_CPU_ARGMAX_CPU_KERNEL_H_ +#define MINDSPORE_CCSRC_KERNEL_CPU_ARGMAX_CPU_KERNEL_H_ #include #include -#include "device/cpu/cpu_kernel.h" -#include "device/cpu/cpu_kernel_factory.h" +#include "kernel/cpu/cpu_kernel.h" +#include "kernel/cpu/cpu_kernel_factory.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { class ArgmaxCPUKernel : public CPUKernel { public: ArgmaxCPUKernel() = default; @@ -39,8 +38,7 @@ class ArgmaxCPUKernel : public CPUKernel { }; MS_REG_CPU_KERNEL(Argmax, ArgmaxCPUKernel); -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore -#endif // MINDSPORE_CCSRC_DEVICE_CPU_ARGMAX_CPU_KERNEL_H_ +#endif // MINDSPORE_CCSRC_KERNEL_CPU_ARGMAX_CPU_KERNEL_H_ diff --git a/mindspore/ccsrc/device/cpu/kernel/bias_add_cpu_kernel.cc b/mindspore/ccsrc/kernel/cpu/bias_add_cpu_kernel.cc similarity index 91% rename from mindspore/ccsrc/device/cpu/kernel/bias_add_cpu_kernel.cc rename to mindspore/ccsrc/kernel/cpu/bias_add_cpu_kernel.cc index 4661ee73cd1f30d9bdb6b0bc981132f0597cdb27..00f301723112d60a70ea1821601eee571d917452 100644 --- a/mindspore/ccsrc/device/cpu/kernel/bias_add_cpu_kernel.cc +++ b/mindspore/ccsrc/kernel/cpu/bias_add_cpu_kernel.cc @@ -14,12 +14,11 @@ * limitations under the License. */ -#include "device/cpu/kernel/bias_add_cpu_kernel.h" +#include "kernel/cpu/bias_add_cpu_kernel.h" namespace mindspore { -namespace device { -namespace cpu { -void BiasAddCpuKernel::InitKernel(const CNodePtr &kernel_node) { +namespace kernel { +void BiasAddCPUKernel::InitKernel(const CNodePtr &kernel_node) { MS_EXCEPTION_IF_NULL(kernel_node); input_shape_ = AnfAlgo::GetInputDeviceShape(kernel_node, 0); bias_shape_ = AnfAlgo::GetInputDeviceShape(kernel_node, 1); @@ -41,7 +40,7 @@ void BiasAddCpuKernel::InitKernel(const CNodePtr &kernel_node) { } } -bool BiasAddCpuKernel::Launch(const std::vector &inputs, const std::vector & /*workspace*/, +bool BiasAddCPUKernel::Launch(const std::vector &inputs, const std::vector & /*workspace*/, const std::vector &outputs) { if (inputs.size() != 2 || outputs.size() != 1) { MS_LOG(EXCEPTION) << "inputs outputs size not supoort"; @@ -79,6 +78,5 @@ bool BiasAddCpuKernel::Launch(const std::vector &inputs, const std:: } return true; } -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/device/cpu/kernel/bias_add_cpu_kernel.h b/mindspore/ccsrc/kernel/cpu/bias_add_cpu_kernel.h similarity index 65% rename from mindspore/ccsrc/device/cpu/kernel/bias_add_cpu_kernel.h rename to mindspore/ccsrc/kernel/cpu/bias_add_cpu_kernel.h index 45028523bd74c45fec615246acee4d80ce55cb2d..9c1a23b4e1216f3f228fedc94c512f1704378243 100644 --- a/mindspore/ccsrc/device/cpu/kernel/bias_add_cpu_kernel.h +++ b/mindspore/ccsrc/kernel/cpu/bias_add_cpu_kernel.h @@ -13,21 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MINDSPORE_MINDSPORE_CCSRC_DEVICE_CPU_KERNEL_BIAS_ADD_CPU_KERNEL_H_ -#define MINDSPORE_MINDSPORE_CCSRC_DEVICE_CPU_KERNEL_BIAS_ADD_CPU_KERNEL_H_ +#ifndef MINDSPORE_MINDSPORE_CCSRC_KERNEL_CPU_BIAS_ADD_CPU_KERNEL_H_ +#define MINDSPORE_MINDSPORE_CCSRC_KERNEL_CPU_BIAS_ADD_CPU_KERNEL_H_ #include #include -#include "device/cpu/cpu_kernel.h" -#include "device/cpu/cpu_kernel_factory.h" +#include "kernel/cpu/cpu_kernel.h" +#include "kernel/cpu/cpu_kernel_factory.h" namespace mindspore { -namespace device { -namespace cpu { -class BiasAddCpuKernel : public CPUKernel { +namespace kernel { +class BiasAddCPUKernel : public CPUKernel { public: - BiasAddCpuKernel() = default; - ~BiasAddCpuKernel() override = default; + BiasAddCPUKernel() = default; + ~BiasAddCPUKernel() override = default; void InitKernel(const CNodePtr &kernel_node) override; bool Launch(const std::vector &inputs, const std::vector &workspace, @@ -38,8 +37,7 @@ class BiasAddCpuKernel : public CPUKernel { std::vector input_shape_; std::vector bias_shape_; }; -MS_REG_CPU_KERNEL(BiasAdd, BiasAddCpuKernel); -} // namespace cpu -} // namespace device +MS_REG_CPU_KERNEL(BiasAdd, BiasAddCPUKernel); +} // namespace kernel } // namespace mindspore -#endif // MINDSPORE_MINDSPORE_CCSRC_DEVICE_CPU_KERNEL_BIAS_ADD_CPU_KERNEL_H_ +#endif // MINDSPORE_MINDSPORE_CCSRC_KERNEL_CPU_BIAS_ADD_CPU_KERNEL_H_ diff --git a/mindspore/ccsrc/device/cpu/kernel/bias_add_grad_cpu_kernel.cc b/mindspore/ccsrc/kernel/cpu/bias_add_grad_cpu_kernel.cc similarity index 89% rename from mindspore/ccsrc/device/cpu/kernel/bias_add_grad_cpu_kernel.cc rename to mindspore/ccsrc/kernel/cpu/bias_add_grad_cpu_kernel.cc index 6846ca2555ae9e320e5e7796b41b971c23578611..1d9c7d076ee6613629bd80d7b5667bac142b9eee 100644 --- a/mindspore/ccsrc/device/cpu/kernel/bias_add_grad_cpu_kernel.cc +++ b/mindspore/ccsrc/kernel/cpu/bias_add_grad_cpu_kernel.cc @@ -14,12 +14,11 @@ * limitations under the License. */ -#include "device/cpu/kernel/bias_add_grad_cpu_kernel.h" +#include "kernel/cpu/bias_add_grad_cpu_kernel.h" namespace mindspore { -namespace device { -namespace cpu { -void BiasAddGradCpuKernel::InitKernel(const CNodePtr &kernel_node) { +namespace kernel { +void BiasAddGradCPUKernel::InitKernel(const CNodePtr &kernel_node) { MS_EXCEPTION_IF_NULL(kernel_node); input_shape_ = AnfAlgo::GetInputDeviceShape(kernel_node, 0); if (input_shape_.size() != 4 && input_shape_.size() != 2) { @@ -27,7 +26,7 @@ void BiasAddGradCpuKernel::InitKernel(const CNodePtr &kernel_node) { } } -bool BiasAddGradCpuKernel::Launch(const std::vector &inputs, const std::vector & /*workspace*/, +bool BiasAddGradCPUKernel::Launch(const std::vector &inputs, const std::vector & /*workspace*/, const std::vector &outputs) { if (inputs.size() != 1 || outputs.size() != 1) { MS_LOG(EXCEPTION) << "input output size not support"; @@ -65,6 +64,5 @@ bool BiasAddGradCpuKernel::Launch(const std::vector &inputs, const s } return true; } -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/device/cpu/kernel/bias_add_grad_cpu_kernel.h b/mindspore/ccsrc/kernel/cpu/bias_add_grad_cpu_kernel.h similarity index 62% rename from mindspore/ccsrc/device/cpu/kernel/bias_add_grad_cpu_kernel.h rename to mindspore/ccsrc/kernel/cpu/bias_add_grad_cpu_kernel.h index 736540b8a3617d72d0665702f15c7ae4f3631127..3c4d6e9a7689a807a10d5fdfcb30f1ace5454dd0 100644 --- a/mindspore/ccsrc/device/cpu/kernel/bias_add_grad_cpu_kernel.h +++ b/mindspore/ccsrc/kernel/cpu/bias_add_grad_cpu_kernel.h @@ -14,21 +14,20 @@ * limitations under the License. */ -#ifndef MINDSPORE_MINDSPORE_CCSRC_DEVICE_CPU_KERNEL_BIASADDGRADCPUKERNEL_H_ -#define MINDSPORE_MINDSPORE_CCSRC_DEVICE_CPU_KERNEL_BIASADDGRADCPUKERNEL_H_ +#ifndef MINDSPORE_MINDSPORE_CCSRC_KERNEL_CPU_BIASADDGRADCPUKERNEL_H_ +#define MINDSPORE_MINDSPORE_CCSRC_KERNEL_CPU_BIASADDGRADCPUKERNEL_H_ #include #include -#include "device/cpu/cpu_kernel.h" -#include "device/cpu/cpu_kernel_factory.h" +#include "kernel/cpu/cpu_kernel.h" +#include "kernel/cpu/cpu_kernel_factory.h" namespace mindspore { -namespace device { -namespace cpu { -class BiasAddGradCpuKernel : public CPUKernel { +namespace kernel { +class BiasAddGradCPUKernel : public CPUKernel { public: - BiasAddGradCpuKernel() = default; - ~BiasAddGradCpuKernel() override = default; + BiasAddGradCPUKernel() = default; + ~BiasAddGradCPUKernel() override = default; void InitKernel(const CNodePtr &kernel_node) override; bool Launch(const std::vector &inputs, const std::vector &workspace, @@ -37,8 +36,7 @@ class BiasAddGradCpuKernel : public CPUKernel { private: std::vector input_shape_; }; -MS_REG_CPU_KERNEL(BiasAddGrad, BiasAddGradCpuKernel); -} // namespace cpu -} // namespace device +MS_REG_CPU_KERNEL(BiasAddGrad, BiasAddGradCPUKernel); +} // namespace kernel } // namespace mindspore -#endif // MINDSPORE_MINDSPORE_CCSRC_DEVICE_CPU_KERNEL_BIASADDGRADCPUKERNEL_H_ +#endif // MINDSPORE_MINDSPORE_CCSRC_KERNEL_CPU_BIASADDGRADCPUKERNEL_H_ diff --git a/mindspore/ccsrc/device/cpu/cpu_kernel.cc b/mindspore/ccsrc/kernel/cpu/cpu_kernel.cc similarity index 91% rename from mindspore/ccsrc/device/cpu/cpu_kernel.cc rename to mindspore/ccsrc/kernel/cpu/cpu_kernel.cc index 5f810ff522b7a8d3d1b65be969d449a8110527ce..7150c06eb5a1dec3a057e281a49108584e0f0211 100644 --- a/mindspore/ccsrc/device/cpu/cpu_kernel.cc +++ b/mindspore/ccsrc/kernel/cpu/cpu_kernel.cc @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "device/cpu/cpu_kernel.h" +#include "kernel/cpu/cpu_kernel.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { void CPUKernel::InitInputOutputSize(const CNodePtr &kernel_node) { MS_EXCEPTION_IF_NULL(kernel_node); size_t input_num = AnfAlgo::GetInputTensorNum(kernel_node); @@ -41,6 +40,5 @@ void CPUKernel::Init(const CNodePtr &kernel_node) { InitInputOutputSize(kernel_node); InitKernel(kernel_node); } -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/device/cpu/cpu_kernel.h b/mindspore/ccsrc/kernel/cpu/cpu_kernel.h similarity index 89% rename from mindspore/ccsrc/device/cpu/cpu_kernel.h rename to mindspore/ccsrc/kernel/cpu/cpu_kernel.h index ebd182ee4926aa92936c0312108b146174849350..f9121cb175eed0f4cf67967a0a8649415368b655 100644 --- a/mindspore/ccsrc/device/cpu/cpu_kernel.h +++ b/mindspore/ccsrc/kernel/cpu/cpu_kernel.h @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MINDSPORE_CCSRC_DEVICE_CPU_CPU_KERNEL_H_ -#define MINDSPORE_CCSRC_DEVICE_CPU_CPU_KERNEL_H_ +#ifndef MINDSPORE_CCSRC_KERNEL_CPU_CPU_KERNEL_H_ +#define MINDSPORE_CCSRC_KERNEL_CPU_CPU_KERNEL_H_ #include #include @@ -28,8 +28,7 @@ using mindspore::kernel::Address; using mindspore::kernel::AddressPtr; namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { const char KSIZE[] = "ksize"; const char STRIDE[] = "stride"; const char STRIDES[] = "strides"; @@ -70,8 +69,7 @@ class CPUKernel : public kernel::KernelMod { std::vector output_size_list_; std::vector workspace_size_list_; }; -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore -#endif // MINDSPORE_CCSRC_DEVICE_CPU_CPU_KERNEL_H_ +#endif // MINDSPORE_CCSRC_KERNEL_CPU_CPU_KERNEL_H_ diff --git a/mindspore/ccsrc/device/cpu/cpu_kernel_factory.cc b/mindspore/ccsrc/kernel/cpu/cpu_kernel_factory.cc similarity index 92% rename from mindspore/ccsrc/device/cpu/cpu_kernel_factory.cc rename to mindspore/ccsrc/kernel/cpu/cpu_kernel_factory.cc index 77a3345344474c016d895d3bbcd30545f6ffafbe..66949cb4fa8b5e64fe1c222d29116f4745812761 100644 --- a/mindspore/ccsrc/device/cpu/cpu_kernel_factory.cc +++ b/mindspore/ccsrc/kernel/cpu/cpu_kernel_factory.cc @@ -14,15 +14,14 @@ * limitations under the License. */ -#include "device/cpu/cpu_kernel_factory.h" +#include "kernel/cpu/cpu_kernel_factory.h" #include #include #include namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { CPUKernelFactory &CPUKernelFactory::Get() { static CPUKernelFactory instance; return instance; @@ -45,6 +44,5 @@ std::shared_ptr CPUKernelFactory::Create(const std::string &kernel_na } return nullptr; } -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/device/cpu/cpu_kernel_factory.h b/mindspore/ccsrc/kernel/cpu/cpu_kernel_factory.h similarity index 86% rename from mindspore/ccsrc/device/cpu/cpu_kernel_factory.h rename to mindspore/ccsrc/kernel/cpu/cpu_kernel_factory.h index 6a86f9470992580e2f422aca5da5032ee18a0f28..f546758632eaa233a7f1bb95b40a8c718bc6bab5 100644 --- a/mindspore/ccsrc/device/cpu/cpu_kernel_factory.h +++ b/mindspore/ccsrc/kernel/cpu/cpu_kernel_factory.h @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MINDSPORE_CCSRC_DEVICE_CPU_CPU_KERNEL_FACTORY_H_ -#define MINDSPORE_CCSRC_DEVICE_CPU_CPU_KERNEL_FACTORY_H_ +#ifndef MINDSPORE_CCSRC_KERNEL_CPU_CPU_KERNEL_FACTORY_H_ +#define MINDSPORE_CCSRC_KERNEL_CPU_CPU_KERNEL_FACTORY_H_ #include #include @@ -22,10 +22,9 @@ #include #include #include "common/utils.h" -#include "device/cpu/cpu_kernel.h" +#include "kernel/cpu/cpu_kernel.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { using CPUKernelCreator = std::function()>; class CPUKernelFactory { public: @@ -51,8 +50,7 @@ class CPUKernelRegistrar { #define MS_REG_CPU_KERNEL(KERNEL_NAME, KERNEL_CLASS) \ static const CPUKernelRegistrar g_cpu_kernel_##KERNEL_NAME##_reg(#KERNEL_NAME, \ []() { return std::make_shared(); }); -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore -#endif // MINDSPORE_CCSRC_DEVICE_CPU_CPU_KERNEL_FACTORY_H_ +#endif // MINDSPORE_CCSRC_KERNEL_CPU_CPU_KERNEL_FACTORY_H_ diff --git a/mindspore/ccsrc/device/cpu/kernel/equal_count_cpu_kernel.cc b/mindspore/ccsrc/kernel/cpu/equal_count_cpu_kernel.cc similarity index 92% rename from mindspore/ccsrc/device/cpu/kernel/equal_count_cpu_kernel.cc rename to mindspore/ccsrc/kernel/cpu/equal_count_cpu_kernel.cc index ee6bb9f144f041155b9e63dbcbafd95f683e69f4..60e7eafa789b04ad530a37eea3a1fd6789bfb54e 100644 --- a/mindspore/ccsrc/device/cpu/kernel/equal_count_cpu_kernel.cc +++ b/mindspore/ccsrc/kernel/cpu/equal_count_cpu_kernel.cc @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "device/cpu/kernel/equal_count_cpu_kernel.h" +#include "kernel/cpu/equal_count_cpu_kernel.h" #include "device/cpu/cpu_device_address.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { void EqualCountCPUKernel::InitKernel(const CNodePtr & /*kernel_node*/) {} bool EqualCountCPUKernel::Launch(const std::vector &inputs, @@ -43,6 +42,5 @@ bool EqualCountCPUKernel::Launch(const std::vector &inputs, output[0] = count; return true; } -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/device/cpu/kernel/equal_count_cpu_kernel.h b/mindspore/ccsrc/kernel/cpu/equal_count_cpu_kernel.h similarity index 76% rename from mindspore/ccsrc/device/cpu/kernel/equal_count_cpu_kernel.h rename to mindspore/ccsrc/kernel/cpu/equal_count_cpu_kernel.h index 26f343e855fd7266a2e3597102eacc80d58fb413..ecfe24a90fd99e377e3963c5a4b9ea02cb0c541a 100644 --- a/mindspore/ccsrc/device/cpu/kernel/equal_count_cpu_kernel.h +++ b/mindspore/ccsrc/kernel/cpu/equal_count_cpu_kernel.h @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MINDSPORE_CCSRC_DEVICE_CPU_EQUAL_COUNT_CPU_KERNEL_H_ -#define MINDSPORE_CCSRC_DEVICE_CPU_EQUAL_COUNT_CPU_KERNEL_H_ +#ifndef MINDSPORE_CCSRC_KERNEL_CPU_EQUAL_COUNT_CPU_KERNEL_H_ +#define MINDSPORE_CCSRC_KERNEL_CPU_EQUAL_COUNT_CPU_KERNEL_H_ #include #include -#include "device/cpu/cpu_kernel.h" -#include "device/cpu/cpu_kernel_factory.h" +#include "kernel/cpu/cpu_kernel.h" +#include "kernel/cpu/cpu_kernel_factory.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { class EqualCountCPUKernel : public CPUKernel { public: EqualCountCPUKernel() = default; @@ -35,8 +34,7 @@ class EqualCountCPUKernel : public CPUKernel { }; MS_REG_CPU_KERNEL(EqualCount, EqualCountCPUKernel); -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore -#endif // MINDSPORE_CCSRC_DEVICE_CPU_EQUAL_COUNT_CPU_KERNEL_H_ +#endif // MINDSPORE_CCSRC_KERNEL_CPU_EQUAL_COUNT_CPU_KERNEL_H_ diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/conv2d_cpu_kernel.cc b/mindspore/ccsrc/kernel/cpu/mkldnn/conv2d_cpu_kernel.cc similarity index 95% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/conv2d_cpu_kernel.cc rename to mindspore/ccsrc/kernel/cpu/mkldnn/conv2d_cpu_kernel.cc index 5d63aee6cd23b920bed0eeb20a0a3c44e0c583dd..657c85dc4845d72c84b771554ff70511d532f798 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/conv2d_cpu_kernel.cc +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/conv2d_cpu_kernel.cc @@ -13,15 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "device/cpu/kernel/mkldnn/conv2d_cpu_kernel.h" +#include "kernel/cpu/mkldnn/conv2d_cpu_kernel.h" #include #include "common/utils.h" -#include "device/cpu/kernel/mkldnn/mkl_kernel_engine.h" +#include "kernel/cpu/mkldnn/mkl_kernel_engine.h" #include "device/cpu/cpu_device_address.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { void Conv2dCPUKernel::InitKernel(const CNodePtr &kernel_node) { MS_EXCEPTION_IF_NULL(kernel_node); std::vector src_shape = AnfAlgo::GetInputDeviceShape(kernel_node, 0); @@ -88,6 +87,5 @@ bool Conv2dCPUKernel::Launch(const std::vector &inputs, ExecutePrimitive(); return true; } -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/conv2d_cpu_kernel.h b/mindspore/ccsrc/kernel/cpu/mkldnn/conv2d_cpu_kernel.h similarity index 78% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/conv2d_cpu_kernel.h rename to mindspore/ccsrc/kernel/cpu/mkldnn/conv2d_cpu_kernel.h index d975b537ca6f6e488ae641a56a797a75e61dfef2..b91059a0d117c4d183470a3400a1fc923eb73113 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/conv2d_cpu_kernel.h +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/conv2d_cpu_kernel.h @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MINDSPORE_CCSRC_DEVICE_CPU_CONV2D_CPU_KERNEL_H_ -#define MINDSPORE_CCSRC_DEVICE_CPU_CONV2D_CPU_KERNEL_H_ +#ifndef MINDSPORE_CCSRC_KERNEL_CPU_CONV2D_CPU_KERNEL_H_ +#define MINDSPORE_CCSRC_KERNEL_CPU_CONV2D_CPU_KERNEL_H_ #include #include -#include "device/cpu/kernel/mkldnn/mkl_cpu_kernel.h" +#include "kernel/cpu/mkldnn/mkl_cpu_kernel.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { class Conv2dCPUKernel : public MKLCPUKernel { public: Conv2dCPUKernel() = default; @@ -35,8 +34,7 @@ class Conv2dCPUKernel : public MKLCPUKernel { }; MS_REG_CPU_KERNEL(Conv2D, Conv2dCPUKernel); -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore -#endif // MINDSPORE_CCSRC_DEVICE_CPU_CONV2D_CPU_KERNEL_H_ +#endif // MINDSPORE_CCSRC_KERNEL_CPU_CONV2D_CPU_KERNEL_H_ diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/conv2d_grad_filter_cpu_kernel.cc b/mindspore/ccsrc/kernel/cpu/mkldnn/conv2d_grad_filter_cpu_kernel.cc similarity index 95% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/conv2d_grad_filter_cpu_kernel.cc rename to mindspore/ccsrc/kernel/cpu/mkldnn/conv2d_grad_filter_cpu_kernel.cc index 1a7c10a531aaf2e51cf434fb06baf9450f8efe91..fbfebaf56eed6efc49a7e1aec5fa729078c544b6 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/conv2d_grad_filter_cpu_kernel.cc +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/conv2d_grad_filter_cpu_kernel.cc @@ -13,15 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "device/cpu/kernel/mkldnn/conv2d_grad_filter_cpu_kernel.h" +#include "kernel/cpu/mkldnn/conv2d_grad_filter_cpu_kernel.h" #include #include "common/utils.h" -#include "device/cpu/kernel/mkldnn/mkl_kernel_engine.h" +#include "kernel/cpu/mkldnn/mkl_kernel_engine.h" #include "device/cpu/cpu_device_address.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { void Conv2dGradFilterCPUKernel::InitKernel(const CNodePtr &kernel_node) { MS_EXCEPTION_IF_NULL(kernel_node); std::vector src_shape = AnfAlgo::GetInputDeviceShape(kernel_node, 1); @@ -90,6 +89,5 @@ bool Conv2dGradFilterCPUKernel::Launch(const std::vector &in ExecutePrimitive(); return true; } -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/conv2d_grad_filter_cpu_kernel.h b/mindspore/ccsrc/kernel/cpu/mkldnn/conv2d_grad_filter_cpu_kernel.h similarity index 78% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/conv2d_grad_filter_cpu_kernel.h rename to mindspore/ccsrc/kernel/cpu/mkldnn/conv2d_grad_filter_cpu_kernel.h index d42c1166f25f789217519dcb3e5b04ae93880b1a..b6cd78171a21aa7e1ebea11788845817c380f1ed 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/conv2d_grad_filter_cpu_kernel.h +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/conv2d_grad_filter_cpu_kernel.h @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MINDSPORE_CCSRC_DEVICE_CPU_CONV2D_GRAD_FILTER_CPU_KERNEL_H_ -#define MINDSPORE_CCSRC_DEVICE_CPU_CONV2D_GRAD_FILTER_CPU_KERNEL_H_ +#ifndef MINDSPORE_CCSRC_KERNEL_CPU_CONV2D_GRAD_FILTER_CPU_KERNEL_H_ +#define MINDSPORE_CCSRC_KERNEL_CPU_CONV2D_GRAD_FILTER_CPU_KERNEL_H_ #include #include -#include "device/cpu/kernel/mkldnn/mkl_cpu_kernel.h" +#include "kernel/cpu/mkldnn/mkl_cpu_kernel.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { class Conv2dGradFilterCPUKernel : public MKLCPUKernel { public: Conv2dGradFilterCPUKernel() = default; @@ -35,8 +34,7 @@ class Conv2dGradFilterCPUKernel : public MKLCPUKernel { }; MS_REG_CPU_KERNEL(Conv2DBackpropFilter, Conv2dGradFilterCPUKernel); -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore -#endif // MINDSPORE_CCSRC_DEVICE_CPU_CONV2D_GRAD_FILTER_CPU_KERNEL_H_ +#endif // MINDSPORE_CCSRC_KERNEL_CPU_CONV2D_GRAD_FILTER_CPU_KERNEL_H_ diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/conv2d_grad_input_cpu_kernel.cc b/mindspore/ccsrc/kernel/cpu/mkldnn/conv2d_grad_input_cpu_kernel.cc similarity index 95% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/conv2d_grad_input_cpu_kernel.cc rename to mindspore/ccsrc/kernel/cpu/mkldnn/conv2d_grad_input_cpu_kernel.cc index 04dda20acdaf72153e562b49059fb5de4db74658..ff0b8633d4cae5397f3618c9cfdc207aef9bf09d 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/conv2d_grad_input_cpu_kernel.cc +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/conv2d_grad_input_cpu_kernel.cc @@ -13,15 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "device/cpu/kernel/mkldnn/conv2d_grad_input_cpu_kernel.h" +#include "kernel/cpu/mkldnn/conv2d_grad_input_cpu_kernel.h" #include -#include "device/cpu/kernel/mkldnn/mkl_kernel_engine.h" +#include "kernel/cpu/mkldnn/mkl_kernel_engine.h" #include "device/cpu/cpu_device_address.h" #include "common/utils.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { void Conv2dGradInputCPUKernel::InitKernel(const CNodePtr &kernel_node) { MS_EXCEPTION_IF_NULL(kernel_node); std::vector src_shape = AnfAlgo::GetOutputDeviceShape(kernel_node, 0); @@ -89,6 +88,5 @@ bool Conv2dGradInputCPUKernel::Launch(const std::vector &inp ExecutePrimitive(); return true; } -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/conv2d_grad_input_cpu_kernel.h b/mindspore/ccsrc/kernel/cpu/mkldnn/conv2d_grad_input_cpu_kernel.h similarity index 78% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/conv2d_grad_input_cpu_kernel.h rename to mindspore/ccsrc/kernel/cpu/mkldnn/conv2d_grad_input_cpu_kernel.h index fb6e14688db2b4fd05fe1e04d9e0136d59576fd7..c61d8133ee0bd7432ef76be18fd82cd4442883cb 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/conv2d_grad_input_cpu_kernel.h +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/conv2d_grad_input_cpu_kernel.h @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MINDSPORE_CCSRC_DEVICE_CPU_CONV2D_GRAD_INPUT_CPU_KERNEL_H_ -#define MINDSPORE_CCSRC_DEVICE_CPU_CONV2D_GRAD_INPUT_CPU_KERNEL_H_ +#ifndef MINDSPORE_CCSRC_KERNEL_CPU_CONV2D_GRAD_INPUT_CPU_KERNEL_H_ +#define MINDSPORE_CCSRC_KERNEL_CPU_CONV2D_GRAD_INPUT_CPU_KERNEL_H_ #include #include -#include "device/cpu/kernel/mkldnn/mkl_cpu_kernel.h" +#include "kernel/cpu/mkldnn/mkl_cpu_kernel.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { class Conv2dGradInputCPUKernel : public MKLCPUKernel { public: Conv2dGradInputCPUKernel() = default; @@ -35,8 +34,7 @@ class Conv2dGradInputCPUKernel : public MKLCPUKernel { }; MS_REG_CPU_KERNEL(Conv2DBackpropInput, Conv2dGradInputCPUKernel); -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore -#endif // MINDSPORE_CCSRC_DEVICE_CPU_CONV2D_GRAD_INPUT_CPU_KERNEL_H_ +#endif // MINDSPORE_CCSRC_KERNEL_CPU_CONV2D_GRAD_INPUT_CPU_KERNEL_H_ diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/matmul_cpu_kernel.cc b/mindspore/ccsrc/kernel/cpu/mkldnn/matmul_cpu_kernel.cc similarity index 93% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/matmul_cpu_kernel.cc rename to mindspore/ccsrc/kernel/cpu/mkldnn/matmul_cpu_kernel.cc index 84d9508c71a35a518094f8c9575afc27283f89a9..28266f2aa06eb6e2ee8fceec4d2a9e637ad46638 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/matmul_cpu_kernel.cc +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/matmul_cpu_kernel.cc @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "device/cpu/kernel/mkldnn/matmul_cpu_kernel.h" +#include "kernel/cpu/mkldnn/matmul_cpu_kernel.h" #include #include -#include "device/cpu/kernel/mkldnn/mkl_kernel_engine.h" +#include "kernel/cpu/mkldnn/mkl_kernel_engine.h" #include "common/utils.h" #include "device/cpu/cpu_device_address.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { void MatMulCPUKernel::InitKernel(const CNodePtr &kernel_node) { MS_EXCEPTION_IF_NULL(kernel_node); std::vector src_shape = AnfAlgo::GetInputDeviceShape(kernel_node, 0); @@ -68,6 +67,5 @@ bool MatMulCPUKernel::Launch(const std::vector &inputs, (void)dnnl_sgemm(trans_a_, trans_b_, dim_m_, dim_n_, dim_k_, 1.f, input_a, lda, input_b, ldb, 0.f, output, dim_n_); return true; } -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/matmul_cpu_kernel.h b/mindspore/ccsrc/kernel/cpu/mkldnn/matmul_cpu_kernel.h similarity index 80% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/matmul_cpu_kernel.h rename to mindspore/ccsrc/kernel/cpu/mkldnn/matmul_cpu_kernel.h index b096e7674093ff0c4b5202d83b622c1d1c04a1dc..ecca5dec73b9c33b474fcfbcadf3c694eb2da15e 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/matmul_cpu_kernel.h +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/matmul_cpu_kernel.h @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MINDSPORE_CCSRC_DEVICE_CPU_MATMUL_CPU_KERNEL_H_ -#define MINDSPORE_CCSRC_DEVICE_CPU_MATMUL_CPU_KERNEL_H_ +#ifndef MINDSPORE_CCSRC_KERNEL_CPU_MATMUL_CPU_KERNEL_H_ +#define MINDSPORE_CCSRC_KERNEL_CPU_MATMUL_CPU_KERNEL_H_ #include #include -#include "device/cpu/kernel/mkldnn/mkl_cpu_kernel.h" +#include "kernel/cpu/mkldnn/mkl_cpu_kernel.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { class MatMulCPUKernel : public MKLCPUKernel { public: MatMulCPUKernel() = default; @@ -42,8 +41,7 @@ class MatMulCPUKernel : public MKLCPUKernel { }; MS_REG_CPU_KERNEL(MatMul, MatMulCPUKernel); -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore -#endif // MINDSPORE_CCSRC_DEVICE_CPU_MATMUL_CPU_KERNEL_H_ +#endif // MINDSPORE_CCSRC_KERNEL_CPU_MATMUL_CPU_KERNEL_H_ diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/mkl_cpu_kernel.cc b/mindspore/ccsrc/kernel/cpu/mkldnn/mkl_cpu_kernel.cc similarity index 95% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/mkl_cpu_kernel.cc rename to mindspore/ccsrc/kernel/cpu/mkldnn/mkl_cpu_kernel.cc index 677df1d0f8026c771daca540aa10181134b25232..1f7ccf9e4164729f2d9d4835751bf3bfc39241f9 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/mkl_cpu_kernel.cc +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/mkl_cpu_kernel.cc @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "device/cpu/kernel/mkldnn/mkl_cpu_kernel.h" +#include "kernel/cpu/mkldnn/mkl_cpu_kernel.h" #include #include #include #include "common/utils.h" -#include "device/cpu/kernel/mkldnn/mkl_kernel_engine.h" +#include "kernel/cpu/mkldnn/mkl_kernel_engine.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { void MKLCPUKernel::GetPadding(const CNodePtr &kernel_node, const std::string &pad_mode, const std::vector &src_shape, int kernel_size, int stride, std::vector *padding_l, std::vector *padding_r) { @@ -99,6 +98,5 @@ void MKLCPUKernel::SetArgumentHandle(int arg_key, void *ptr) { } void MKLCPUKernel::ExecutePrimitive() { MKLKernelEngine::Get().Execute(primitive_, arguments_); } -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/mkl_cpu_kernel.h b/mindspore/ccsrc/kernel/cpu/mkldnn/mkl_cpu_kernel.h similarity index 82% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/mkl_cpu_kernel.h rename to mindspore/ccsrc/kernel/cpu/mkldnn/mkl_cpu_kernel.h index 0a38de706011cd2c47353ba063e1fa4917740e11..cd06032ff02c4dde69410f4077e29a3d989c8880 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/mkl_cpu_kernel.h +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/mkl_cpu_kernel.h @@ -13,20 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MINDSPORE_CCSRC_DEVICE_CPU_MKL_CPU_KERNEL_H_ -#define MINDSPORE_CCSRC_DEVICE_CPU_MKL_CPU_KERNEL_H_ +#ifndef MINDSPORE_CCSRC_KERNEL_CPU_MKL_CPU_KERNEL_H_ +#define MINDSPORE_CCSRC_KERNEL_CPU_MKL_CPU_KERNEL_H_ #include #include #include #include #include "dnnl.hpp" -#include "device/cpu/cpu_kernel.h" -#include "device/cpu/cpu_kernel_factory.h" +#include "kernel/cpu/cpu_kernel.h" +#include "kernel/cpu/cpu_kernel_factory.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { class MKLCPUKernel : public CPUKernel { public: MKLCPUKernel() = default; @@ -43,8 +42,7 @@ class MKLCPUKernel : public CPUKernel { std::unordered_map arguments_; std::shared_ptr primitive_{nullptr}; }; -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore -#endif // MINDSPORE_CCSRC_DEVICE_CPU_MKL_CPU_KERNEL_H_ +#endif // MINDSPORE_CCSRC_KERNEL_CPU_MKL_CPU_KERNEL_H_ diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/mkl_kernel_engine.cc b/mindspore/ccsrc/kernel/cpu/mkldnn/mkl_kernel_engine.cc similarity index 89% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/mkl_kernel_engine.cc rename to mindspore/ccsrc/kernel/cpu/mkldnn/mkl_kernel_engine.cc index 702514873273b8c0532091220ab2569c1067b1f1..ae4dbb26d84e89ef691d58cff6391beea7f7eb33 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/mkl_kernel_engine.cc +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/mkl_kernel_engine.cc @@ -13,13 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "device/cpu/kernel/mkldnn/mkl_kernel_engine.h" +#include "kernel/cpu/mkldnn/mkl_kernel_engine.h" #include "utils/log_adapter.h" #include "dnnl.hpp" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { void MKLKernelEngine::Execute(const std::shared_ptr &primitive, const std::unordered_map &arguments) { MS_EXCEPTION_IF_NULL(primitive); @@ -34,6 +33,5 @@ dnnl::memory MKLKernelEngine::CreateMemory(const dnnl::memory::desc &mem_desc, b return dnnl::memory(mem_desc, engine_, nullptr); } } -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/mkl_kernel_engine.h b/mindspore/ccsrc/kernel/cpu/mkldnn/mkl_kernel_engine.h similarity index 95% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/mkl_kernel_engine.h rename to mindspore/ccsrc/kernel/cpu/mkldnn/mkl_kernel_engine.h index ea764359b6f481fe025487cf7059f6b1b9577977..36a3ceff6dc785f384d638e2708a5b7867bc44ea 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/mkl_kernel_engine.h +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/mkl_kernel_engine.h @@ -23,8 +23,7 @@ #include "common/utils.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { class MKLKernelEngine { public: static MKLKernelEngine &Get() { @@ -46,8 +45,7 @@ class MKLKernelEngine { dnnl::engine engine_; dnnl::stream stream_; }; -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore #endif // MINDSPORE_MKL_KERNEL_ENGINE_H_ diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/mul_cpu_kernel.cc b/mindspore/ccsrc/kernel/cpu/mkldnn/mul_cpu_kernel.cc similarity index 93% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/mul_cpu_kernel.cc rename to mindspore/ccsrc/kernel/cpu/mkldnn/mul_cpu_kernel.cc index bdaa85559ee4449b991b99527466b92eb20513d4..4f77508004da3582221df1509128858708f98a64 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/mul_cpu_kernel.cc +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/mul_cpu_kernel.cc @@ -13,14 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "device/cpu/kernel/mkldnn/mul_cpu_kernel.h" -#include "device/cpu/kernel/mkldnn/mkl_kernel_engine.h" +#include "kernel/cpu/mkldnn/mul_cpu_kernel.h" +#include "kernel/cpu/mkldnn/mkl_kernel_engine.h" #include "device/cpu/cpu_device_address.h" #include "common/utils.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { void MulCPUKernel::InitKernel(const CNodePtr &kernel_node) { MS_EXCEPTION_IF_NULL(kernel_node); std::vector src0_shape = AnfAlgo::GetInputDeviceShape(kernel_node, 0); @@ -58,6 +57,5 @@ bool MulCPUKernel::Launch(const std::vector &inputs, ExecutePrimitive(); return true; } -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/mul_cpu_kernel.h b/mindspore/ccsrc/kernel/cpu/mkldnn/mul_cpu_kernel.h similarity index 78% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/mul_cpu_kernel.h rename to mindspore/ccsrc/kernel/cpu/mkldnn/mul_cpu_kernel.h index e666197632c40df1f71f29153faf1081614f23c1..746c2925ec9aa3b200392f62d85671a15851a4f1 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/mul_cpu_kernel.h +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/mul_cpu_kernel.h @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MINDSPORE_CCSRC_DEVICE_CPU_MUL_CPU_KERNEL_H_ -#define MINDSPORE_CCSRC_DEVICE_CPU_MUL_CPU_KERNEL_H_ +#ifndef MINDSPORE_CCSRC_KERNEL_CPU_MUL_CPU_KERNEL_H_ +#define MINDSPORE_CCSRC_KERNEL_CPU_MUL_CPU_KERNEL_H_ #include #include -#include "device/cpu/kernel/mkldnn/mkl_cpu_kernel.h" +#include "kernel/cpu/mkldnn/mkl_cpu_kernel.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { class MulCPUKernel : public MKLCPUKernel { public: MulCPUKernel() = default; @@ -35,8 +34,7 @@ class MulCPUKernel : public MKLCPUKernel { }; MS_REG_CPU_KERNEL(Mul, MulCPUKernel); -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore -#endif // MINDSPORE_CCSRC_DEVICE_CPU_MUL_CPU_KERNEL_H_ +#endif // MINDSPORE_CCSRC_KERNEL_CPU_MUL_CPU_KERNEL_H_ diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/pooling_cpu_kernel.cc b/mindspore/ccsrc/kernel/cpu/mkldnn/pooling_cpu_kernel.cc similarity index 94% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/pooling_cpu_kernel.cc rename to mindspore/ccsrc/kernel/cpu/mkldnn/pooling_cpu_kernel.cc index 9417105e2f56e2f930941ca986ca69d90c70811d..5225050dc181ef0314dba804aa6a3f8795270330 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/pooling_cpu_kernel.cc +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/pooling_cpu_kernel.cc @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "device/cpu/kernel/mkldnn/pooling_cpu_kernel.h" +#include "kernel/cpu/mkldnn/pooling_cpu_kernel.h" #include #include #include "common/utils.h" -#include "device/cpu/kernel/mkldnn/mkl_kernel_engine.h" +#include "kernel/cpu/mkldnn/mkl_kernel_engine.h" #include "device/cpu/cpu_device_address.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { void PoolingCPUKernel::InitKernel(const CNodePtr &kernel_node) { MS_EXCEPTION_IF_NULL(kernel_node); std::vector src_shape = AnfAlgo::GetInputDeviceShape(kernel_node, 0); @@ -66,6 +65,5 @@ bool PoolingCPUKernel::Launch(const std::vector &inputs, ExecutePrimitive(); return true; } -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/pooling_cpu_kernel.h b/mindspore/ccsrc/kernel/cpu/mkldnn/pooling_cpu_kernel.h similarity index 78% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/pooling_cpu_kernel.h rename to mindspore/ccsrc/kernel/cpu/mkldnn/pooling_cpu_kernel.h index 50f4ff5da73a45091a6bbbbb0a289136399cc611..a08201513772302c953de6852b645768e285b255 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/pooling_cpu_kernel.h +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/pooling_cpu_kernel.h @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MINDSPORE_CCSRC_DEVICE_CPU_POOLING_CPU_KERNEL_H_ -#define MINDSPORE_CCSRC_DEVICE_CPU_POOLING_CPU_KERNEL_H_ +#ifndef MINDSPORE_CCSRC_KERNEL_CPU_POOLING_CPU_KERNEL_H_ +#define MINDSPORE_CCSRC_KERNEL_CPU_POOLING_CPU_KERNEL_H_ #include #include -#include "device/cpu/kernel/mkldnn/mkl_cpu_kernel.h" +#include "kernel/cpu/mkldnn/mkl_cpu_kernel.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { class PoolingCPUKernel : public MKLCPUKernel { public: PoolingCPUKernel() = default; @@ -35,8 +34,7 @@ class PoolingCPUKernel : public MKLCPUKernel { }; MS_REG_CPU_KERNEL(MaxPool, PoolingCPUKernel); -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore -#endif // MINDSPORE_CCSRC_DEVICE_CPU_POOLING_CPU_KERNEL_H_ +#endif // MINDSPORE_CCSRC_KERNEL_CPU_POOLING_CPU_KERNEL_H_ diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/pooling_grad_cpu_kernel.cc b/mindspore/ccsrc/kernel/cpu/mkldnn/pooling_grad_cpu_kernel.cc similarity index 96% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/pooling_grad_cpu_kernel.cc rename to mindspore/ccsrc/kernel/cpu/mkldnn/pooling_grad_cpu_kernel.cc index 724b78f19f3b7d622ad291a4631865467717e803..c0459de7908518c4ccdfd37704dbb018f136b04a 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/pooling_grad_cpu_kernel.cc +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/pooling_grad_cpu_kernel.cc @@ -13,17 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "device/cpu/kernel/mkldnn/pooling_grad_cpu_kernel.h" +#include "kernel/cpu/mkldnn/pooling_grad_cpu_kernel.h" #include #include #include #include "common/utils.h" -#include "device/cpu/kernel/mkldnn/mkl_kernel_engine.h" +#include "kernel/cpu/mkldnn/mkl_kernel_engine.h" #include "device/cpu/cpu_device_address.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { void PoolingGradCPUKernel::InitKernel(const CNodePtr &kernel_node) { MS_EXCEPTION_IF_NULL(kernel_node); src_shape_ = AnfAlgo::GetInputDeviceShape(kernel_node, 0); @@ -121,6 +120,5 @@ bool PoolingGradCPUKernel::Launch(const std::vector &inputs, } return true; } -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/pooling_grad_cpu_kernel.h b/mindspore/ccsrc/kernel/cpu/mkldnn/pooling_grad_cpu_kernel.h similarity index 82% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/pooling_grad_cpu_kernel.h rename to mindspore/ccsrc/kernel/cpu/mkldnn/pooling_grad_cpu_kernel.h index e557f7f95f71df081117595f6b3d379928941365..16ca6901d469fd16663a519da295897ec5bf0c4c 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/pooling_grad_cpu_kernel.h +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/pooling_grad_cpu_kernel.h @@ -13,17 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MINDSPORE_CCSRC_DEVICE_CPU_POOLING_GRAD_CPU_KERNEL_H_ -#define MINDSPORE_CCSRC_DEVICE_CPU_POOLING_GRAD_CPU_KERNEL_H_ +#ifndef MINDSPORE_CCSRC_KERNEL_CPU_POOLING_GRAD_CPU_KERNEL_H_ +#define MINDSPORE_CCSRC_KERNEL_CPU_POOLING_GRAD_CPU_KERNEL_H_ #include #include #include -#include "device/cpu/kernel/mkldnn/mkl_cpu_kernel.h" +#include "kernel/cpu/mkldnn/mkl_cpu_kernel.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { class PoolingGradCPUKernel : public MKLCPUKernel { public: PoolingGradCPUKernel() = default; @@ -45,8 +44,7 @@ class PoolingGradCPUKernel : public MKLCPUKernel { }; MS_REG_CPU_KERNEL(MaxPoolGrad, PoolingGradCPUKernel); -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore -#endif // MINDSPORE_CCSRC_DEVICE_CPU_POOLING_GRAD_CPU_KERNEL_H_ +#endif // MINDSPORE_CCSRC_KERNEL_CPU_POOLING_GRAD_CPU_KERNEL_H_ diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/relu_cpu_kernel.cc b/mindspore/ccsrc/kernel/cpu/mkldnn/relu_cpu_kernel.cc similarity index 91% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/relu_cpu_kernel.cc rename to mindspore/ccsrc/kernel/cpu/mkldnn/relu_cpu_kernel.cc index c8bf63eaf061eaf737d31ed12119798ac0e4b23f..d5ef20a25e2dba63c50eb8a78f80c63fad18abe0 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/relu_cpu_kernel.cc +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/relu_cpu_kernel.cc @@ -13,14 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "device/cpu/kernel/mkldnn/relu_cpu_kernel.h" -#include "device/cpu/kernel/mkldnn/mkl_kernel_engine.h" +#include "kernel/cpu/mkldnn/relu_cpu_kernel.h" +#include "kernel/cpu/mkldnn/mkl_kernel_engine.h" #include "device/cpu/cpu_device_address.h" #include "common/utils.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { void ReluCPUKernel::InitKernel(const CNodePtr &kernel_node) { MS_EXCEPTION_IF_NULL(kernel_node); std::vector src_shape = AnfAlgo::GetInputDeviceShape(kernel_node, 0); @@ -49,6 +48,5 @@ bool ReluCPUKernel::Launch(const std::vector &inputs, ExecutePrimitive(); return true; } -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/relu_cpu_kernel.h b/mindspore/ccsrc/kernel/cpu/mkldnn/relu_cpu_kernel.h similarity index 78% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/relu_cpu_kernel.h rename to mindspore/ccsrc/kernel/cpu/mkldnn/relu_cpu_kernel.h index 8811539f407e6347644baca9f9fbb6f8b2f3cede..b9ccb12f2548d8faf6ad15bef2f99b144412e3ad 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/relu_cpu_kernel.h +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/relu_cpu_kernel.h @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MINDSPORE_CCSRC_DEVICE_CPU_RELU_CPU_KERNEL_H_ -#define MINDSPORE_CCSRC_DEVICE_CPU_RELU_CPU_KERNEL_H_ +#ifndef MINDSPORE_CCSRC_KERNEL_CPU_RELU_CPU_KERNEL_H_ +#define MINDSPORE_CCSRC_KERNEL_CPU_RELU_CPU_KERNEL_H_ #include #include -#include "device/cpu/kernel/mkldnn/mkl_cpu_kernel.h" +#include "kernel/cpu/mkldnn/mkl_cpu_kernel.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { class ReluCPUKernel : public MKLCPUKernel { public: ReluCPUKernel() = default; @@ -35,8 +34,7 @@ class ReluCPUKernel : public MKLCPUKernel { }; MS_REG_CPU_KERNEL(ReLU, ReluCPUKernel); -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore -#endif // MINDSPORE_CCSRC_DEVICE_CPU_RELU_CPU_KERNEL_H_ +#endif // MINDSPORE_CCSRC_KERNEL_CPU_RELU_CPU_KERNEL_H_ diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/relu_grad_cpu_kernel.cc b/mindspore/ccsrc/kernel/cpu/mkldnn/relu_grad_cpu_kernel.cc similarity index 93% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/relu_grad_cpu_kernel.cc rename to mindspore/ccsrc/kernel/cpu/mkldnn/relu_grad_cpu_kernel.cc index b831562d10fec76dcc46af6c11ec902fcbe6e826..4a6213ddf2b8d55239a33331fc431c54c1caed4f 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/relu_grad_cpu_kernel.cc +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/relu_grad_cpu_kernel.cc @@ -13,14 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "device/cpu/kernel/mkldnn/relu_grad_cpu_kernel.h" -#include "device/cpu/kernel/mkldnn/mkl_kernel_engine.h" +#include "kernel/cpu/mkldnn/relu_grad_cpu_kernel.h" +#include "kernel/cpu/mkldnn/mkl_kernel_engine.h" #include "device/cpu/cpu_device_address.h" #include "common/utils.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { void ReluGradCPUKernel::InitKernel(const CNodePtr &kernel_node) { MS_EXCEPTION_IF_NULL(kernel_node); std::vector src_shape = AnfAlgo::GetInputDeviceShape(kernel_node, 0); @@ -66,6 +65,5 @@ bool ReluGradCPUKernel::Launch(const std::vector &inputs, } return true; } -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/relu_grad_cpu_kernel.h b/mindspore/ccsrc/kernel/cpu/mkldnn/relu_grad_cpu_kernel.h similarity index 77% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/relu_grad_cpu_kernel.h rename to mindspore/ccsrc/kernel/cpu/mkldnn/relu_grad_cpu_kernel.h index 81b84916ba55b74d1f176fb37a21947e83e52334..1ff9184b2eb02582318ed9aace52bb941c323fd4 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/relu_grad_cpu_kernel.h +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/relu_grad_cpu_kernel.h @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MINDSPORE_CCSRC_DEVICE_CPU_RELU_GRAD_CPU_KERNEL_H_ -#define MINDSPORE_CCSRC_DEVICE_CPU_RELU_GRAD_CPU_KERNEL_H_ +#ifndef MINDSPORE_CCSRC_KERNEL_CPU_RELU_GRAD_CPU_KERNEL_H_ +#define MINDSPORE_CCSRC_KERNEL_CPU_RELU_GRAD_CPU_KERNEL_H_ #include #include -#include "device/cpu/kernel/mkldnn/mkl_cpu_kernel.h" +#include "kernel/cpu/mkldnn/mkl_cpu_kernel.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { class ReluGradCPUKernel : public MKLCPUKernel { public: ReluGradCPUKernel() = default; @@ -35,8 +34,7 @@ class ReluGradCPUKernel : public MKLCPUKernel { }; MS_REG_CPU_KERNEL(ReluGrad, ReluGradCPUKernel); -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore -#endif // MINDSPORE_CCSRC_DEVICE_CPU_RELU_GRAD_CPU_KERNEL_H_ +#endif // MINDSPORE_CCSRC_KERNEL_CPU_RELU_GRAD_CPU_KERNEL_H_ diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/softmax_cpu_kernel.cc b/mindspore/ccsrc/kernel/cpu/mkldnn/softmax_cpu_kernel.cc similarity index 91% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/softmax_cpu_kernel.cc rename to mindspore/ccsrc/kernel/cpu/mkldnn/softmax_cpu_kernel.cc index 495f833c164759a4feccb1513463391c8f3be734..7fa740cfc05cae9791690aa57e35ab29c6e0bed2 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/softmax_cpu_kernel.cc +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/softmax_cpu_kernel.cc @@ -13,14 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "device/cpu/kernel/mkldnn/softmax_cpu_kernel.h" -#include "device/cpu/kernel/mkldnn/mkl_kernel_engine.h" +#include "kernel/cpu/mkldnn/softmax_cpu_kernel.h" +#include "kernel/cpu/mkldnn/mkl_kernel_engine.h" #include "device/cpu/cpu_device_address.h" #include "common/utils.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { void SoftmaxCPUKernel::InitKernel(const CNodePtr &kernel_node) { MS_EXCEPTION_IF_NULL(kernel_node); std::vector src_shape = AnfAlgo::GetInputDeviceShape(kernel_node, 0); @@ -51,6 +50,5 @@ bool SoftmaxCPUKernel::Launch(const std::vector &inputs, ExecutePrimitive(); return true; } -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/softmax_cpu_kernel.h b/mindspore/ccsrc/kernel/cpu/mkldnn/softmax_cpu_kernel.h similarity index 78% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/softmax_cpu_kernel.h rename to mindspore/ccsrc/kernel/cpu/mkldnn/softmax_cpu_kernel.h index 8f4ccae1b2065f80c991d602db41921dc9d897a0..de512474934d9bb2735fd4e476cd9c2eb43312cf 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/softmax_cpu_kernel.h +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/softmax_cpu_kernel.h @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MINDSPORE_CCSRC_DEVICE_CPU_SOFTMAX_CPU_KERNEL_H_ -#define MINDSPORE_CCSRC_DEVICE_CPU_SOFTMAX_CPU_KERNEL_H_ +#ifndef MINDSPORE_CCSRC_KERNEL_CPU_SOFTMAX_CPU_KERNEL_H_ +#define MINDSPORE_CCSRC_KERNEL_CPU_SOFTMAX_CPU_KERNEL_H_ #include #include -#include "device/cpu/kernel/mkldnn/mkl_cpu_kernel.h" +#include "kernel/cpu/mkldnn/mkl_cpu_kernel.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { class SoftmaxCPUKernel : public MKLCPUKernel { public: SoftmaxCPUKernel() = default; @@ -35,8 +34,7 @@ class SoftmaxCPUKernel : public MKLCPUKernel { }; MS_REG_CPU_KERNEL(Softmax, SoftmaxCPUKernel); -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore -#endif // MINDSPORE_CCSRC_DEVICE_CPU_SOFTMAX_CPU_KERNEL_H_ +#endif // MINDSPORE_CCSRC_KERNEL_CPU_SOFTMAX_CPU_KERNEL_H_ diff --git a/mindspore/ccsrc/device/cpu/kernel/mkldnn/sparse_softmax_cross_entropy_with_logits_cpu_kernel.cc b/mindspore/ccsrc/kernel/cpu/mkldnn/sparse_softmax_cross_entropy_with_logits_cpu_kernel.cc similarity index 95% rename from mindspore/ccsrc/device/cpu/kernel/mkldnn/sparse_softmax_cross_entropy_with_logits_cpu_kernel.cc rename to mindspore/ccsrc/kernel/cpu/mkldnn/sparse_softmax_cross_entropy_with_logits_cpu_kernel.cc index ca06b4a617e453c2c70376634fd4c574f654d191..c33fcd246f85ed27b5ce7c0c84287832e8a76bc8 100644 --- a/mindspore/ccsrc/device/cpu/kernel/mkldnn/sparse_softmax_cross_entropy_with_logits_cpu_kernel.cc +++ b/mindspore/ccsrc/kernel/cpu/mkldnn/sparse_softmax_cross_entropy_with_logits_cpu_kernel.cc @@ -13,17 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "device/cpu/kernel/mkldnn/sparse_softmax_cross_entropy_with_logits_cpu_kernel.h" +#include "kernel/cpu/mkldnn/sparse_softmax_cross_entropy_with_logits_cpu_kernel.h" #include #include #include -#include "device/cpu/kernel/mkldnn/mkl_kernel_engine.h" +#include "kernel/cpu/mkldnn/mkl_kernel_engine.h" #include "device/cpu/cpu_device_address.h" #include "common/utils.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { void SparseSoftmaxCrossEntropyWithLogitsCPUKernel::InitInputOutputSize(const CNodePtr &kernel_node) { CPUKernel::InitInputOutputSize(kernel_node); MS_EXCEPTION_IF_NULL(kernel_node); @@ -126,6 +125,5 @@ bool SparseSoftmaxCrossEntropyWithLogitsCPUKernel::Launch(const std::vector #include -#include "device/cpu/kernel/mkldnn/mkl_cpu_kernel.h" +#include "kernel/cpu/mkldnn/mkl_cpu_kernel.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { class SparseSoftmaxCrossEntropyWithLogitsCPUKernel : public MKLCPUKernel { public: SparseSoftmaxCrossEntropyWithLogitsCPUKernel() = default; @@ -45,8 +44,7 @@ class SparseSoftmaxCrossEntropyWithLogitsCPUKernel : public MKLCPUKernel { }; MS_REG_CPU_KERNEL(SparseSoftmaxCrossEntropyWithLogits, SparseSoftmaxCrossEntropyWithLogitsCPUKernel); -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore -#endif // MINDSPORE_CCSRC_DEVICE_CPU_SPARSE_SOFTMAX_CROSS_ENTROPY_WITH_LOGITS_CPU_KERNEL_H_ +#endif // MINDSPORE_CCSRC_KERNEL_CPU_SPARSE_SOFTMAX_CROSS_ENTROPY_WITH_LOGITS_CPU_KERNEL_H_ diff --git a/mindspore/ccsrc/device/cpu/kernel/one_hot_cpu_kernel.cc b/mindspore/ccsrc/kernel/cpu/one_hot_cpu_kernel.cc similarity index 95% rename from mindspore/ccsrc/device/cpu/kernel/one_hot_cpu_kernel.cc rename to mindspore/ccsrc/kernel/cpu/one_hot_cpu_kernel.cc index e4b3f03f58e2f8d76cf41ff1fd539fc7a82d5e39..00dfe73f28b4bcfb5ae0895aa97dc43259751dde 100644 --- a/mindspore/ccsrc/device/cpu/kernel/one_hot_cpu_kernel.cc +++ b/mindspore/ccsrc/kernel/cpu/one_hot_cpu_kernel.cc @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "device/cpu/kernel/one_hot_cpu_kernel.h" +#include "kernel/cpu/one_hot_cpu_kernel.h" #include "device/cpu/cpu_device_address.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { void OneHotCPUKernel::InitKernel(const CNodePtr &kernel_node) { MS_EXCEPTION_IF_NULL(kernel_node); auto output_shape = AnfAlgo::GetOutputInferShape(kernel_node, 0); @@ -69,6 +68,5 @@ bool OneHotCPUKernel::Launch(const std::vector &inputs, return true; } -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/device/cpu/kernel/one_hot_cpu_kernel.h b/mindspore/ccsrc/kernel/cpu/one_hot_cpu_kernel.h similarity index 77% rename from mindspore/ccsrc/device/cpu/kernel/one_hot_cpu_kernel.h rename to mindspore/ccsrc/kernel/cpu/one_hot_cpu_kernel.h index f41ac63265a4d9a9e2a2e0b78add9c0662cb9af0..bb692361239ad64c46be05a9cf677d690ae04e47 100644 --- a/mindspore/ccsrc/device/cpu/kernel/one_hot_cpu_kernel.h +++ b/mindspore/ccsrc/kernel/cpu/one_hot_cpu_kernel.h @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MINDSPORE_CCSRC_DEVICE_CPU_ONE_HOT_CPU_KERNEL_H_ -#define MINDSPORE_CCSRC_DEVICE_CPU_ONE_HOT_CPU_KERNEL_H_ +#ifndef MINDSPORE_CCSRC_KERNEL_CPU_ONE_HOT_CPU_KERNEL_H_ +#define MINDSPORE_CCSRC_KERNEL_CPU_ONE_HOT_CPU_KERNEL_H_ #include #include -#include "device/cpu/cpu_kernel.h" -#include "device/cpu/cpu_kernel_factory.h" +#include "kernel/cpu/cpu_kernel.h" +#include "kernel/cpu/cpu_kernel_factory.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { class OneHotCPUKernel : public CPUKernel { public: OneHotCPUKernel() = default; @@ -40,8 +39,7 @@ class OneHotCPUKernel : public CPUKernel { }; MS_REG_CPU_KERNEL(OneHot, OneHotCPUKernel); -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore -#endif // MINDSPORE_CCSRC_DEVICE_CPU_ONE_HOT_CPU_KERNEL_H_ +#endif // MINDSPORE_CCSRC_KERNEL_CPU_ONE_HOT_CPU_KERNEL_H_ diff --git a/mindspore/ccsrc/device/cpu/kernel/reshape_cpu_kernel.cc b/mindspore/ccsrc/kernel/cpu/reshape_cpu_kernel.cc similarity index 92% rename from mindspore/ccsrc/device/cpu/kernel/reshape_cpu_kernel.cc rename to mindspore/ccsrc/kernel/cpu/reshape_cpu_kernel.cc index a742e3a55053c6c56694b530a5d602aa6e3af39b..7342a19e993dfd727dff643b1aa58e27d397b5a2 100644 --- a/mindspore/ccsrc/device/cpu/kernel/reshape_cpu_kernel.cc +++ b/mindspore/ccsrc/kernel/cpu/reshape_cpu_kernel.cc @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "device/cpu/kernel/reshape_cpu_kernel.h" +#include "kernel/cpu/reshape_cpu_kernel.h" #include "device/cpu/cpu_device_address.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { void ReshapeCPUKernel::InitKernel(const CNodePtr &kernel_node) { MS_EXCEPTION_IF_NULL(kernel_node); } bool ReshapeCPUKernel::Launch(const std::vector &inputs, @@ -43,6 +42,5 @@ bool ReshapeCPUKernel::Launch(const std::vector &inputs, } return true; } -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/device/cpu/kernel/reshape_cpu_kernel.h b/mindspore/ccsrc/kernel/cpu/reshape_cpu_kernel.h similarity index 78% rename from mindspore/ccsrc/device/cpu/kernel/reshape_cpu_kernel.h rename to mindspore/ccsrc/kernel/cpu/reshape_cpu_kernel.h index d371e3a7ac258944090caf9eb727d6e1a2e4533a..837873d48c6e7f93f067fe63207c64675e0abb4a 100644 --- a/mindspore/ccsrc/device/cpu/kernel/reshape_cpu_kernel.h +++ b/mindspore/ccsrc/kernel/cpu/reshape_cpu_kernel.h @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MINDSPORE_CCSRC_DEVICE_CPU_RESHAPE_CPU_KERNEL_H_ -#define MINDSPORE_CCSRC_DEVICE_CPU_RESHAPE_CPU_KERNEL_H_ +#ifndef MINDSPORE_CCSRC_KERNEL_CPU_RESHAPE_CPU_KERNEL_H_ +#define MINDSPORE_CCSRC_KERNEL_CPU_RESHAPE_CPU_KERNEL_H_ #include #include -#include "device/cpu/cpu_kernel.h" -#include "device/cpu/cpu_kernel_factory.h" +#include "kernel/cpu/cpu_kernel.h" +#include "kernel/cpu/cpu_kernel_factory.h" namespace mindspore { -namespace device { -namespace cpu { +namespace kernel { class ReshapeCPUKernel : public CPUKernel { public: ReshapeCPUKernel() = default; @@ -37,8 +36,7 @@ class ReshapeCPUKernel : public CPUKernel { MS_REG_CPU_KERNEL(Reshape, ReshapeCPUKernel); MS_REG_CPU_KERNEL(Flatten, ReshapeCPUKernel); MS_REG_CPU_KERNEL(ExpandDims, ReshapeCPUKernel); -} // namespace cpu -} // namespace device +} // namespace kernel } // namespace mindspore -#endif // MINDSPORE_CCSRC_DEVICE_CPU_RESHAPE_CPU_KERNEL_H_ +#endif // MINDSPORE_CCSRC_KERNEL_CPU_RESHAPE_CPU_KERNEL_H_ diff --git a/mindspore/ccsrc/session/CMakeLists.txt b/mindspore/ccsrc/session/CMakeLists.txt index 66495626eb9e622a4f552c4ebddc06d0fb37eaa8..56a7327e800eb429862167dc1d420b6041144552 100644 --- a/mindspore/ccsrc/session/CMakeLists.txt +++ b/mindspore/ccsrc/session/CMakeLists.txt @@ -12,6 +12,13 @@ if (ENABLE_GPU) list(APPEND _SESSION_SRC_LIST ${_GPU_SRC_LIST}) endif () +if (ENABLE_CPU) + file(GLOB_RECURSE _CPU_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + "cpu_session.cc" + ) + list(APPEND _SESSION_SRC_LIST ${_CPU_SRC_LIST}) +endif () + if (ENABLE_D) file(GLOB_RECURSE _D_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "ascend_session.cc" diff --git a/mindspore/ccsrc/device/cpu/cpu_session.cc b/mindspore/ccsrc/session/cpu_session.cc similarity index 96% rename from mindspore/ccsrc/device/cpu/cpu_session.cc rename to mindspore/ccsrc/session/cpu_session.cc index 1613f9f91e73c6b8c91e1059e8679c4ee5e77c00..e8830d730c5a7416cdf05002317856b5a4a449da 100644 --- a/mindspore/ccsrc/device/cpu/cpu_session.cc +++ b/mindspore/ccsrc/session/cpu_session.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "device/cpu/cpu_session.h" +#include "session/cpu_session.h" #include #include "ir/meta_tensor.h" #include "ir/anf.h" @@ -23,7 +23,7 @@ #include "session/anf_runtime_algorithm.h" #include "device/kernel_runtime.h" #include "predict/predict.h" -#include "device/cpu/cpu_kernel_factory.h" +#include "kernel/cpu/cpu_kernel_factory.h" namespace mindspore { namespace session { @@ -110,7 +110,7 @@ void CPUSession::BuildKernel(const KernelGraph *kernel_graph) { MS_EXCEPTION_IF_NULL(kernel_node); std::string kernel_name = AnfAlgo::GetCNodeName(kernel_node); MS_LOG(INFO) << "Cpu building operator[" << kernel_name << "]."; - std::shared_ptr cpu_kernel = device::cpu::CPUKernelFactory::Get().Create(kernel_name); + std::shared_ptr cpu_kernel = kernel::CPUKernelFactory::Get().Create(kernel_name); if (cpu_kernel == nullptr) { MS_LOG(EXCEPTION) << "Operator[" << kernel_name << "] is not support."; } diff --git a/mindspore/ccsrc/device/cpu/cpu_session.h b/mindspore/ccsrc/session/cpu_session.h similarity index 100% rename from mindspore/ccsrc/device/cpu/cpu_session.h rename to mindspore/ccsrc/session/cpu_session.h diff --git a/mindspore/ccsrc/session/session_factory.h b/mindspore/ccsrc/session/session_factory.h index 476d9ff4a133b1faed2c0f9eeea48f238037ac09..99db0afeb7f5f6473c304a4c23bc9025c69731ea 100644 --- a/mindspore/ccsrc/session/session_factory.h +++ b/mindspore/ccsrc/session/session_factory.h @@ -22,7 +22,6 @@ #include #include #include "common/utils.h" -#include "device/cpu/cpu_kernel.h" #include "session/session_basic.h" namespace mindspore { namespace session { diff --git a/tests/ut/cpp/pre_activate/ascend/enhancer/insert_memcpy_async_for_getnext.cc b/tests/ut/cpp/pre_activate/ascend/enhancer/insert_memcpy_async_for_getnext.cc index 2616354e4ca02bcd9ddba040b1dce7b9c4b50965..56bf0ae4e080db0d4907b79d75f58f99539f7043 100644 --- a/tests/ut/cpp/pre_activate/ascend/enhancer/insert_memcpy_async_for_getnext.cc +++ b/tests/ut/cpp/pre_activate/ascend/enhancer/insert_memcpy_async_for_getnext.cc @@ -16,6 +16,7 @@ #include "common/backend_common_test.h" #include "common/py_func_graph_fetcher.h" #include "session/ascend_session.h" +#include "session/anf_runtime_algorithm.h" #include "pipeline/resource.h" #include "operator/ops.h" #include "ir/manager.h"