1 /*******************************************************************************
2 * Copyright 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 *******************************************************************************/
23 #include "mkldnn_common.hpp"
30 * arrays: SRC, WEI, BIA, DST, ACC
31 * params: {data_type, min, max, f_min, f_max, f_base, f_step, f_sparsity, eps}
34 const int int_max_exact = 1<<24;
35 const _dt_conf_t conf_f32 = {
36 {mkldnn_f32, -int_max_exact, int_max_exact, -32, 32, 0, 1, .35, 0.},
37 {mkldnn_f32, -int_max_exact, int_max_exact, -32, 32, 0, 1, 1.0, 0.},
38 {mkldnn_f32, -int_max_exact, int_max_exact, -512, 512, 0, 1, 1.0, 0.},
39 {mkldnn_f32, -int_max_exact, int_max_exact, -32, 32, 0, 1, .35, 0.},
43 const _dt_conf_t conf_s16s16s32s32 = {
44 {mkldnn_s16, INT16_MIN, INT16_MAX, -4, 4, 0, 1, .35, 0.},
45 {mkldnn_s16, INT16_MIN, INT16_MAX, -5, 5, 0, 1, .35, 0.},
46 {mkldnn_s32, INT32_MIN, INT32_MAX, -8, 32, 0, 1, .35, 0.},
47 {mkldnn_s32, INT32_MIN, INT32_MAX, -4, 4, 0, 1, .35, 0.},
51 const _dt_conf_t conf_u8s8f32s32 = {
52 {mkldnn_u8, 0, UINT8_MAX, 0, 8, 0, 1, .35, 0.},
53 {mkldnn_s8, INT8_MIN, INT8_MAX, -5, 5, 0, 1, .35, 0.},
54 {mkldnn_f32, -int_max_exact, int_max_exact, -8, 32, 0, 1, .35, 0.},
55 {mkldnn_f32, -int_max_exact, int_max_exact, -255, 255, 0, 1, .35, 0.},
59 const _dt_conf_t conf_u8s8s32s32 = {
60 {mkldnn_u8, 0, UINT8_MAX, 0, 8, 0, 1, .35, 0.},
61 {mkldnn_s8, INT8_MIN, INT8_MAX, -5, 5, 0, 1, .35, 0.},
62 {mkldnn_f32, -int_max_exact, int_max_exact, -8, 32, 0, 1, .35, 0.},
63 {mkldnn_s32, INT32_MIN, INT32_MAX, -255, 255, 0, 1, .35, 0.},
67 const _dt_conf_t conf_u8s8s8s32 = {
68 {mkldnn_u8, 0, UINT8_MAX, 0, 8, 0, 1, .35, 0.},
69 {mkldnn_s8, INT8_MIN, INT8_MAX, -5, 5, 0, 1, .35, 0.},
70 {mkldnn_f32, -int_max_exact, int_max_exact, -8, 32, 0, 1, .35, 0.},
71 {mkldnn_s8, INT8_MIN, INT8_MAX, -127, 127, 0, 1, .35, 0.},
75 const _dt_conf_t conf_u8s8u8s32 = {
76 {mkldnn_u8, 0, UINT8_MAX, 0, 8, 0, 1, .35, 0.},
77 {mkldnn_s8, INT8_MIN, INT8_MAX, -5, 5, 0, 1, .35, 0.},
78 {mkldnn_f32, -int_max_exact, int_max_exact, -8, 32, 0, 1, .35, 0.},
79 {mkldnn_u8, 0, UINT8_MAX, 0, 255, 0, 1, .35, 0.},
83 const _dt_conf_t conf_s8s8f32s32 = {
84 {mkldnn_s8, INT8_MIN, INT8_MAX, -5, 5, 0, 1, .35, 0.},
85 {mkldnn_s8, INT8_MIN, INT8_MAX, -5, 5, 0, 1, .35, 0.},
86 {mkldnn_f32, -int_max_exact, int_max_exact, -8, 32, 0, 1, .35, 0.},
87 {mkldnn_f32, -int_max_exact, int_max_exact, -255, 255, 0, 1, .35, 0.},
91 const _dt_conf_t conf_s8s8s32s32 = {
92 {mkldnn_s8, INT8_MIN, INT8_MAX, -5, 5, 0, 1, .35, 0.},
93 {mkldnn_s8, INT8_MIN, INT8_MAX, -5, 5, 0, 1, .35, 0.},
94 {mkldnn_f32, -int_max_exact, int_max_exact, -8, 32, 0, 1, .35, 0.},
95 {mkldnn_s32, INT32_MIN, INT32_MAX, -255, 255, 0, 1, .35, 0.},
99 const _dt_conf_t conf_s8s8s8s32 = {
100 {mkldnn_s8, INT8_MIN, INT8_MAX, -5, 5, 0, 1, .35, 0.},
101 {mkldnn_s8, INT8_MIN, INT8_MAX, -5, 5, 0, 1, .35, 0.},
102 {mkldnn_f32, -int_max_exact, int_max_exact, -8, 32, 0, 1, .35, 0.},
103 {mkldnn_s8, INT8_MIN, INT8_MAX, -127, 127, 0, 1, .35, 0.},
107 const _dt_conf_t conf_s8s8u8s32 = {
108 {mkldnn_s8, INT8_MIN, INT8_MAX, -5, 5, 0, 1, .35, 0.},
109 {mkldnn_s8, INT8_MIN, INT8_MAX, -5, 5, 0, 1, .35, 0.},
110 {mkldnn_f32, -int_max_exact, int_max_exact, -8, 32, 0, 1, .35, 0.},
111 {mkldnn_u8, 0, UINT8_MAX, 0, 255, 0, 1, .35, 0.},
115 const dt_conf_t *str2cfg(const char *str) {
117 if (!strcasecmp(STRINGIFY(cfg), str)) return CONCAT2(conf_,cfg)
129 []() { SAFE(FAIL, CRIT); return 0; }();
130 return (const dt_conf_t *)1;
133 const char *cfg2str(const dt_conf_t *cfg) {
134 #define CASE(_cfg) if (cfg == CONCAT2(conf_,_cfg)) return STRINGIFY(_cfg)
146 []() { SAFE(FAIL, CRIT); return 0; }();