text
stringlengths
0
2.2M
if (jcp.src_zero_point) {
want_wei_md.extra.flags |= compensation_conv_asymmetric_src;
want_wei_md.extra.asymm_compensation_mask = (1 << 0)
+ (with_groups && !jcp.is_depthwise ? (1 << 1) : 0);
}
if (weights_md.format_kind == format_kind::any) {
weights_md = want_wei_md;
return true;
}
return weights_md == want_wei_md;
};
if (!set_or_check_wei_format()) { return status::unimplemented; }
format_tag_t dat_tag = utils::pick(
ndims - 3, format_tag::nwc, format_tag::nhwc, format_tag::ndhwc);
if (src_d.format_kind() == format_kind::any) {
CHECK(memory_desc_init_by_tag(src_md, dat_tag));
jcp.src_tag = dat_tag;
} else {
jcp.src_tag = src_d.matches_one_of_tag(dat_tag);
}
if (jcp.src_tag != dat_tag) { return status::unimplemented; }
if (dst_d.format_kind() == format_kind::any) {
CHECK(memory_desc_init_by_tag(dst_md, dat_tag));
jcp.dst_tag = dat_tag;
} else {
jcp.dst_tag = dst_d.matches_one_of_tag(dat_tag);
}
if (jcp.dst_tag != dat_tag) { return status::unimplemented; }
if (jcp.with_bias) {
if (bias_d.format_kind() == format_kind::any)
CHECK(memory_desc_init_by_tag(bias_md, format_tag::x));
}
CHECK(attr.set_default_formats(&dst_md));
const auto &p = attr.post_ops_;
const int sum_ind = p.find(primitive_kind::sum);
jcp.with_sum = sum_ind != -1;
const int eltwise_ind = p.find(primitive_kind::eltwise);
jcp.with_eltwise = eltwise_ind != -1;
const int binary_ind = p.find(primitive_kind::binary);
jcp.with_binary = binary_ind != -1;
jcp.sum_dt = p.get_sum_dt(jcp.dst_dt);
jcp.post_ops = p;
jcp.is_fast_postops = is_fast_postops(jcp);
using namespace injector;
const bool sum_at_pos_0_only = (jcp.src_dt == data_type::bf16);
const bool sum_requires_scale_one = sum_at_pos_0_only;
const bool sum_requires_zp_zero = sum_at_pos_0_only;
const bool post_ops_ok_ = post_ops_ok({avx512_core, {eltwise, binary, sum},
jcp.post_ops, &dst_d, sum_at_pos_0_only, sum_requires_scale_one,
sum_requires_zp_zero});
if (!post_ops_ok_) return status::unimplemented;
jcp.typesize_in = types::data_type_size(src_d.data_type());
jcp.typesize_out = types::data_type_size(dst_d.data_type());
jcp.typesize_bia
= jcp.with_bias ? types::data_type_size(bias_d.data_type()) : 0;
jcp.typesize_acc = sizeof(int32_t);
jcp.nb_ic = jcp.ic / jcp.ic_block;
jcp.nb_oc = jcp.oc / jcp.oc_block;
jcp.nb_ic_int = div_up(jcp.ic_without_padding, jcp.ic_block_int_np);
jcp.max_width = amx::get_max_rows(amx::get_max_palette());
if (jcp.max_width <= 0) return status::unimplemented;
const int size_treshold = 32;
const int min_width
= 1; // TODO: Possible optimizations: do not use small values
const int spatial = jcp.od * jcp.oh;
const int os = jcp.od * jcp.oh * jcp.ow;
jcp.tile_width = 1;
for (int s_size = jcp.max_width; s_size >= min_width; s_size--) {
if ((spatial >= size_treshold && spatial % s_size == 0)
|| (spatial < size_treshold && os % s_size == 0)) {
jcp.tile_width = s_size;
break;
}
}
if (jcp.tile_width == 1) {
jcp.tile_width = nstl::min(jcp.max_width, os);
jcp.tile_tail = os % jcp.max_width;
for (int i = jcp.max_width; i >= min_width; i--) {
int i_tail = os % i;
if (i_tail > jcp.tile_tail || i_tail == 0) {
jcp.tile_width = i;
jcp.tile_tail = i_tail;
if (i_tail == 0) break;
}