From 53709e7e619dbcf243a7421777c103e69c5012ee Mon Sep 17 00:00:00 2001 From: tensor-tang Date: Thu, 6 Dec 2018 13:01:38 +0000 Subject: [PATCH] refine names --- paddle/fluid/operators/CMakeLists.txt | 4 +- .../{jitkernels => jit}/CMakeLists.txt | 6 +-- .../operators/{jitkernels => jit}/README.md | 2 +- .../jitcode => jit/gen}/CMakeLists.txt | 0 .../{jitkernels/jitcode => jit/gen}/blas.cc | 17 ++++---- .../{jitkernels/jitcode => jit/gen}/blas.h | 10 ++--- .../jitcode => jit/gen}/jitcode.cc | 10 ++--- .../{jitkernels/jitcode => jit/gen}/jitcode.h | 12 +++--- .../jitcode_base.cc => jit/gen_base.cc} | 8 ++-- .../jitcode_base.h => jit/gen_base.h} | 10 ++--- .../{jitkernels => jit}/kernel_base.h | 4 +- .../{jitkernels => jit}/kernel_key.h | 6 +-- .../{jitkernels => jit}/kernel_pool.cc | 6 +-- .../{jitkernels => jit}/kernel_pool.h | 20 ++++----- .../{jitkernels => jit}/more/CMakeLists.txt | 0 .../more/mkl/CMakeLists.txt | 0 .../{jitkernels => jit}/more/mkl/mkl.cc | 10 ++--- .../{jitkernels => jit}/more/mkl/mkl.h | 6 +-- .../operators/{jitkernels => jit}/more/more.h | 0 .../{jitkernels => jit}/refer/CMakeLists.txt | 0 .../{jitkernels => jit}/refer/refer.cc | 6 +-- .../{jitkernels => jit}/refer/refer.h | 6 +-- .../operators/{jitkernels => jit}/registry.h | 42 +++++++++---------- .../operators/{jitkernels => jit}/test.cc | 6 +-- 24 files changed, 96 insertions(+), 95 deletions(-) rename paddle/fluid/operators/{jitkernels => jit}/CMakeLists.txt (79%) rename paddle/fluid/operators/{jitkernels => jit}/README.md (98%) rename paddle/fluid/operators/{jitkernels/jitcode => jit/gen}/CMakeLists.txt (100%) rename paddle/fluid/operators/{jitkernels/jitcode => jit/gen}/blas.cc (90%) rename paddle/fluid/operators/{jitkernels/jitcode => jit/gen}/blas.h (93%) rename paddle/fluid/operators/{jitkernels/jitcode => jit/gen}/jitcode.cc (79%) rename paddle/fluid/operators/{jitkernels/jitcode => jit/gen}/jitcode.h (94%) rename paddle/fluid/operators/{jitkernels/jitcode_base.cc => jit/gen_base.cc} (88%) rename paddle/fluid/operators/{jitkernels/jitcode_base.h => jit/gen_base.h} (90%) rename paddle/fluid/operators/{jitkernels => jit}/kernel_base.h (96%) rename paddle/fluid/operators/{jitkernels => jit}/kernel_key.h (93%) rename paddle/fluid/operators/{jitkernels => jit}/kernel_pool.cc (90%) rename paddle/fluid/operators/{jitkernels => jit}/kernel_pool.h (89%) rename paddle/fluid/operators/{jitkernels => jit}/more/CMakeLists.txt (100%) rename paddle/fluid/operators/{jitkernels => jit}/more/mkl/CMakeLists.txt (100%) rename paddle/fluid/operators/{jitkernels => jit}/more/mkl/mkl.cc (84%) rename paddle/fluid/operators/{jitkernels => jit}/more/mkl/mkl.h (92%) rename paddle/fluid/operators/{jitkernels => jit}/more/more.h (100%) rename paddle/fluid/operators/{jitkernels => jit}/refer/CMakeLists.txt (100%) rename paddle/fluid/operators/{jitkernels => jit}/refer/refer.cc (81%) rename paddle/fluid/operators/{jitkernels => jit}/refer/refer.h (91%) rename paddle/fluid/operators/{jitkernels => jit}/registry.h (86%) rename paddle/fluid/operators/{jitkernels => jit}/test.cc (95%) diff --git a/paddle/fluid/operators/CMakeLists.txt b/paddle/fluid/operators/CMakeLists.txt index 2808133e84..16ef5c9524 100644 --- a/paddle/fluid/operators/CMakeLists.txt +++ b/paddle/fluid/operators/CMakeLists.txt @@ -16,7 +16,7 @@ add_subdirectory(metrics) add_subdirectory(optimizers) add_subdirectory(reduce_ops) add_subdirectory(sequence_ops) -add_subdirectory(jitkernels) +add_subdirectory(jit) if(WITH_DISTRIBUTE) add_subdirectory(distributed) @@ -68,7 +68,7 @@ set(COMMON_OP_DEPS ${COMMON_OP_DEPS} selected_rows_functor selected_rows lod_ten if (NOT WIN32) set(COMMON_OP_DEPS ${COMMON_OP_DEPS} dynload_warpctc) endif() -set(COMMON_OP_DEPS ${COMMON_OP_DEPS} sequence_padding sequence_scale cos_sim_functor memory jit_kernel concat_and_split cross_entropy softmax vol2col im2col sampler) +set(COMMON_OP_DEPS ${COMMON_OP_DEPS} sequence_padding sequence_scale cos_sim_functor memory jit_kernel_helper concat_and_split cross_entropy softmax vol2col im2col sampler) set(COMMON_OP_DEPS ${COMMON_OP_DEPS} sequence2batch lstm_compute matrix_bit_code gru_compute activation_functions) if (WITH_GPU) set(COMMON_OP_DEPS ${COMMON_OP_DEPS} depthwise_conv prelu) diff --git a/paddle/fluid/operators/jitkernels/CMakeLists.txt b/paddle/fluid/operators/jit/CMakeLists.txt similarity index 79% rename from paddle/fluid/operators/jitkernels/CMakeLists.txt rename to paddle/fluid/operators/jit/CMakeLists.txt index f6bb3e0712..77fd27666f 100644 --- a/paddle/fluid/operators/jitkernels/CMakeLists.txt +++ b/paddle/fluid/operators/jit/CMakeLists.txt @@ -14,8 +14,8 @@ cc_library(jit_kernel_base SRCS ${jit_kernel_cc_srcs} DEPS ${JIT_KERNEL_DEPS}) add_subdirectory(refer) add_subdirectory(more) if(WITH_XBYAK) - add_subdirectory(jitcode) + add_subdirectory(gen) endif() -cc_library(jit_kernel SRCS ${jit_kernel_cc_srcs} DEPS ${JIT_KERNEL_DEPS}) -cc_test(jit_kernel_test SRCS test.cc DEPS jit_kernel) +cc_library(jit_kernel_helper SRCS ${jit_kernel_cc_srcs} DEPS ${JIT_KERNEL_DEPS}) +cc_test(jit_kernel_test SRCS test.cc DEPS jit_kernel_helper) diff --git a/paddle/fluid/operators/jitkernels/README.md b/paddle/fluid/operators/jit/README.md similarity index 98% rename from paddle/fluid/operators/jitkernels/README.md rename to paddle/fluid/operators/jit/README.md index fd6428b43e..12158bf9d0 100644 --- a/paddle/fluid/operators/jitkernels/README.md +++ b/paddle/fluid/operators/jit/README.md @@ -13,7 +13,7 @@ PaddlePaddle/Paddle/paddle/fluid/ │ ├── .../ └── jit/ ├── ... - ├── jitcode/ + ├── gen/ │ └── ... |── more/ │ ├── ... diff --git a/paddle/fluid/operators/jitkernels/jitcode/CMakeLists.txt b/paddle/fluid/operators/jit/gen/CMakeLists.txt similarity index 100% rename from paddle/fluid/operators/jitkernels/jitcode/CMakeLists.txt rename to paddle/fluid/operators/jit/gen/CMakeLists.txt diff --git a/paddle/fluid/operators/jitkernels/jitcode/blas.cc b/paddle/fluid/operators/jit/gen/blas.cc similarity index 90% rename from paddle/fluid/operators/jitkernels/jitcode/blas.cc rename to paddle/fluid/operators/jit/gen/blas.cc index 2691bee0fd..4a8b4554c8 100644 --- a/paddle/fluid/operators/jitkernels/jitcode/blas.cc +++ b/paddle/fluid/operators/jit/gen/blas.cc @@ -11,13 +11,14 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ -#include "paddle/fluid/operators/jitkernels/jitcode/blas.h" -#include "paddle/fluid/operators/jitkernels/registry.h" + +#include "paddle/fluid/operators/jit/gen/blas.h" +#include "paddle/fluid/operators/jit/registry.h" namespace paddle { namespace operators { -namespace jitkernels { -namespace jitcode { +namespace jit { +namespace gen { void VXXJitCode::genCode() { // do not need push stack, and do not need save avx512reg if do not use avx512 @@ -102,17 +103,17 @@ void VXXJitCode::genCode() { ret(); } -} // namespace jitcode +} // namespace gen template <> -std::unique_ptr CreateJitCode(int attr) { +std::unique_ptr CreateJitCode(int attr) { if (UseJitCode(attr)) { - return make_unique( + return make_unique( attr, CodeSize(attr)); } return nullptr; } -} // namespace jitkernels +} // namespace jit } // namespace operators } // namespace paddle diff --git a/paddle/fluid/operators/jitkernels/jitcode/blas.h b/paddle/fluid/operators/jit/gen/blas.h similarity index 93% rename from paddle/fluid/operators/jitkernels/jitcode/blas.h rename to paddle/fluid/operators/jit/gen/blas.h index a1aca97723..edc05f86a0 100644 --- a/paddle/fluid/operators/jitkernels/jitcode/blas.h +++ b/paddle/fluid/operators/jit/gen/blas.h @@ -15,12 +15,12 @@ #pragma once #include -#include "paddle/fluid/operators/jitkernels/jitcode/jitcode.h" +#include "paddle/fluid/operators/jit/gen/jitcode.h" namespace paddle { namespace operators { -namespace jitkernels { -namespace jitcode { +namespace jit { +namespace gen { // function: vec = Operand(vec(or scalar), vec(or scalar)) (maybe with relu) class VXXJitCode : public JitCode { @@ -82,7 +82,7 @@ class VMulJitCode : public VXXJitCode { : VXXJitCode(d, operand_type::mul, 0, false, code_size, code_ptr) {} }; -} // namespace jitcode -} // namespace jitkernels +} // namespace gen +} // namespace jit } // namespace operators } // namespace paddle diff --git a/paddle/fluid/operators/jitkernels/jitcode/jitcode.cc b/paddle/fluid/operators/jit/gen/jitcode.cc similarity index 79% rename from paddle/fluid/operators/jitkernels/jitcode/jitcode.cc rename to paddle/fluid/operators/jit/gen/jitcode.cc index 8078ace7a8..93204d340e 100644 --- a/paddle/fluid/operators/jitkernels/jitcode/jitcode.cc +++ b/paddle/fluid/operators/jit/gen/jitcode.cc @@ -12,11 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "paddle/fluid/operators/jitkernels/jitcode/jitcode.h" +#include "paddle/fluid/operators/jit/gen/jitcode.h" namespace paddle { namespace operators { -namespace jitkernels { +namespace jit { template <> size_t GetKey(int d) { @@ -24,15 +24,15 @@ size_t GetKey(int d) { } // template <> -// std::shared_ptr CreateJitCode(int attr) +// std::shared_ptr CreateJitCode(int attr) // { // if (UseJitCode(attr)) { -// return std::make_shared>(attr, +// return std::make_shared>(attr, // CodeSize(attr))); // } // return nullptr; // } -} // namespace jitkernels +} // namespace jit } // namespace operators } // namespace paddle diff --git a/paddle/fluid/operators/jitkernels/jitcode/jitcode.h b/paddle/fluid/operators/jit/gen/jitcode.h similarity index 94% rename from paddle/fluid/operators/jitkernels/jitcode/jitcode.h rename to paddle/fluid/operators/jit/gen/jitcode.h index 03c2100ca0..52b8da9a82 100644 --- a/paddle/fluid/operators/jitkernels/jitcode/jitcode.h +++ b/paddle/fluid/operators/jit/gen/jitcode.h @@ -15,7 +15,7 @@ #pragma once #include -#include "paddle/fluid/operators/jitkernels/jitcode_base.h" +#include "paddle/fluid/operators/jit/gen_base.h" #include "paddle/fluid/platform/cpu_info.h" #define XBYAK_USE_MMAP_ALLOCATOR @@ -24,8 +24,8 @@ namespace paddle { namespace operators { -namespace jitkernels { -namespace jitcode { +namespace jit { +namespace gen { // Application Binary Interface constexpr Xbyak::Operand::Code abi_param1(Xbyak::Operand::RDI), @@ -67,7 +67,7 @@ typedef enum { #define DECLARE_JIT_CODE(codename) \ const char* name() const override { return #codename; } -class JitCode : public JitBase, public Xbyak::CodeGenerator { +class JitCode : public GenBase, public Xbyak::CodeGenerator { public: explicit JitCode(size_t code_size, void* code_ptr = nullptr) : Xbyak::CodeGenerator(code_size, code_ptr) { @@ -128,7 +128,7 @@ class JitCode : public JitBase, public Xbyak::CodeGenerator { } }; -} // namespace jitcode -} // namespace jitkernels +} // namespace gen +} // namespace jit } // namespace operators } // namespace paddle diff --git a/paddle/fluid/operators/jitkernels/jitcode_base.cc b/paddle/fluid/operators/jit/gen_base.cc similarity index 88% rename from paddle/fluid/operators/jitkernels/jitcode_base.cc rename to paddle/fluid/operators/jit/gen_base.cc index 1da2af51f4..310da0c76f 100644 --- a/paddle/fluid/operators/jitkernels/jitcode_base.cc +++ b/paddle/fluid/operators/jit/gen_base.cc @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "paddle/fluid/operators/jitkernels/jitcode_base.h" +#include "paddle/fluid/operators/jit/gen_base.h" #include #include #include @@ -21,10 +21,10 @@ DEFINE_bool(dump_jitcode, false, "Whether to dump the jitcode to file"); namespace paddle { namespace operators { -namespace jitkernels { +namespace jit { // refer do not need useme, it would be the last one. -void JitBase::dumpCode(const unsigned char* code) const { +void GenBase::dumpCode(const unsigned char* code) const { if (code) { static int counter = 0; std::ostringstream filename; @@ -38,6 +38,6 @@ void JitBase::dumpCode(const unsigned char* code) const { } } -} // namespace jitkernels +} // namespace jit } // namespace operators } // namespace paddle diff --git a/paddle/fluid/operators/jitkernels/jitcode_base.h b/paddle/fluid/operators/jit/gen_base.h similarity index 90% rename from paddle/fluid/operators/jitkernels/jitcode_base.h rename to paddle/fluid/operators/jit/gen_base.h index de8aaf229f..4a136534dc 100644 --- a/paddle/fluid/operators/jitkernels/jitcode_base.h +++ b/paddle/fluid/operators/jit/gen_base.h @@ -16,14 +16,14 @@ #include #include // for shared_ptr -#include "paddle/fluid/operators/jitkernels/kernel_base.h" +#include "paddle/fluid/operators/jit/kernel_base.h" #include "paddle/fluid/platform/macros.h" DECLARE_bool(dump_jitcode); namespace paddle { namespace operators { -namespace jitkernels { +namespace jit { // TODO(TJ): make these functions as virtual of a class @@ -43,7 +43,7 @@ bool UseJitCode(Attr attr) { template size_t GetKey(Attr attr); -class JitBase : public Kernel { +class GenBase : public Kernel { public: virtual const char* name() const = 0; virtual const unsigned char* getCodeInternal() = 0; @@ -62,8 +62,8 @@ class JitBase : public Kernel { }; template -std::unique_ptr CreateJitCode(Attr attr); +std::unique_ptr CreateJitCode(Attr attr); -} // namespace jitkernels +} // namespace jit } // namespace operators } // namespace paddle diff --git a/paddle/fluid/operators/jitkernels/kernel_base.h b/paddle/fluid/operators/jit/kernel_base.h similarity index 96% rename from paddle/fluid/operators/jitkernels/kernel_base.h rename to paddle/fluid/operators/jit/kernel_base.h index 6fbb0f9f7e..6a789c52c3 100644 --- a/paddle/fluid/operators/jitkernels/kernel_base.h +++ b/paddle/fluid/operators/jit/kernel_base.h @@ -17,7 +17,7 @@ namespace paddle { namespace operators { -namespace jitkernels { +namespace jit { typedef enum { vmul = 0, vadd = 1, vsub, vexp } KernelType; @@ -54,6 +54,6 @@ class ReferKernel : public KernelImpl { bool UseMe(Attr attr) const override { return true; } }; -} // namespace jitkernels +} // namespace jit } // namespace operators } // namespace paddle diff --git a/paddle/fluid/operators/jitkernels/kernel_key.h b/paddle/fluid/operators/jit/kernel_key.h similarity index 93% rename from paddle/fluid/operators/jitkernels/kernel_key.h rename to paddle/fluid/operators/jit/kernel_key.h index e06c2b58da..af9df77337 100644 --- a/paddle/fluid/operators/jitkernels/kernel_key.h +++ b/paddle/fluid/operators/jit/kernel_key.h @@ -13,12 +13,12 @@ * limitations under the License. */ #pragma once -#include "paddle/fluid/operators/jitkernels/kernel_base.h" +#include "paddle/fluid/operators/jit/kernel_base.h" #include "paddle/fluid/platform/place.h" namespace paddle { namespace operators { -namespace jitkernels { +namespace jit { struct KernelKey { struct Hash { @@ -44,6 +44,6 @@ struct KernelKey { bool operator!=(const KernelKey& o) const { return !(*this == o); } }; -} // namespace jitkernels +} // namespace jit } // namespace operators } // namespace paddle diff --git a/paddle/fluid/operators/jitkernels/kernel_pool.cc b/paddle/fluid/operators/jit/kernel_pool.cc similarity index 90% rename from paddle/fluid/operators/jitkernels/kernel_pool.cc rename to paddle/fluid/operators/jit/kernel_pool.cc index 9bb0ba349b..f300d28a6f 100644 --- a/paddle/fluid/operators/jitkernels/kernel_pool.cc +++ b/paddle/fluid/operators/jit/kernel_pool.cc @@ -12,14 +12,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "paddle/fluid/operators/jitkernels/kernel_pool.h" +#include "paddle/fluid/operators/jit/kernel_pool.h" #include // for shared_ptr #include #include namespace paddle { namespace operators { -namespace jitkernels { +namespace jit { KernelPool& KernelPool::Instance() { static KernelPool g_kernel_pool; @@ -31,6 +31,6 @@ ReferKernelPool& ReferKernelPool::Instance() { return g_refer_kernel_pool; } -} // namespace jitkernels +} // namespace jit } // namespace operators } // namespace paddle diff --git a/paddle/fluid/operators/jitkernels/kernel_pool.h b/paddle/fluid/operators/jit/kernel_pool.h similarity index 89% rename from paddle/fluid/operators/jitkernels/kernel_pool.h rename to paddle/fluid/operators/jit/kernel_pool.h index 901a891cb3..737b7f60e3 100644 --- a/paddle/fluid/operators/jitkernels/kernel_pool.h +++ b/paddle/fluid/operators/jit/kernel_pool.h @@ -18,19 +18,19 @@ #include #include #include -#include "paddle/fluid/operators/jitkernels/jitcode_base.h" -#include "paddle/fluid/operators/jitkernels/kernel_base.h" -#include "paddle/fluid/operators/jitkernels/kernel_key.h" +#include "paddle/fluid/operators/jit/gen_base.h" +#include "paddle/fluid/operators/jit/kernel_base.h" +#include "paddle/fluid/operators/jit/kernel_key.h" #include "paddle/fluid/platform/place.h" namespace paddle { namespace operators { -namespace jitkernels { +namespace jit { template class JitCodePool { - typedef std::unique_ptr JitBasePtr; - typedef std::unordered_map JitBaseMap; + typedef std::unique_ptr GenBasePtr; + typedef std::unordered_map JitCodeMap; public: JitCodePool() = default; @@ -39,16 +39,16 @@ class JitCodePool { return g_jit_codes; } - const JitBaseMap& AllKernels() { return codes_; } + const JitCodeMap& AllKernels() { return codes_; } bool Has(size_t key) const { return codes_.find(key) != codes_.end(); } - void Insert(size_t key, JitBasePtr value) { + void Insert(size_t key, GenBasePtr value) { codes_.emplace(key, std::move(value)); } private: - JitBaseMap codes_; + JitCodeMap codes_; DISABLE_COPY_AND_ASSIGN(JitCodePool); }; @@ -146,6 +146,6 @@ const Func Get(Attr attr) { return GetRefer(); } -} // namespace jitkernels +} // namespace jit } // namespace operators } // namespace paddle diff --git a/paddle/fluid/operators/jitkernels/more/CMakeLists.txt b/paddle/fluid/operators/jit/more/CMakeLists.txt similarity index 100% rename from paddle/fluid/operators/jitkernels/more/CMakeLists.txt rename to paddle/fluid/operators/jit/more/CMakeLists.txt diff --git a/paddle/fluid/operators/jitkernels/more/mkl/CMakeLists.txt b/paddle/fluid/operators/jit/more/mkl/CMakeLists.txt similarity index 100% rename from paddle/fluid/operators/jitkernels/more/mkl/CMakeLists.txt rename to paddle/fluid/operators/jit/more/mkl/CMakeLists.txt diff --git a/paddle/fluid/operators/jitkernels/more/mkl/mkl.cc b/paddle/fluid/operators/jit/more/mkl/mkl.cc similarity index 84% rename from paddle/fluid/operators/jitkernels/more/mkl/mkl.cc rename to paddle/fluid/operators/jit/more/mkl/mkl.cc index 88a7d66194..0ffe1d565f 100644 --- a/paddle/fluid/operators/jitkernels/more/mkl/mkl.cc +++ b/paddle/fluid/operators/jit/more/mkl/mkl.cc @@ -12,13 +12,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "paddle/fluid/operators/jitkernels/more/mkl/mkl.h" -#include "paddle/fluid/operators/jitkernels/registry.h" +#include "paddle/fluid/operators/jit/more/mkl/mkl.h" +#include "paddle/fluid/operators/jit/registry.h" #include "paddle/fluid/platform/dynload/mklml.h" namespace paddle { namespace operators { -namespace jitkernels { +namespace jit { namespace more { namespace mkl { @@ -34,11 +34,11 @@ void VMul(const double* x, const double* y, double* z, int n) { } // namespace mkl } // namespace more -} // namespace jitkernels +} // namespace jit } // namespace operators } // namespace paddle -namespace mkl = paddle::operators::jitkernels::more::mkl; +namespace mkl = paddle::operators::jit::more::mkl; REGISTER_JITKERNEL_MORE(vmul, mkl, mkl::VMulKernel, mkl::VMulKernel); diff --git a/paddle/fluid/operators/jitkernels/more/mkl/mkl.h b/paddle/fluid/operators/jit/more/mkl/mkl.h similarity index 92% rename from paddle/fluid/operators/jitkernels/more/mkl/mkl.h rename to paddle/fluid/operators/jit/more/mkl/mkl.h index 9cf032db43..45cfec1c47 100644 --- a/paddle/fluid/operators/jitkernels/more/mkl/mkl.h +++ b/paddle/fluid/operators/jit/more/mkl/mkl.h @@ -15,12 +15,12 @@ #pragma once #include -#include "paddle/fluid/operators/jitkernels/kernel_base.h" +#include "paddle/fluid/operators/jit/kernel_base.h" #include "paddle/fluid/platform/cpu_info.h" namespace paddle { namespace operators { -namespace jitkernels { +namespace jit { namespace more { namespace mkl { @@ -43,6 +43,6 @@ class VMulKernel : public KernelImpl::func_type, } // namespace mkl } // namespace more -} // namespace jitkernels +} // namespace jit } // namespace operators } // namespace paddle diff --git a/paddle/fluid/operators/jitkernels/more/more.h b/paddle/fluid/operators/jit/more/more.h similarity index 100% rename from paddle/fluid/operators/jitkernels/more/more.h rename to paddle/fluid/operators/jit/more/more.h diff --git a/paddle/fluid/operators/jitkernels/refer/CMakeLists.txt b/paddle/fluid/operators/jit/refer/CMakeLists.txt similarity index 100% rename from paddle/fluid/operators/jitkernels/refer/CMakeLists.txt rename to paddle/fluid/operators/jit/refer/CMakeLists.txt diff --git a/paddle/fluid/operators/jitkernels/refer/refer.cc b/paddle/fluid/operators/jit/refer/refer.cc similarity index 81% rename from paddle/fluid/operators/jitkernels/refer/refer.cc rename to paddle/fluid/operators/jit/refer/refer.cc index dbccac896c..a987b5fca0 100644 --- a/paddle/fluid/operators/jitkernels/refer/refer.cc +++ b/paddle/fluid/operators/jit/refer/refer.cc @@ -12,10 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "paddle/fluid/operators/jitkernels/refer/refer.h" -#include "paddle/fluid/operators/jitkernels/registry.h" +#include "paddle/fluid/operators/jit/refer/refer.h" +#include "paddle/fluid/operators/jit/registry.h" -namespace refer = paddle::operators::jitkernels::refer; +namespace refer = paddle::operators::jit::refer; REGISTER_JITKERNEL_REFER(vmul, refer::VMulKernel, refer::VMulKernel); diff --git a/paddle/fluid/operators/jitkernels/refer/refer.h b/paddle/fluid/operators/jit/refer/refer.h similarity index 91% rename from paddle/fluid/operators/jitkernels/refer/refer.h rename to paddle/fluid/operators/jit/refer/refer.h index 796f58d401..76a663633d 100644 --- a/paddle/fluid/operators/jitkernels/refer/refer.h +++ b/paddle/fluid/operators/jit/refer/refer.h @@ -13,12 +13,12 @@ * limitations under the License. */ #pragma once -#include "paddle/fluid/operators/jitkernels/kernel_base.h" +#include "paddle/fluid/operators/jit/kernel_base.h" #include "paddle/fluid/platform/enforce.h" namespace paddle { namespace operators { -namespace jitkernels { +namespace jit { namespace refer { template @@ -36,6 +36,6 @@ class VMulKernel : public ReferKernel::func_type, }; } // namespace refer -} // namespace jitkernels +} // namespace jit } // namespace operators } // namespace paddle diff --git a/paddle/fluid/operators/jitkernels/registry.h b/paddle/fluid/operators/jit/registry.h similarity index 86% rename from paddle/fluid/operators/jitkernels/registry.h rename to paddle/fluid/operators/jit/registry.h index 6d817461be..c1f02d9cd5 100644 --- a/paddle/fluid/operators/jitkernels/registry.h +++ b/paddle/fluid/operators/jit/registry.h @@ -17,14 +17,14 @@ #include #include #include -#include "paddle/fluid/operators/jitkernels/kernel_base.h" -#include "paddle/fluid/operators/jitkernels/kernel_pool.h" +#include "paddle/fluid/operators/jit/kernel_base.h" +#include "paddle/fluid/operators/jit/kernel_pool.h" #include "paddle/fluid/platform/place.h" #include "paddle/fluid/platform/variant.h" // for UNUSED namespace paddle { namespace operators { -namespace jitkernels { +namespace jit { // make_unique is supported since c++14 template @@ -76,21 +76,21 @@ class JitKernelRegistrar { msg) // Refer always on CPUPlace -#define REGISTER_JITKERNEL_REFER(kernel_type, ...) \ - STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE( \ - __reg_jitkernel_##kernel_type##_refer_CPUPlace, \ - "REGISTER_KERNEL_REFER must be called in global namespace"); \ - static ::paddle::operators::jitkernels::JitKernelRegistrar< \ - ::paddle::operators::jitkernels::ReferKernelPool, \ - ::paddle::platform::CPUPlace, __VA_ARGS__> \ - __jit_kernel_registrar_##kernel_type##_refer_CPUPlace_( \ - ::paddle::operators::jitkernels::KernelType::kernel_type); \ - int TouchJitKernelReg_##kernel_type##_refer_CPUPlace_() { \ - __jit_kernel_registrar_##kernel_type##_refer_CPUPlace_.Touch(); \ - return 0; \ +#define REGISTER_JITKERNEL_REFER(kernel_type, ...) \ + STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE( \ + __reg_jitkernel_##kernel_type##_refer_CPUPlace, \ + "REGISTER_KERNEL_REFER must be called in global namespace"); \ + static ::paddle::operators::jit::JitKernelRegistrar< \ + ::paddle::operators::jit::ReferKernelPool, ::paddle::platform::CPUPlace, \ + __VA_ARGS__> \ + __jit_kernel_registrar_##kernel_type##_refer_CPUPlace_( \ + ::paddle::operators::jit::KernelType::kernel_type); \ + int TouchJitKernelReg_##kernel_type##_refer_CPUPlace_() { \ + __jit_kernel_registrar_##kernel_type##_refer_CPUPlace_.Touch(); \ + return 0; \ } -// kernel_type: should be in paddle::operators::jitkernels::KernelType +// kernel_type: should be in paddle::operators::jit::KernelType // place_type: should be one of CPUPlace and GPUPlace in paddle::platform #define REGISTER_KERNEL_MORE(kernel_type, impl_type, place_type, ...) \ STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE( \ @@ -99,11 +99,11 @@ class JitKernelRegistrar { extern int TouchJitKernelReg_##kernel_type##_refer_CPUPlace_(); \ static int __assert_##kernel_type##_##impl_type##_##place_type##_has_refer_ \ UNUSED = TouchJitKernelReg_##kernel_type##_refer_CPUPlace_(); \ - static ::paddle::operators::jitkernels::JitKernelRegistrar< \ - ::paddle::operators::jitkernels::KernelPool, \ - ::paddle::platform::place_type, __VA_ARGS__> \ + static ::paddle::operators::jit::JitKernelRegistrar< \ + ::paddle::operators::jit::KernelPool, ::paddle::platform::place_type, \ + __VA_ARGS__> \ __jit_kernel_registrar_##kernel_type##_##impl_type##_##place_type##_( \ - ::paddle::operators::jitkernels::KernelType::kernel_type); \ + ::paddle::operators::jit::KernelType::kernel_type); \ int TouchJitKernelReg_##kernel_type##_##impl_type##_##place_type##_() { \ __jit_kernel_registrar_##kernel_type##_##impl_type##_##place_type##_ \ .Touch(); \ @@ -139,6 +139,6 @@ class JitKernelRegistrar { #define USE_JITKERNEL_MORE(kernel_type, impl_type) \ USE_KERNEL_MORE(kernel_type, impl_type, CPUPlace) -} // namespace jitkernels +} // namespace jit } // namespace operators } // namespace paddle diff --git a/paddle/fluid/operators/jitkernels/test.cc b/paddle/fluid/operators/jit/test.cc similarity index 95% rename from paddle/fluid/operators/jitkernels/test.cc rename to paddle/fluid/operators/jit/test.cc index d27b5d1cba..836b6eee80 100644 --- a/paddle/fluid/operators/jitkernels/test.cc +++ b/paddle/fluid/operators/jit/test.cc @@ -19,9 +19,9 @@ #include "gflags/gflags.h" #include "glog/logging.h" #include "gtest/gtest.h" -#include "paddle/fluid/operators/jitkernels/kernel_pool.h" +#include "paddle/fluid/operators/jit/kernel_pool.h" // TODO(TJ): remove me -#include "paddle/fluid/operators/jitkernels/registry.h" +#include "paddle/fluid/operators/jit/registry.h" #include "paddle/fluid/platform/place.h" #include "paddle/fluid/platform/port.h" @@ -66,7 +66,7 @@ TEST(JitKernel, vmul) { using T = float; using PlaceType = paddle::platform::CPUPlace; - namespace jit = paddle::operators::jitkernels; + namespace jit = paddle::operators::jit; // TODO(TJ): test more vector size for (int d = 1; d < 30; ++d) { auto ref = jit::GetRefer::func_type, -- GitLab