#ifndef CPU_REORDER_CPU_REORDER_HPP
#define CPU_REORDER_CPU_REORDER_HPP
#include <map>
#include <vector>
#include "cpu/reorder/simple_reorder.hpp"
#include "cpu/reorder/simple_sparse_reorder.hpp"
#include "common/impl_list_item.hpp"
#include "common/memory.hpp"
#include "common/type_helpers.hpp"
#include "cpu/cpu_engine.hpp"
#include "cpu/reorder/cpu_reorder_pd.hpp"
#if DNNL_X64
#include "cpu/x64/jit_uni_reorder.hpp"
#include "cpu/x64/jit_uni_reorder_direct_copy.hpp"
#include "cpu/x64/matmul/brgemm_matmul_reorders.hpp"
#elif DNNL_AARCH64
#include "cpu/aarch64/matmul/brgemm_matmul_reorders.hpp"
#include "cpu/aarch64/reorder/jit_blk_reorder.hpp"
#include "cpu/aarch64/reorder/jit_uni_reorder.hpp"
#if defined(DNNL_AARCH64_USE_ACL)
#include "cpu/aarch64/reorder/acl_reorder.hpp"
#endif
#elif DNNL_PPC64
#include "cpu/ppc64/ppc64_gemm_reorder.hpp"
#elif DNNL_RV64
#ifdef DNNL_RISCV_USE_RVV_INTRINSICS
#include "cpu/rv64/rvv_gemm_reorder.hpp"
#endif
#endif
#include "cpu/rnn/rnn_reorders.hpp"
namespace dnnl {
namespace impl {
namespace cpu {
using namespace dnnl::impl::data_type;
using namespace dnnl::impl::format_tag;
struct reorder_impl_key_t {
data_type_t src_dt;
data_type_t dst_dt; int ndims;
bool operator<(const reorder_impl_key_t &rhs) const {
return value() < rhs.value();
}
private:
size_t value() const {
const size_t dtm = data_type::data_type_max;
const size_t m1 = static_cast<size_t>(ndims) * dtm;
const size_t m2 = (m1 + static_cast<size_t>(src_dt)) * dtm;
return m2 + static_cast<size_t>(dst_dt);
}
};
using impl_list_map_t
= std::map<reorder_impl_key_t, std::vector<impl_list_item_t>>;
extern const impl_list_map_t ®ular_fp4_impl_list_map();
extern const impl_list_map_t ®ular_f32_fp8_impl_list_map();
extern const impl_list_map_t ®ular_f32_bf16_impl_list_map();
extern const impl_list_map_t ®ular_f32_f16_impl_list_map();
extern const impl_list_map_t ®ular_f32_f32_impl_list_map();
extern const impl_list_map_t ®ular_f32_s32_impl_list_map();
extern const impl_list_map_t ®ular_f32_s8_impl_list_map();
extern const impl_list_map_t ®ular_f32_u8_impl_list_map();
extern const impl_list_map_t ®ular_fp8_impl_list_map();
extern const impl_list_map_t ®ular_bf16_impl_list_map();
extern const impl_list_map_t ®ular_f16_impl_list_map();
extern const impl_list_map_t ®ular_s32_impl_list_map();
extern const impl_list_map_t ®ular_s8_impl_list_map();
extern const impl_list_map_t ®ular_u8_impl_list_map();
extern const impl_list_map_t ®ular_s4_impl_list_map();
extern const impl_list_map_t ®ular_u4_impl_list_map();
extern const impl_list_map_t &comp_f32_s8_impl_list_map();
extern const impl_list_map_t &comp_bf16_s8_impl_list_map();
extern const impl_list_map_t &comp_s8_s8_impl_list_map();
#define REG_SR(idt, ifmt, odt, ofmt, ...) \
impl_list_item_t(impl_list_item_t::reorder_type_deduction_helper_t< \
simple_reorder_t<idt, ifmt, odt, ofmt, __VA_ARGS__>::pd_t>()),
#define REG_SR_BIDIR(idt, ifmt, odt, ofmt) \
REG_SR(idt, ifmt, odt, ofmt, fmt_order::keep) \
REG_SR(idt, ifmt, odt, ofmt, fmt_order::reverse)
#define REG_SR_DIRECT_COPY(idt, odt) \
REG_SR(idt, any, odt, any, fmt_order::any, spec::direct_copy) \
REG_SR(idt, any, odt, any, fmt_order::any, spec::direct_copy_except_dim_0)
#if defined(__INTEL_COMPILER) || (defined(__GNUC__) && !defined(__clang__))
#define REG_FAST_DIRECT_COPY_F32_F32 REG_SR_DIRECT_COPY(f32, f32)
#else
#define REG_FAST_DIRECT_COPY_F32_F32
#endif
#ifdef __INTEL_COMPILER
#define REG_FAST_DIRECT_COPY(sdt, ddt) REG_SR_DIRECT_COPY(sdt, ddt)
#else
#define REG_FAST_DIRECT_COPY(sdt, ddt)
#endif
#define CPU_REORDER_INSTANCE(...) \
impl_list_item_t(impl_list_item_t::reorder_type_deduction_helper_t< \
__VA_ARGS__::pd_t>()),
} } }
#endif