提交 53709e7e 编写于 作者: T tensor-tang

refine names

上级 ce674b68
...@@ -16,7 +16,7 @@ add_subdirectory(metrics) ...@@ -16,7 +16,7 @@ add_subdirectory(metrics)
add_subdirectory(optimizers) add_subdirectory(optimizers)
add_subdirectory(reduce_ops) add_subdirectory(reduce_ops)
add_subdirectory(sequence_ops) add_subdirectory(sequence_ops)
add_subdirectory(jitkernels) add_subdirectory(jit)
if(WITH_DISTRIBUTE) if(WITH_DISTRIBUTE)
add_subdirectory(distributed) add_subdirectory(distributed)
...@@ -68,7 +68,7 @@ set(COMMON_OP_DEPS ${COMMON_OP_DEPS} selected_rows_functor selected_rows lod_ten ...@@ -68,7 +68,7 @@ set(COMMON_OP_DEPS ${COMMON_OP_DEPS} selected_rows_functor selected_rows lod_ten
if (NOT WIN32) if (NOT WIN32)
set(COMMON_OP_DEPS ${COMMON_OP_DEPS} dynload_warpctc) set(COMMON_OP_DEPS ${COMMON_OP_DEPS} dynload_warpctc)
endif() 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) set(COMMON_OP_DEPS ${COMMON_OP_DEPS} sequence2batch lstm_compute matrix_bit_code gru_compute activation_functions)
if (WITH_GPU) if (WITH_GPU)
set(COMMON_OP_DEPS ${COMMON_OP_DEPS} depthwise_conv prelu) set(COMMON_OP_DEPS ${COMMON_OP_DEPS} depthwise_conv prelu)
......
...@@ -14,8 +14,8 @@ cc_library(jit_kernel_base SRCS ${jit_kernel_cc_srcs} DEPS ${JIT_KERNEL_DEPS}) ...@@ -14,8 +14,8 @@ cc_library(jit_kernel_base SRCS ${jit_kernel_cc_srcs} DEPS ${JIT_KERNEL_DEPS})
add_subdirectory(refer) add_subdirectory(refer)
add_subdirectory(more) add_subdirectory(more)
if(WITH_XBYAK) if(WITH_XBYAK)
add_subdirectory(jitcode) add_subdirectory(gen)
endif() endif()
cc_library(jit_kernel SRCS ${jit_kernel_cc_srcs} DEPS ${JIT_KERNEL_DEPS}) 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) cc_test(jit_kernel_test SRCS test.cc DEPS jit_kernel_helper)
...@@ -13,7 +13,7 @@ PaddlePaddle/Paddle/paddle/fluid/ ...@@ -13,7 +13,7 @@ PaddlePaddle/Paddle/paddle/fluid/
│ ├── .../ │ ├── .../
└── jit/ └── jit/
├── ... ├── ...
├── jitcode/ ├── gen/
│ └── ... │ └── ...
|── more/ |── more/
│ ├── ... │ ├── ...
......
...@@ -11,13 +11,14 @@ ...@@ -11,13 +11,14 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. */ * 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 paddle {
namespace operators { namespace operators {
namespace jitkernels { namespace jit {
namespace jitcode { namespace gen {
void VXXJitCode::genCode() { void VXXJitCode::genCode() {
// do not need push stack, and do not need save avx512reg if do not use avx512 // do not need push stack, and do not need save avx512reg if do not use avx512
...@@ -102,17 +103,17 @@ void VXXJitCode::genCode() { ...@@ -102,17 +103,17 @@ void VXXJitCode::genCode() {
ret(); ret();
} }
} // namespace jitcode } // namespace gen
template <> template <>
std::unique_ptr<JitBase> CreateJitCode<KernelType::vmul, float, int>(int attr) { std::unique_ptr<GenBase> CreateJitCode<KernelType::vmul, float, int>(int attr) {
if (UseJitCode<KernelType::vmul, float, int>(attr)) { if (UseJitCode<KernelType::vmul, float, int>(attr)) {
return make_unique<jitcode::VMulJitCode>( return make_unique<gen::VMulJitCode>(
attr, CodeSize<KernelType::vmul, float, int>(attr)); attr, CodeSize<KernelType::vmul, float, int>(attr));
} }
return nullptr; return nullptr;
} }
} // namespace jitkernels } // namespace jit
} // namespace operators } // namespace operators
} // namespace paddle } // namespace paddle
...@@ -15,12 +15,12 @@ ...@@ -15,12 +15,12 @@
#pragma once #pragma once
#include <string> #include <string>
#include "paddle/fluid/operators/jitkernels/jitcode/jitcode.h" #include "paddle/fluid/operators/jit/gen/jitcode.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
namespace jitkernels { namespace jit {
namespace jitcode { namespace gen {
// function: vec = Operand(vec(or scalar), vec(or scalar)) (maybe with relu) // function: vec = Operand(vec(or scalar), vec(or scalar)) (maybe with relu)
class VXXJitCode : public JitCode { class VXXJitCode : public JitCode {
...@@ -82,7 +82,7 @@ class VMulJitCode : public VXXJitCode { ...@@ -82,7 +82,7 @@ class VMulJitCode : public VXXJitCode {
: VXXJitCode(d, operand_type::mul, 0, false, code_size, code_ptr) {} : VXXJitCode(d, operand_type::mul, 0, false, code_size, code_ptr) {}
}; };
} // namespace jitcode } // namespace gen
} // namespace jitkernels } // namespace jit
} // namespace operators } // namespace operators
} // namespace paddle } // namespace paddle
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. */ * limitations under the License. */
#include "paddle/fluid/operators/jitkernels/jitcode/jitcode.h" #include "paddle/fluid/operators/jit/gen/jitcode.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
namespace jitkernels { namespace jit {
template <> template <>
size_t GetKey<int>(int d) { size_t GetKey<int>(int d) {
...@@ -24,15 +24,15 @@ size_t GetKey<int>(int d) { ...@@ -24,15 +24,15 @@ size_t GetKey<int>(int d) {
} }
// template <> // template <>
// std::shared_ptr<const JitBase> CreateJitCode<KernelType::vmul, int>(int attr) // std::shared_ptr<const GenBase> CreateJitCode<KernelType::vmul, int>(int attr)
// { // {
// if (UseJitCode<KernelType::vmul, int>(attr)) { // if (UseJitCode<KernelType::vmul, int>(attr)) {
// return std::make_shared<jitcode::VMulJitCode<int>>(attr, // return std::make_shared<gen::VMulJitCode<int>>(attr,
// CodeSize<KernelType::vmul, int>(attr))); // CodeSize<KernelType::vmul, int>(attr)));
// } // }
// return nullptr; // return nullptr;
// } // }
} // namespace jitkernels } // namespace jit
} // namespace operators } // namespace operators
} // namespace paddle } // namespace paddle
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#pragma once #pragma once
#include <type_traits> #include <type_traits>
#include "paddle/fluid/operators/jitkernels/jitcode_base.h" #include "paddle/fluid/operators/jit/gen_base.h"
#include "paddle/fluid/platform/cpu_info.h" #include "paddle/fluid/platform/cpu_info.h"
#define XBYAK_USE_MMAP_ALLOCATOR #define XBYAK_USE_MMAP_ALLOCATOR
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
namespace paddle { namespace paddle {
namespace operators { namespace operators {
namespace jitkernels { namespace jit {
namespace jitcode { namespace gen {
// Application Binary Interface // Application Binary Interface
constexpr Xbyak::Operand::Code abi_param1(Xbyak::Operand::RDI), constexpr Xbyak::Operand::Code abi_param1(Xbyak::Operand::RDI),
...@@ -67,7 +67,7 @@ typedef enum { ...@@ -67,7 +67,7 @@ typedef enum {
#define DECLARE_JIT_CODE(codename) \ #define DECLARE_JIT_CODE(codename) \
const char* name() const override { return #codename; } const char* name() const override { return #codename; }
class JitCode : public JitBase, public Xbyak::CodeGenerator { class JitCode : public GenBase, public Xbyak::CodeGenerator {
public: public:
explicit JitCode(size_t code_size, void* code_ptr = nullptr) explicit JitCode(size_t code_size, void* code_ptr = nullptr)
: Xbyak::CodeGenerator(code_size, code_ptr) { : Xbyak::CodeGenerator(code_size, code_ptr) {
...@@ -128,7 +128,7 @@ class JitCode : public JitBase, public Xbyak::CodeGenerator { ...@@ -128,7 +128,7 @@ class JitCode : public JitBase, public Xbyak::CodeGenerator {
} }
}; };
} // namespace jitcode } // namespace gen
} // namespace jitkernels } // namespace jit
} // namespace operators } // namespace operators
} // namespace paddle } // namespace paddle
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. */ * limitations under the License. */
#include "paddle/fluid/operators/jitkernels/jitcode_base.h" #include "paddle/fluid/operators/jit/gen_base.h"
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
...@@ -21,10 +21,10 @@ DEFINE_bool(dump_jitcode, false, "Whether to dump the jitcode to file"); ...@@ -21,10 +21,10 @@ DEFINE_bool(dump_jitcode, false, "Whether to dump the jitcode to file");
namespace paddle { namespace paddle {
namespace operators { namespace operators {
namespace jitkernels { namespace jit {
// refer do not need useme, it would be the last one. // 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) { if (code) {
static int counter = 0; static int counter = 0;
std::ostringstream filename; std::ostringstream filename;
...@@ -38,6 +38,6 @@ void JitBase::dumpCode(const unsigned char* code) const { ...@@ -38,6 +38,6 @@ void JitBase::dumpCode(const unsigned char* code) const {
} }
} }
} // namespace jitkernels } // namespace jit
} // namespace operators } // namespace operators
} // namespace paddle } // namespace paddle
...@@ -16,14 +16,14 @@ ...@@ -16,14 +16,14 @@
#include <gflags/gflags.h> #include <gflags/gflags.h>
#include <memory> // for shared_ptr #include <memory> // 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" #include "paddle/fluid/platform/macros.h"
DECLARE_bool(dump_jitcode); DECLARE_bool(dump_jitcode);
namespace paddle { namespace paddle {
namespace operators { namespace operators {
namespace jitkernels { namespace jit {
// TODO(TJ): make these functions as virtual of a class // TODO(TJ): make these functions as virtual of a class
...@@ -43,7 +43,7 @@ bool UseJitCode(Attr attr) { ...@@ -43,7 +43,7 @@ bool UseJitCode(Attr attr) {
template <typename Attr> template <typename Attr>
size_t GetKey(Attr attr); size_t GetKey(Attr attr);
class JitBase : public Kernel { class GenBase : public Kernel {
public: public:
virtual const char* name() const = 0; virtual const char* name() const = 0;
virtual const unsigned char* getCodeInternal() = 0; virtual const unsigned char* getCodeInternal() = 0;
...@@ -62,8 +62,8 @@ class JitBase : public Kernel { ...@@ -62,8 +62,8 @@ class JitBase : public Kernel {
}; };
template <KernelType KT, typename T, typename Attr> template <KernelType KT, typename T, typename Attr>
std::unique_ptr<JitBase> CreateJitCode(Attr attr); std::unique_ptr<GenBase> CreateJitCode(Attr attr);
} // namespace jitkernels } // namespace jit
} // namespace operators } // namespace operators
} // namespace paddle } // namespace paddle
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
namespace paddle { namespace paddle {
namespace operators { namespace operators {
namespace jitkernels { namespace jit {
typedef enum { vmul = 0, vadd = 1, vsub, vexp } KernelType; typedef enum { vmul = 0, vadd = 1, vsub, vexp } KernelType;
...@@ -54,6 +54,6 @@ class ReferKernel : public KernelImpl<T, Func, Attr> { ...@@ -54,6 +54,6 @@ class ReferKernel : public KernelImpl<T, Func, Attr> {
bool UseMe(Attr attr) const override { return true; } bool UseMe(Attr attr) const override { return true; }
}; };
} // namespace jitkernels } // namespace jit
} // namespace operators } // namespace operators
} // namespace paddle } // namespace paddle
...@@ -13,12 +13,12 @@ ...@@ -13,12 +13,12 @@
* limitations under the License. */ * limitations under the License. */
#pragma once #pragma once
#include "paddle/fluid/operators/jitkernels/kernel_base.h" #include "paddle/fluid/operators/jit/kernel_base.h"
#include "paddle/fluid/platform/place.h" #include "paddle/fluid/platform/place.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
namespace jitkernels { namespace jit {
struct KernelKey { struct KernelKey {
struct Hash { struct Hash {
...@@ -44,6 +44,6 @@ struct KernelKey { ...@@ -44,6 +44,6 @@ struct KernelKey {
bool operator!=(const KernelKey& o) const { return !(*this == o); } bool operator!=(const KernelKey& o) const { return !(*this == o); }
}; };
} // namespace jitkernels } // namespace jit
} // namespace operators } // namespace operators
} // namespace paddle } // namespace paddle
...@@ -12,14 +12,14 @@ ...@@ -12,14 +12,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. */ * limitations under the License. */
#include "paddle/fluid/operators/jitkernels/kernel_pool.h" #include "paddle/fluid/operators/jit/kernel_pool.h"
#include <memory> // for shared_ptr #include <memory> // for shared_ptr
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
namespace paddle { namespace paddle {
namespace operators { namespace operators {
namespace jitkernels { namespace jit {
KernelPool& KernelPool::Instance() { KernelPool& KernelPool::Instance() {
static KernelPool g_kernel_pool; static KernelPool g_kernel_pool;
...@@ -31,6 +31,6 @@ ReferKernelPool& ReferKernelPool::Instance() { ...@@ -31,6 +31,6 @@ ReferKernelPool& ReferKernelPool::Instance() {
return g_refer_kernel_pool; return g_refer_kernel_pool;
} }
} // namespace jitkernels } // namespace jit
} // namespace operators } // namespace operators
} // namespace paddle } // namespace paddle
...@@ -18,19 +18,19 @@ ...@@ -18,19 +18,19 @@
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "paddle/fluid/operators/jitkernels/jitcode_base.h" #include "paddle/fluid/operators/jit/gen_base.h"
#include "paddle/fluid/operators/jitkernels/kernel_base.h" #include "paddle/fluid/operators/jit/kernel_base.h"
#include "paddle/fluid/operators/jitkernels/kernel_key.h" #include "paddle/fluid/operators/jit/kernel_key.h"
#include "paddle/fluid/platform/place.h" #include "paddle/fluid/platform/place.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
namespace jitkernels { namespace jit {
template <KernelType KT> template <KernelType KT>
class JitCodePool { class JitCodePool {
typedef std::unique_ptr<JitBase> JitBasePtr; typedef std::unique_ptr<GenBase> GenBasePtr;
typedef std::unordered_map<size_t, JitBasePtr> JitBaseMap; typedef std::unordered_map<size_t, GenBasePtr> JitCodeMap;
public: public:
JitCodePool() = default; JitCodePool() = default;
...@@ -39,16 +39,16 @@ class JitCodePool { ...@@ -39,16 +39,16 @@ class JitCodePool {
return g_jit_codes; 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(); } 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)); codes_.emplace(key, std::move(value));
} }
private: private:
JitBaseMap codes_; JitCodeMap codes_;
DISABLE_COPY_AND_ASSIGN(JitCodePool); DISABLE_COPY_AND_ASSIGN(JitCodePool);
}; };
...@@ -146,6 +146,6 @@ const Func Get(Attr attr) { ...@@ -146,6 +146,6 @@ const Func Get(Attr attr) {
return GetRefer<KT, T, Func, Attr>(); return GetRefer<KT, T, Func, Attr>();
} }
} // namespace jitkernels } // namespace jit
} // namespace operators } // namespace operators
} // namespace paddle } // namespace paddle
...@@ -12,13 +12,13 @@ ...@@ -12,13 +12,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. */ * limitations under the License. */
#include "paddle/fluid/operators/jitkernels/more/mkl/mkl.h" #include "paddle/fluid/operators/jit/more/mkl/mkl.h"
#include "paddle/fluid/operators/jitkernels/registry.h" #include "paddle/fluid/operators/jit/registry.h"
#include "paddle/fluid/platform/dynload/mklml.h" #include "paddle/fluid/platform/dynload/mklml.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
namespace jitkernels { namespace jit {
namespace more { namespace more {
namespace mkl { namespace mkl {
...@@ -34,11 +34,11 @@ void VMul<double>(const double* x, const double* y, double* z, int n) { ...@@ -34,11 +34,11 @@ void VMul<double>(const double* x, const double* y, double* z, int n) {
} // namespace mkl } // namespace mkl
} // namespace more } // namespace more
} // namespace jitkernels } // namespace jit
} // namespace operators } // namespace operators
} // namespace paddle } // namespace paddle
namespace mkl = paddle::operators::jitkernels::more::mkl; namespace mkl = paddle::operators::jit::more::mkl;
REGISTER_JITKERNEL_MORE(vmul, mkl, mkl::VMulKernel<float>, REGISTER_JITKERNEL_MORE(vmul, mkl, mkl::VMulKernel<float>,
mkl::VMulKernel<double>); mkl::VMulKernel<double>);
...@@ -15,12 +15,12 @@ ...@@ -15,12 +15,12 @@
#pragma once #pragma once
#include <type_traits> #include <type_traits>
#include "paddle/fluid/operators/jitkernels/kernel_base.h" #include "paddle/fluid/operators/jit/kernel_base.h"
#include "paddle/fluid/platform/cpu_info.h" #include "paddle/fluid/platform/cpu_info.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
namespace jitkernels { namespace jit {
namespace more { namespace more {
namespace mkl { namespace mkl {
...@@ -43,6 +43,6 @@ class VMulKernel : public KernelImpl<T, typename VMulTypes<T>::func_type, ...@@ -43,6 +43,6 @@ class VMulKernel : public KernelImpl<T, typename VMulTypes<T>::func_type,
} // namespace mkl } // namespace mkl
} // namespace more } // namespace more
} // namespace jitkernels } // namespace jit
} // namespace operators } // namespace operators
} // namespace paddle } // namespace paddle
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. */ * limitations under the License. */
#include "paddle/fluid/operators/jitkernels/refer/refer.h" #include "paddle/fluid/operators/jit/refer/refer.h"
#include "paddle/fluid/operators/jitkernels/registry.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<float>, REGISTER_JITKERNEL_REFER(vmul, refer::VMulKernel<float>,
refer::VMulKernel<double>); refer::VMulKernel<double>);
...@@ -13,12 +13,12 @@ ...@@ -13,12 +13,12 @@
* limitations under the License. */ * limitations under the License. */
#pragma once #pragma once
#include "paddle/fluid/operators/jitkernels/kernel_base.h" #include "paddle/fluid/operators/jit/kernel_base.h"
#include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/enforce.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
namespace jitkernels { namespace jit {
namespace refer { namespace refer {
template <typename T> template <typename T>
...@@ -36,6 +36,6 @@ class VMulKernel : public ReferKernel<T, typename VMulTypes<T>::func_type, ...@@ -36,6 +36,6 @@ class VMulKernel : public ReferKernel<T, typename VMulTypes<T>::func_type,
}; };
} // namespace refer } // namespace refer
} // namespace jitkernels } // namespace jit
} // namespace operators } // namespace operators
} // namespace paddle } // namespace paddle
...@@ -17,14 +17,14 @@ ...@@ -17,14 +17,14 @@
#include <memory> #include <memory>
#include <tuple> #include <tuple>
#include <type_traits> #include <type_traits>
#include "paddle/fluid/operators/jitkernels/kernel_base.h" #include "paddle/fluid/operators/jit/kernel_base.h"
#include "paddle/fluid/operators/jitkernels/kernel_pool.h" #include "paddle/fluid/operators/jit/kernel_pool.h"
#include "paddle/fluid/platform/place.h" #include "paddle/fluid/platform/place.h"
#include "paddle/fluid/platform/variant.h" // for UNUSED #include "paddle/fluid/platform/variant.h" // for UNUSED
namespace paddle { namespace paddle {
namespace operators { namespace operators {
namespace jitkernels { namespace jit {
// make_unique is supported since c++14 // make_unique is supported since c++14
template <typename T, typename... Args> template <typename T, typename... Args>
...@@ -76,21 +76,21 @@ class JitKernelRegistrar { ...@@ -76,21 +76,21 @@ class JitKernelRegistrar {
msg) msg)
// Refer always on CPUPlace // Refer always on CPUPlace
#define REGISTER_JITKERNEL_REFER(kernel_type, ...) \ #define REGISTER_JITKERNEL_REFER(kernel_type, ...) \
STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE( \ STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE( \
__reg_jitkernel_##kernel_type##_refer_CPUPlace, \ __reg_jitkernel_##kernel_type##_refer_CPUPlace, \
"REGISTER_KERNEL_REFER must be called in global namespace"); \ "REGISTER_KERNEL_REFER must be called in global namespace"); \
static ::paddle::operators::jitkernels::JitKernelRegistrar< \ static ::paddle::operators::jit::JitKernelRegistrar< \
::paddle::operators::jitkernels::ReferKernelPool, \ ::paddle::operators::jit::ReferKernelPool, ::paddle::platform::CPUPlace, \
::paddle::platform::CPUPlace, __VA_ARGS__> \ __VA_ARGS__> \
__jit_kernel_registrar_##kernel_type##_refer_CPUPlace_( \ __jit_kernel_registrar_##kernel_type##_refer_CPUPlace_( \
::paddle::operators::jitkernels::KernelType::kernel_type); \ ::paddle::operators::jit::KernelType::kernel_type); \
int TouchJitKernelReg_##kernel_type##_refer_CPUPlace_() { \ int TouchJitKernelReg_##kernel_type##_refer_CPUPlace_() { \
__jit_kernel_registrar_##kernel_type##_refer_CPUPlace_.Touch(); \ __jit_kernel_registrar_##kernel_type##_refer_CPUPlace_.Touch(); \
return 0; \ 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 // place_type: should be one of CPUPlace and GPUPlace in paddle::platform
#define REGISTER_KERNEL_MORE(kernel_type, impl_type, place_type, ...) \ #define REGISTER_KERNEL_MORE(kernel_type, impl_type, place_type, ...) \
STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE( \ STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE( \
...@@ -99,11 +99,11 @@ class JitKernelRegistrar { ...@@ -99,11 +99,11 @@ class JitKernelRegistrar {
extern int TouchJitKernelReg_##kernel_type##_refer_CPUPlace_(); \ extern int TouchJitKernelReg_##kernel_type##_refer_CPUPlace_(); \
static int __assert_##kernel_type##_##impl_type##_##place_type##_has_refer_ \ static int __assert_##kernel_type##_##impl_type##_##place_type##_has_refer_ \
UNUSED = TouchJitKernelReg_##kernel_type##_refer_CPUPlace_(); \ UNUSED = TouchJitKernelReg_##kernel_type##_refer_CPUPlace_(); \
static ::paddle::operators::jitkernels::JitKernelRegistrar< \ static ::paddle::operators::jit::JitKernelRegistrar< \
::paddle::operators::jitkernels::KernelPool, \ ::paddle::operators::jit::KernelPool, ::paddle::platform::place_type, \
::paddle::platform::place_type, __VA_ARGS__> \ __VA_ARGS__> \
__jit_kernel_registrar_##kernel_type##_##impl_type##_##place_type##_( \ __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##_() { \ int TouchJitKernelReg_##kernel_type##_##impl_type##_##place_type##_() { \
__jit_kernel_registrar_##kernel_type##_##impl_type##_##place_type##_ \ __jit_kernel_registrar_##kernel_type##_##impl_type##_##place_type##_ \
.Touch(); \ .Touch(); \
...@@ -139,6 +139,6 @@ class JitKernelRegistrar { ...@@ -139,6 +139,6 @@ class JitKernelRegistrar {
#define USE_JITKERNEL_MORE(kernel_type, impl_type) \ #define USE_JITKERNEL_MORE(kernel_type, impl_type) \
USE_KERNEL_MORE(kernel_type, impl_type, CPUPlace) USE_KERNEL_MORE(kernel_type, impl_type, CPUPlace)
} // namespace jitkernels } // namespace jit
} // namespace operators } // namespace operators
} // namespace paddle } // namespace paddle
...@@ -19,9 +19,9 @@ ...@@ -19,9 +19,9 @@
#include "gflags/gflags.h" #include "gflags/gflags.h"
#include "glog/logging.h" #include "glog/logging.h"
#include "gtest/gtest.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 // 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/place.h"
#include "paddle/fluid/platform/port.h" #include "paddle/fluid/platform/port.h"
...@@ -66,7 +66,7 @@ TEST(JitKernel, vmul) { ...@@ -66,7 +66,7 @@ TEST(JitKernel, vmul) {
using T = float; using T = float;
using PlaceType = paddle::platform::CPUPlace; using PlaceType = paddle::platform::CPUPlace;
namespace jit = paddle::operators::jitkernels; namespace jit = paddle::operators::jit;
// TODO(TJ): test more vector size // TODO(TJ): test more vector size
for (int d = 1; d < 30; ++d) { for (int d = 1; d < 30; ++d) {
auto ref = jit::GetRefer<jit::vmul, T, jit::VMulTypes<T>::func_type, auto ref = jit::GetRefer<jit::vmul, T, jit::VMulTypes<T>::func_type,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册