diff --git a/paddle/fluid/operators/CMakeLists.txt b/paddle/fluid/operators/CMakeLists.txt index 2808133e844a6587ea3ec3fc0732caac2a6e433a..16ef5c9524e5d414350bd485d1930b20a139b1fe 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 f6bb3e0712f759d6ed656b8acabd4e723620f82d..77fd27666f295307339d33e1dc5a5d72c5540bf3 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 fd6428b43ece8714b2f95e80c07a2a3190e6cb02..12158bf9d03d8765ed961c256b6f24f0d710558a 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 2691bee0fdf1669535540dfc5f217c55fa4aca60..4a8b4554c8ba5ac6496d2ee837056aa98bc15b10 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 a1aca97723e75eed3b3fefe9bf8471d4326bc812..edc05f86a03c894586952c4740b484692c1a418f 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 8078ace7a8458bd43b24122e8fcfd59f67d7deeb..93204d340e993def1307532820abdecb656a048f 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 03c2100ca059cd8e68d88f5daa2f8ad50c303377..52b8da9a82aa1b9e7b45a18defb09a94ebca9614 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 1da2af51f410b3d296324bac6bd9b00f9b31bbbc..310da0c76f1ab251d788e54f2305f375f3fb4838 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 de8aaf229fe8f2844afd76b7536f5fa13e569bce..4a136534dca0764686b1e271f490df42ccf5bbdb 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 6fbb0f9f7ea71d622ee0e7e2cf29db287ca53cfa..6a789c52c370d94ed5ea52a1d8b728617fd7a819 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 e06c2b58daea5ebddb48a629e08c171fe77b8929..af9df77337d0d2dcc241714b50b93889248628dc 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 9bb0ba349bce7e34af0da1928d103be26ce083bb..f300d28a6f0d6a9eaa44825581bdae22186fc8a8 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 901a891cb38a260f304d0d883229b2ab8ae3bd38..737b7f60e3c4e53aa1706377afb84ecd98d3717c 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 88a7d661940658e484cca7d9ca7741710ef5ebf4..0ffe1d565f1b2a1639c82b85e9c0825d64461de7 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 9cf032db43f4aac700a575bc0aac0ae961c28f9f..45cfec1c477373bbe94373e23f727f553e492fb7 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 dbccac896c53c31e95817eda50c69b0a8f872ff9..a987b5fca098e21aeb1b673701313dc2974f973a 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 796f58d40177be87e33bbe540ed1b9cf75e16c92..76a663633d1eaa9a148f1d19557c0e72363bb3d0 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 6d817461bec8dcdbcf6e659d98a720afd7b61a95..c1f02d9cd5771f40c7ce34e3ef560d16f7b71770 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 d27b5d1cbae9b2644382106daaf12a50df7f942c..836b6eee8007d088dc9bd1108357b899c2a983cd 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,