text
stringlengths
0
2.2M
/*******************************************************************************
* Copyright 2019-2021 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain src copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
#include "dnnl_test_common.hpp"
#include "gtest/gtest.h"
#include "oneapi/dnnl/dnnl.hpp"
#include <vector>
namespace dnnl {
namespace P {
// Common
unsigned NONE = 0u;
unsigned RUNTIME = 1u << 31;
unsigned SCALES = 1u << 30;
unsigned ZERO_POINTS = 1u << 29;
unsigned LEADING_DIM = 1u << 28;
// matrices indices: 1 .. 7
// bits reserved: 20 .. 22
unsigned MATRIX_MASK = 7u << 20;
unsigned SRC = 1u << 20;
unsigned WEIGHTS = 2u << 20;
unsigned DST = 3u << 20;
// scales and zero points: 1 .. 3
// bits reserved: 0 .. 1
unsigned MASK_MASK = 3u << 0;
unsigned COMMON = 1u << 0;
unsigned PER_N = 1u << 1;
} // namespace P
struct matmul_base_t {
struct md_t {
memory::dims dims;
memory::data_type dt;
memory::format_tag tag;
unsigned flags;
} src, weights, dst;
memory::data_type bia_dt;
};
// TODO: src way to generalize?
struct matmul_attr_t {
// ctor {P::SCALE, {P::SRC, P::WEIGHTS, P::DST}, {P::POST_OPS, ...}}
unsigned scale_flags;
struct zero_points_t {
unsigned src, weights, dst;
} zero_points;
struct post_op_t {
primitive::kind kind;
algorithm alg;
};
std::vector<post_op_t> post_ops;
};
struct matmul_test_params_t {
matmul_base_t base;
matmul_attr_t attr;
bool expect_to_fail;
dnnl_status_t expected_status;
};
using tag = memory::format_tag;
class matmul_iface_test_t
: public ::testing::TestWithParam<matmul_test_params_t> {
protected:
void SetUp() override {
matmul_test_params_t p
= ::testing::TestWithParam<decltype(p)>::GetParam();
SKIP_IF(unsupported_data_type(p.base.src.dt),
"Engine does not support this data type.");
SKIP_IF(unsupported_data_type(p.base.weights.dt),
"Engine does not support this data type.");
SKIP_IF(unsupported_data_type(p.base.dst.dt),