1 /*******************************************************************************
2 * Copyright 2017-2018 Intel Corporation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *******************************************************************************/
25 #include "dnn_types.hpp"
26 #include "mkldnn_common.hpp"
27 #include "mkldnn_memory.hpp"
31 using dims_t = std::vector<ptrdiff_t>;
34 mkldnn_data_type_t dt;
38 typedef const dt_conf_s *dt_conf_t;
40 struct reorder_conf_t {
42 mkldnn_memory_format_t fmt_in, fmt_out;
49 attr_t::round_mode_t irmode;
50 attr_t::scale_t::policy_t policy;
55 prb_t(const reorder_conf_t &r, const dt_conf_t &conf_in,
56 const dt_conf_t &conf_out, const attr_t &attr, float scale = 0.f)
57 : reorder(r), conf_in(conf_in), conf_out(conf_out), attr(attr) {
58 if (scale != 0.f) this->attr.oscale.scale = scale;
61 const reorder_conf_t reorder;
67 extern const char *perf_template; /* performance output template */
69 extern const dt_conf_t conf_f32;
70 extern const dt_conf_t conf_s8;
71 extern const dt_conf_t conf_u8;
72 extern const dt_conf_t conf_s16;
73 extern const dt_conf_t conf_s32;
74 dt_conf_t dt2cfg(mkldnn_data_type_t dt);
75 mkldnn_data_type_t cfg2dt(dt_conf_t cfg);
77 const size_t max_dims_len = 20;
78 const size_t max_prb_len = 392;
79 dims_t str2dims(const char *str);
80 void dims2str(const dims_t &dims, char *buffer);
81 void prb2str(const prb_t *p, const res_t *res, char *buffer);
82 void perf_report(const prb_t *p, const res_t *r, const char *pstr);
84 inline size_t data_off_f(const prb_t *p, int mb, int ic, int ih, int iw) {
85 const auto &dims = p->reorder.dims;
86 return ((mb * dims[1] + ic) * dims[2] + ih) * dims[3] + iw;
89 int doit(const prb_t *p, res_t *res);
90 int bench(int argc, char **argv, bool main_bench = true);