text
stringlengths
0
2.2M
postops_injector_ = utils::make_unique<
injector::jit_uni_postops_injector_t<avx512_core>>(
this, jcp.post_ops, static_params);
}
}
// Tile register decomposition
int jit_avx512_core_amx_1x1_fwd_kernel_t::get_out_tensor(int h, int i) const {
return C_BASE + h * jcp.nb_os_blocking + i;
}
int jit_avx512_core_amx_1x1_fwd_kernel_t::get_inp_tensor(int h) const {
return I_BASE + h;
}
int jit_avx512_core_amx_1x1_fwd_kernel_t::get_wei_tensor(int i) const {
return W_BASE + i;
}
bool jit_avx512_core_amx_1x1_fwd_kernel_t::is_bf16() const {
return jcp.src_dt == data_type::bf16;
}
// Code generation
void jit_avx512_core_amx_1x1_fwd_kernel_t::init_runtime_counters() {
row_count_ = 0;
buf_count_ = 0;
is_store_done_ = false;
is_buffer_empty_ = true;
}
size_t jit_avx512_core_amx_1x1_fwd_kernel_t::out_h_shift() const {
return (size_t)jcp.ow * jcp.ngroups * jcp.oc_without_padding;
}
size_t jit_avx512_core_amx_1x1_fwd_kernel_t::out_w_shift() const {
return (size_t)jcp.ngroups * jcp.oc_without_padding;
}
size_t jit_avx512_core_amx_1x1_fwd_kernel_t::inp_offset(
int h, int w, int icb) const {
return (size_t)jcp.typesize_in
* (h * jcp.iw * jcp.ngroups * jcp.ic_without_padding
+ w * jcp.ngroups * jcp.ic_without_padding
+ icb * jcp.ic_block_int_np);
}
size_t jit_avx512_core_amx_1x1_fwd_kernel_t::out_row_offset(
int h, int w, int ocb) const {
return (size_t)jcp.typesize_out
* (h * jcp.ow * jcp.ngroups * jcp.oc_without_padding
+ w * jcp.ngroups * jcp.oc_without_padding
+ ocb * jcp.oc_block);
}
void jit_avx512_core_amx_1x1_fwd_kernel_t::update_buffer_pointers() {
auto buffer_offset = [=](bool shift) { return ((buf_count_ + shift) % 2); };
int wsp_shift = jcp.typesize_acc * (jcp.wsp_buffer_size / 2);
int postop_shift = wsp_shift * buffer_offset(true);
mov(reg_postop, wsp_ptr);
add(reg_postop, postop_shift);
buf_count_++;
}
void jit_avx512_core_amx_1x1_fwd_kernel_t::interleave_store() {
int scnd_dim = jcp.nb_os_blocking * jcp.tile_width;
for (int c = 0;
c < jcp.per_one_pstore && !is_store_done_ && !is_buffer_empty_;
c++) {
int ocb = (row_count_ / scnd_dim);
int osb = (row_count_ % scnd_dim) / jcp.tile_width;
int row = (row_count_ % scnd_dim) % jcp.tile_width;
const Zmm zmm_r = zmm_out(row);
int oh = ((osb * jcp.tile_width + row) / jcp.ow);
int ow = ((osb * jcp.tile_width + row) % jcp.ow);
{
// preserve registers used by binary post_ops injector
const injector_utils::conditional_register_preserve_guard_t
cond_register_guard(jcp.with_binary, this,
{bin_injector_helper_reg_1,
bin_injector_helper_reg_2});
const int wsp_row_offset = jcp.typesize_acc
* (osb * jcp.nb_oc_blocking * jcp.max_width * jcp.oc_block
+ ocb * jcp.max_width * jcp.oc_block
+ row * jcp.oc_block);
vmovups(zmm_r, ptr[reg_postop + wsp_row_offset]);
store_output_vector(zmm_r, ocb, oh, ow);
row_count_++;
}
int exp_row_count
= jcp.tile_width * jcp.nb_oc_blocking * jcp.nb_os_blocking;
if (row_count_ == exp_row_count) {