text
stringlengths
0
2.2M
jcp.ngroups = with_groups ? weights_d.dims()[0] : 1;
jcp.mb = src_d.dims()[0];
jcp.oc = dst_d.dims()[1] / jcp.ngroups;
jcp.oc_without_padding = jcp.oc;
jcp.ic = src_d.dims()[1] / jcp.ngroups;
jcp.ic_without_padding = jcp.ic;
jcp.id = is_3d ? src_d.dims()[2] : 1;
jcp.ih = !is_1d ? src_d.dims()[ndims - 2] : 1;
jcp.iw = src_d.dims()[ndims - 1];
jcp.od = is_3d ? dst_d.dims()[2] : 1;
jcp.oh = !is_1d ? dst_d.dims()[ndims - 2] : 1;
jcp.ow = dst_d.dims()[ndims - 1];
jcp.kd = is_3d ? weights_d.dims()[with_groups + 2] : 1;
jcp.kh = !is_1d ? weights_d.dims()[with_groups + ndims - 2] : 1;
jcp.kw = weights_d.dims()[with_groups + ndims - 1];
jcp.f_pad = is_3d ? cd.padding[0][0] : 0;
jcp.t_pad = !is_1d ? cd.padding[0][ndims - 4] : 0;
jcp.l_pad = cd.padding[0][ndims - 3];
jcp.stride_d = is_3d ? cd.strides[0] : 1;
jcp.stride_h = !is_1d ? cd.strides[ndims - 4] : 1;
jcp.stride_w = cd.strides[ndims - 3];
jcp.with_bias = cd.bias_desc.format_kind != format_kind::undef;
if (!(jcp.kd == 1 && jcp.kh == 1 && jcp.kw == 1))
return status::unimplemented;
if (!(jcp.f_pad == 0 && jcp.t_pad == 0 && jcp.l_pad == 0))
return status::unimplemented;
jcp.dilate_d = is_3d ? cd.dilates[0] : 0;
jcp.dilate_h = is_1d ? 0 : cd.dilates[ndims - 4];
jcp.dilate_w = cd.dilates[ndims - 3];
jcp.is_depthwise = true && with_groups && everyone_is(1, jcp.ic, jcp.oc);
if (jcp.dilate_d != 0 || jcp.dilate_h != 0 || jcp.dilate_w != 0)
return status::unimplemented;
if (jcp.is_depthwise)
return status::unimplemented; // TODO: add support of DW convolution
if (jcp.ngroups > 1)
return status::unimplemented; // TODO: add support for non-unit groups
jcp.bia_dt = jcp.with_bias ? cd.bias_desc.data_type : data_type::undef;
jcp.dst_dt = cd.dst_desc.data_type;
jcp.src_dt = cd.src_desc.data_type;
jcp.wei_dt = cd.weights_desc.data_type;
const auto zp = attr.zero_points_;
jcp.dst_zero_point = !zp.has_default_values(DNNL_ARG_DST);
jcp.src_zero_point = !zp.has_default_values(DNNL_ARG_SRC);
jcp.zp_src_is_common = zp.common(
DNNL_ARG_SRC); // otherwise, it's per-channel (not supported)
if (!IMPLICATION(jcp.src_zero_point, jcp.zp_src_is_common)
|| !IMPLICATION(jcp.dst_zero_point || jcp.src_zero_point,
is_int8_convolution))
return status::unimplemented;
jcp.nthr = nthreads;
jcp.ic_block = 16;
jcp.ic_block_int = is_bf16_convolution ? 32 : 64;
jcp.ic_block_int_np = jcp.ic_block_int;
if (jcp.ic_block_int < jcp.ic_without_padding
&& jcp.ic_without_padding % jcp.ic_block_int != 0) {
// Order of blocks comes from empirical observation
static const int try_blocks[] = {32, 48, 40, 56};
for (auto blk_size : try_blocks) {
const int _blk_size = is_bf16_convolution ? blk_size / 2 : blk_size;
if (jcp.ic_without_padding % _blk_size == 0) {
jcp.ic_block_int_np = _blk_size;
break;
}
}
}
jcp.oc_block = 16;
bool args_ok = true && jcp.ic % 4 == 0
&& (jcp.ow == jcp.iw && jcp.stride_w == 1)
&& (jcp.oh == jcp.ih && jcp.stride_h == 1)
&& (jcp.od == jcp.id && jcp.stride_d == 1);
if (!args_ok) return status::unimplemented;
if (jcp.ngroups == 1) {
jcp.oc = rnd_up(jcp.oc, jcp.oc_block);
jcp.ic = rnd_up(jcp.ic, jcp.ic_block);
}
auto set_or_check_wei_format = [&]() {
using namespace format_tag;
using namespace memory_extra_flags;
format_tag_t wei_tag;
wei_tag = (is_bf16_convolution)
? pick(with_groups + 2 * (ndims - 3), OIw16i16o2i, gOIw16i16o2i,
OIhw16i16o2i, gOIhw16i16o2i, OIdhw16i16o2i,
gOIdhw16i16o2i)
: pick(with_groups + 2 * (ndims - 3), OIw16i16o4i, gOIw16i16o4i,
OIhw16i16o4i, gOIhw16i16o4i, OIdhw16i16o4i,
gOIdhw16i16o4i);
memory_desc_t want_wei_md = weights_md;
memory_desc_init_by_tag(want_wei_md, wei_tag);