text
stringlengths
0
2.2M
"Engine does not support this data type.");
SKIP_IF(unsupported_data_type(p.base.bia_dt),
"Engine does not support this data type.");
SKIP_IF(get_test_engine_kind() == engine::kind::gpu
&& ((p.attr.zero_points.src & P::PER_N)
|| (p.attr.zero_points.dst & P::PER_N)),
"Per dimensional zero points are not supported on GPU");
SKIP_IF(get_test_engine_kind() == engine::kind::cpu
&& p.base.src.tag == impl::format_tag::AB8a4b,
"Don't test blocked formats on CPU");
SKIP_IF_CUDA((p.attr.zero_points.src != 0 || p.attr.zero_points.dst != 0
|| p.attr.zero_points.weights != 0),
"Zero points not supported for CUDA");
SKIP_IF_CUDA((p.attr.scale_flags & P::MASK_MASK) == P::PER_N,
"Per dimensional scaling is not supported for CUDA");
catch_expected_failures(
[=]() { Test(); }, p.expect_to_fail, p.expected_status, false);
}
// use `force_no_rt = true` when create final memory
static memory::desc init_md(
const matmul_base_t::md_t &desc, bool force_no_rt = false) {
const bool runtime = force_no_rt ? false : (desc.flags & P::RUNTIME);
const bool use_ld = (desc.flags & P::LEADING_DIM);
memory::dims dims = desc.dims;
if (runtime)
dims = memory::dims(desc.dims.size(), DNNL_RUNTIME_DIM_VAL);
if (runtime || use_ld == false)
return memory::desc(dims, desc.dt, desc.tag);
memory::dims strides;
switch (desc.tag) {
case tag::ab: strides = {dims[1] + 1, 1}; break;
case tag::ba: strides = {1, dims[0] + 1}; break;
case tag::abc:
strides = {dims[1] * (dims[2] + 1) + 1, dims[2] + 1, 1};
break;
case tag::acb:
strides = {dims[1] * (dims[2] + 1) + 1, dims[2] + 1, 1};
break;
default:
throw std::invalid_argument("tag doesn't support custom ld");
}
return memory::desc(dims, desc.dt, strides);
}
static void create_attr(const matmul_test_params_t &p, primitive_attr &attr,
memory &scales_m, memory &zero_points_src_m,
memory &zero_points_weights_m, memory &zero_points_dst_m,
engine &eng) {
const int ndims = (int)p.base.dst.dims.size();
// output scales
if (p.attr.scale_flags != P::NONE) {
ASSERT_TRUE(p.attr.scale_flags & P::SCALES);
unsigned scales_mask = p.attr.scale_flags & P::MASK_MASK;
ASSERT_TRUE(scales_mask == P::COMMON || scales_mask == P::PER_N);
int mask = scales_mask == P::PER_N ? 1 << (ndims - 1) : 0;
memory::dim scale_size = mask ? p.base.dst.dims[ndims - 1] : 1;
if (p.attr.scale_flags & P::RUNTIME) {
attr.set_output_scales(mask, {DNNL_RUNTIME_F32_VAL});
scales_m = test::make_memory(
{{scale_size}, memory::data_type::f32, {1}}, eng);
auto s = map_memory<float>(scales_m);
GTEST_EXPECT_NE(s, nullptr);
for (memory::dim i = 0; i < scale_size; ++i)
s[i] = 2.f;
} else {
std::vector<float> scales(scale_size, 2.f);
attr.set_output_scales(mask, scales);
}
}
// zero points
auto handle_zero_points = [&](int arg, unsigned flags,
const matmul_base_t::md_t &md,
memory &zero_points_m) {
if (flags == P::NONE) return;
ASSERT_TRUE(flags & P::ZERO_POINTS);
ASSERT_TRUE(flags & P::MATRIX_MASK);
// sanity check
switch (arg) {
case DNNL_ARG_SRC:
ASSERT_TRUE((flags & P::MATRIX_MASK) == P::SRC);
break;
case DNNL_ARG_WEIGHTS:
ASSERT_TRUE((flags & P::MATRIX_MASK) == P::WEIGHTS);
break;