Publishing R3
[platform/upstream/dldt.git] / inference-engine / thirdparty / mkl-dnn / tests / benchdnn / reorder / input_reorder.hpp
1 /*******************************************************************************
2 * Copyright 2017-2018 Intel Corporation
3 *
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
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
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 *******************************************************************************/
16
17 #ifndef _INPUT_REORDER_HPP
18 #define _INPUT_REORDER_HPP
19
20 #include "mkldnn_common.hpp"
21 #include "reorder/reorder.hpp"
22
23 #define MASK_SUPPORTED 1
24 #define SCALE_SUPPORTED 1
25
26 #if SCALE_SUPPORTED
27     const float default_scales[] = {0.125, 0.25, 0.5, 1, 2, 4, 8};
28 #else
29     const float default_scales[] = {1};
30 #endif
31
32 const int int_max_exact = 1<<24;
33
34 const reorder::dt_conf_t conf_f32 = {mkldnn_f32, -int_max_exact, 2*int_max_exact};
35 const reorder::dt_conf_t conf_s8 = {mkldnn_s8, INT8_MIN, -2*INT8_MIN};
36 const reorder::dt_conf_t conf_u8 = {mkldnn_u8, 0, UINT8_MAX};
37 const reorder::dt_conf_t conf_s16 = {mkldnn_s16, INT16_MIN, -2*INT16_MIN};
38 const reorder::dt_conf_t conf_s32 = {mkldnn_s32, -int_max_exact, 2*int_max_exact};
39
40 static reorder::reorder_conf_t reorders[] = {
41     /* ndims, dims, fmt_in, fmt_out */
42     {4, {2, 64, 13, 13}, mkldnn_nchw, mkldnn_nchw},
43     {4, {2, 64, 13, 13}, mkldnn_nChw8c, mkldnn_nhwc},
44     {4, {2, 64, 13, 13}, mkldnn_nhwc, mkldnn_nChw8c},
45     {4, {2, 64, 13, 13}, mkldnn_nChw16c, mkldnn_nhwc},
46     {4, {2, 64, 13, 13}, mkldnn_nhwc, mkldnn_nChw16c},
47     {4, {2, 64, 13, 13}, mkldnn_nchw, mkldnn_nhwc},
48     {4, {2, 64, 13, 13}, mkldnn_nhwc, mkldnn_nchw},
49     {4, {2, 64, 13, 13}, mkldnn_oihw, mkldnn_oihw},
50     {4, {2, 64, 13, 13}, mkldnn_hwio, mkldnn_oihw},
51 };
52
53 static reorder::q10n_conf_t q10ns[] = {
54     /* dt_{in,out}, conf, rmode, policy, scale */
55     /* f32 <-> f32 */
56     { conf_f32, conf_f32, attr_t::round_mode_t::NEAREST,
57         attr_t::scale_t::policy_t::COMMON},
58     /* u8 <-> u8 */
59     { conf_u8, conf_u8, attr_t::round_mode_t::NEAREST,
60         attr_t::scale_t::policy_t::COMMON},
61     /* s8 <-> s8 */
62     { conf_s8, conf_s8, attr_t::round_mode_t::NEAREST,
63         attr_t::scale_t::policy_t::COMMON},
64     /* s32 <-> s32 */
65     { conf_s32, conf_s32, attr_t::round_mode_t::NEAREST,
66         attr_t::scale_t::policy_t::COMMON},
67     /* s8 <-> u8 */
68     { conf_s8, conf_u8, attr_t::round_mode_t::NEAREST,
69         attr_t::scale_t::policy_t::COMMON},
70     { conf_u8, conf_s8, attr_t::round_mode_t::NEAREST,
71         attr_t::scale_t::policy_t::COMMON},
72     /* f32 <-> s32 */
73     { conf_f32, conf_s32, attr_t::round_mode_t::NEAREST,
74         attr_t::scale_t::policy_t::COMMON},
75     { conf_f32, conf_s32, attr_t::round_mode_t::DOWN,
76         attr_t::scale_t::policy_t::COMMON},
77     { conf_s32, conf_f32, attr_t::round_mode_t::NEAREST,
78         attr_t::scale_t::policy_t::COMMON},
79     /* f32 <-> s8 */
80     { conf_f32, conf_s8, attr_t::round_mode_t::NEAREST,
81         attr_t::scale_t::policy_t::COMMON},
82     { conf_s8, conf_f32, attr_t::round_mode_t::NEAREST,
83         attr_t::scale_t::policy_t::COMMON},
84     /* f32 <-> u8 */
85     { conf_f32, conf_u8, attr_t::round_mode_t::NEAREST,
86         attr_t::scale_t::policy_t::COMMON},
87     { conf_u8, conf_f32, attr_t::round_mode_t::NEAREST,
88         attr_t::scale_t::policy_t::COMMON},
89     /* s32 <-> s8 */
90     { conf_s32, conf_s8, attr_t::round_mode_t::NEAREST,
91         attr_t::scale_t::policy_t::COMMON},
92     { conf_s8, conf_s32, attr_t::round_mode_t::NEAREST,
93         attr_t::scale_t::policy_t::COMMON},
94     /* s32 <-> u8 */
95     { conf_s32, conf_u8, attr_t::round_mode_t::NEAREST,
96         attr_t::scale_t::policy_t::COMMON},
97     { conf_u8, conf_s32, attr_t::round_mode_t::NEAREST,
98         attr_t::scale_t::policy_t::COMMON},
99
100 #if MASK_SUPPORTED
101     { conf_f32, conf_f32, attr_t::round_mode_t::NEAREST,
102         attr_t::scale_t::policy_t::PER_OC},
103     { conf_s8, conf_f32, attr_t::round_mode_t::NEAREST,
104         attr_t::scale_t::policy_t::PER_OC},
105 #endif
106 };
107
108 #endif