Skip to content

Commit a7922d8

Browse files
rhilkensJaccovG
authored andcommitted
[build] turn on Werror
1 parent a353acf commit a7922d8

File tree

7 files changed

+128
-110
lines changed

7 files changed

+128
-110
lines changed

lib/mli_lib.cmake

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,24 +73,32 @@ set(MLI_LIB_PRIVATE_INCLUDES
7373
${MLI_LIB_CMAKE_DIR}/src/pal
7474
)
7575

76+
set(MLI_LIB_PRIVATE_COMPILE_OPTIONS )
77+
7678
if (ARC)
77-
set(MLI_LIB_PRIVATE_COMPILE_OPTIONS
79+
list(APPEND MLI_LIB_PRIVATE_COMPILE_OPTIONS
7880
-Hnocopyr
7981
-Hpurge
8082
-Hsdata0
8183
-Hdense_prologue
84+
-tcf_core_config
85+
)
86+
endif()
87+
88+
if (ARC)
89+
list(APPEND MLI_LIB_PRIVATE_COMPILE_OPTIONS
90+
-Werror
8291
-Wall
8392
-Wno-nonportable-include-path
84-
-tcf_core_config
8593
)
8694
elseif (MSVC)
87-
set(MLI_LIB_PRIVATE_COMPILE_OPTIONS
88-
/W3
95+
list(APPEND MLI_LIB_PRIVATE_COMPILE_OPTIONS
96+
/W2
97+
/WX
8998
)
9099
else()
91-
set(MLI_LIB_PRIVATE_COMPILE_OPTIONS
100+
list(APPEND MLI_LIB_PRIVATE_COMPILE_OPTIONS
92101
-Werror
93-
-Wno-nonportable-include-path
94102
)
95103
endif()
96104

lib/src/helpers/src/impl/mli_hlp_convert_tensor_ref.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020, Synopsys, Inc.
2+
* Copyright 2020-2021, Synopsys, Inc.
33
* All rights reserved.
44
*
55
* This source code is licensed under the BSD-3-Clause license found in
@@ -176,7 +176,7 @@ mli_status convert_float_data(const mli_tensor * src, mli_tensor * dst, convert_
176176
int32_t tensor_val = mli_math_float_scale(float_tensor_arr[float_tensor_pos], scale_val);
177177
tensor_arr[tensor_pos] = mli_math_cast_fx<int32_t, t_T>(mli_math_add_fx<int32_t>(tensor_val, zero_offset), 0);
178178
} else if (mode == mli::hlp::DEQUANTIZE) {
179-
const float float_tensor_val_unscaled = static_cast<float>(mli_math_sub_fx<int32_t>(tensor_arr[tensor_pos], zero_offset));
179+
const float float_tensor_val_unscaled = static_cast<float>(mli_math_sub_fx<int32_t>((int32_t)(tensor_arr[tensor_pos]), zero_offset));
180180
float_tensor_arr[float_tensor_pos] = float_tensor_val_unscaled * scale_val;
181181
}
182182
}

lib/src/move/mli_mov_api.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "mli_api.h"
1313
#include "mli_debug.h"
1414
#include "mli_math_macros.h"
15+
#include "mli_mem_info.h"
1516
#include "mli_mov_api.h"
1617
#include "mli_mov.h"
1718
#include "mli_types.h"
@@ -107,8 +108,8 @@ mli_status mli_mov_prepare(mli_mov_handle_t* h, const mli_tensor* src, const mli
107108
int rank = dst->rank = src->rank;
108109
dst->el_type = src->el_type;
109110

110-
const bool src_in_vccm = mli_prv_is_inside_vccm(src->data.mem.void_p);
111-
const bool dst_in_vccm = mli_prv_is_inside_vccm(dst->data.mem.void_p);
111+
const bool src_in_vccm = mli_mem_is_inside_vccm(src->data.mem.void_p);
112+
const bool dst_in_vccm = mli_mem_is_inside_vccm(dst->data.mem.void_p);
112113

113114
if ((src->el_type == MLI_EL_SA_8 || src->el_type == MLI_EL_SA_32) && (src->el_params.sa.dim != -1)) {
114115
if ((dst->el_params.sa.scale.mem.pi16 != src->el_params.sa.scale.mem.pi16) &&

lib/src/pal/mli_mem_info.h

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
* Copyright 2021, Synopsys, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-3-Clause license found in
6+
* the LICENSE file in the root directory of this source tree.
7+
*
8+
*/
9+
10+
#ifndef _MLI_MEM_INFO_H_
11+
#define _MLI_MEM_INFO_H_
12+
13+
#include "mli_config.h"
14+
#include "mli_types.h"
15+
16+
#ifdef _ARC
17+
#include <arc/arc_reg.h>
18+
19+
#define SUPPORT_NON_ALIGNMENT 22
20+
#define DISABLE_ALIGNMENT_CHECK 19
21+
#endif
22+
23+
static MLI_FORCE_INLINE bool mli_mem_is_inside_dccm(const void *ptr) {
24+
#ifdef core_config_dccm_size
25+
return ((uint32_t)ptr >= core_config_dccm_base) &&
26+
((uint32_t)ptr < core_config_dccm_base + core_config_dccm_size);
27+
#else
28+
return false;
29+
#endif
30+
}
31+
32+
static MLI_FORCE_INLINE bool mli_mem_is_inside_yccm(const void *ptr) {
33+
#ifdef core_config_xy_y_base
34+
return ((uint32_t)ptr >= core_config_xy_y_base) &&
35+
((uint32_t)ptr < core_config_xy_y_base + core_config_xy_size);
36+
#else
37+
return false;
38+
#endif
39+
}
40+
41+
static MLI_FORCE_INLINE bool mli_mem_is_inside_xccm(const void *ptr) {
42+
#ifdef core_config_xy_x_base
43+
return ((uint32_t)ptr >= core_config_xy_x_base) &&
44+
((uint32_t)ptr < core_config_xy_x_base + core_config_xy_size);
45+
#else
46+
return false;
47+
#endif
48+
}
49+
50+
static MLI_FORCE_INLINE bool mli_mem_is_inside_vccm(const void *ptr) {
51+
#ifdef core_config_vec_mem_size
52+
return ((uint32_t)ptr >= core_config_vec_mem_base) &&
53+
((uint32_t)ptr < core_config_vec_mem_base + core_config_vec_mem_size);
54+
#else
55+
return false;
56+
#endif
57+
}
58+
59+
static MLI_FORCE_INLINE bool mli_mem_is_inside_ccm(const void *ptr) {
60+
return mli_mem_is_inside_dccm(ptr)
61+
|| mli_mem_is_inside_xccm(ptr)
62+
|| mli_mem_is_inside_yccm(ptr)
63+
|| mli_mem_is_inside_vccm(ptr);
64+
}
65+
66+
static MLI_FORCE_INLINE mli_status mli_mem_chk_ptr(void *p, uint32_t align_mask, bool check_bank, bool vccm_chk_bank) {
67+
#if MLI_PTR_IS_VCCM
68+
bool is_inside_vccm = mli_mem_is_inside_vccm(p);
69+
if (vccm_chk_bank && (!is_inside_vccm))
70+
return MLI_STATUS_MEM_BANK_MISMATCH;
71+
//Check the alignment if the pointer is inside the VCCM memory or the non_alignment isn't supported
72+
if (is_inside_vccm ||
73+
(((_lr(ISA_CONFIG)&(1<<SUPPORT_NON_ALIGNMENT)) == 0) || ((_lr(STATUS32)&(1<<DISABLE_ALIGNMENT_CHECK)) == 0))) {
74+
if (((uint32_t)p & align_mask) != 0)
75+
return MLI_STATUS_MISALIGNMENT_ERROR;
76+
}
77+
#endif
78+
#if MLI_PTR_IS_XY
79+
if (check_bank && (!mli_mem_is_inside_ccm(p)))
80+
return MLI_STATUS_MEM_BANK_MISMATCH;
81+
#endif
82+
#if (PLATFORM == V2DSP_XY) || ((PLATFORM == V2DSP_VECTOR) && (!MLI_PTR_IS_VCCM))
83+
if (((_lr(ISA_CONFIG)&(1<<SUPPORT_NON_ALIGNMENT)) == 0) || ((_lr(STATUS32)&(1<<DISABLE_ALIGNMENT_CHECK)) == 0)) {
84+
if (((uint32_t)p & align_mask) != 0)
85+
return MLI_STATUS_MISALIGNMENT_ERROR;
86+
}
87+
#endif
88+
return MLI_STATUS_OK;
89+
}
90+
91+
#endif // _MLI_MEM_INFO_H_

lib/src/pal/vdsp/mli_prv_dsp.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2020, Synopsys, Inc.
2+
* Copyright 2020-2021, Synopsys, Inc.
33
* All rights reserved.
44
*
55
* This source code is licensed under the BSD-3-Clause license found in
@@ -325,25 +325,25 @@ MLI_FORCE_INLINE vNx2accshort_t mli_prv_init_accu(vNx2short_t inp_val) {
325325
return vvcadd_init(inp_val, (int16_t)0);
326326
}
327327

328-
static MLI_FORCE_INLINE int32_t mli_prv_init_accu(int8_t inp_val) {
328+
static MLI_FORCE_INLINE int32_t mli_prv_init_accu(int8_t inp_val) {
329329
int32_t acc = inp_val;
330330
return acc;
331331
}
332332

333-
static MLI_FORCE_INLINE int32_t mli_prv_init_accu(int32_t inp_val) {
333+
static MLI_FORCE_INLINE int32_t mli_prv_init_accu(int32_t inp_val) {
334334
int32_t acc = inp_val;
335335
return acc;
336336
}
337337

338-
static MLI_FORCE_INLINE int32_t mli_prv_init_accu_with_bias(
338+
static MLI_FORCE_INLINE int32_t mli_prv_init_accu_with_bias(
339339
const MLI_PTR(int8_t) __restrict in,
340340
const int8_t bias,
341341
const int bias_shift) {
342342
int32_t accu = mli_math_asr_rnd_fx<int32_t>((int32_t) bias, -bias_shift);
343343
return accu;
344344
}
345345

346-
static MLI_FORCE_INLINE int32_t mli_prv_init_accu_with_bias(
346+
static MLI_FORCE_INLINE int32_t mli_prv_init_accu_with_bias(
347347
const MLI_PTR(int16_t) __restrict in,
348348
const int8_t bias,
349349
const int bias_shift) {
@@ -377,6 +377,15 @@ MLI_FORCE_INLINE vNx2accint_t mli_prv_init_accu_with_bias_v(
377377
return mli_math_asl_fx(r, bias_shift);
378378
}
379379

380+
template<>
381+
MLI_FORCE_INLINE mli_acc32_t mli_prv_init_accu_with_bias_v(
382+
const int16_t bias,
383+
const int bias_shift) {
384+
385+
mli_acc32_t r = bias;
386+
return mli_math_asl_fx(r, bias_shift);
387+
}
388+
380389
template<>
381390
MLI_FORCE_INLINE mli_acc40_t mli_prv_init_accu_with_bias_v(
382391
const int16_t bias,
@@ -385,6 +394,7 @@ MLI_FORCE_INLINE mli_acc40_t mli_prv_init_accu_with_bias_v(
385394
mli_acc40_t r = bias;
386395
return mli_math_asl_fx(r, bias_shift);
387396
}
397+
388398
// Multiply and accumulate for vectors of 1, 2, and 4 elements
389399
//=========================================================================
390400
// Note:

lib/src/private/mli_prv_tensor.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,12 +1006,4 @@ mli_prv_get_relu_limits (const mli_relu_cfg * cfg, const mli_tensor * out) {
10061006
return val_limit;
10071007
}
10081008

1009-
static MLI_FORCE_INLINE bool mli_prv_is_inside_vccm (const void *ptr) {
1010-
#if core_config_vec_mem_size
1011-
return ((uint32_t)ptr >= core_config_vec_mem_base) &&
1012-
((uint32_t)ptr < core_config_vec_mem_base + core_config_vec_mem_size);
1013-
#else
1014-
return false;
1015-
#endif
1016-
}
10171009
#endif //_MLI_PRV_TENSOR_H_

lib/src/private/src/mli_check.cc

Lines changed: 3 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -17,85 +17,14 @@
1717
#include "mli_helpers_api.h"
1818
#include "mli_math.h"
1919
#include "mli_math_macros.h"
20+
#include "mli_mem_info.h"
2021
#include "mli_prv_activation_lut.h"
2122
#include "mli_prv_tensor.h"
2223
#include "mli_types.h"
2324

24-
#if _ARC
25-
#include <arc/arc_reg.h>
26-
#endif
2725
#pragma MLI_CODE_SECTION_START(".mli_lib")
28-
#define SUPPORT_NON_ALIGNMENT 22
29-
#define DISABLE_ALIGNMENT_CHECK 19
30-
31-
32-
#if core_config_dccm_size
33-
static MLI_FORCE_INLINE bool mli_chk_inside_dccm (const void *ptr) {
34-
return ((uint32_t)ptr >= core_config_dccm_base) &&
35-
((uint32_t)ptr < core_config_dccm_base + core_config_dccm_size);
36-
}
37-
#endif
38-
39-
#if core_config_xy_size
40-
static MLI_FORCE_INLINE bool mli_chk_inside_yccm (const void *ptr) {
41-
#ifdef core_config_xy_y_base
42-
return ((uint32_t)ptr >= core_config_xy_y_base) &&
43-
((uint32_t)ptr < core_config_xy_y_base + core_config_xy_size);
44-
#else
45-
return false;
46-
#endif
47-
}
4826

49-
static MLI_FORCE_INLINE bool mli_chk_inside_xccm (const void *ptr) {
50-
#ifdef core_config_xy_x_base
51-
return ((uint32_t)ptr >= core_config_xy_x_base) &&
52-
((uint32_t)ptr < core_config_xy_x_base + core_config_xy_size);
53-
#else
54-
return false;
55-
#endif
56-
}
57-
#endif
58-
59-
#if core_config_xy_size || core_config_dccm_size
60-
static MLI_FORCE_INLINE bool mli_chk_inside_ccm (const void *ptr) {
61-
#if core_config_xy_size
62-
if (mli_chk_inside_xccm(ptr) || mli_chk_inside_yccm(ptr)) {
63-
return true;
64-
}
65-
#endif
66-
#if core_config_dccm_size
67-
if (mli_chk_inside_dccm(ptr)) {
68-
return true;
69-
}
70-
#endif
71-
return false;
72-
}
73-
#endif
7427

75-
static MLI_FORCE_INLINE mli_status mli_chk_ptr(void *p, uint32_t align_mask, bool check_bank, bool vccm_chk_bank) {
76-
#if MLI_PTR_IS_VCCM
77-
bool is_inside_vccm = mli_prv_is_inside_vccm(p);
78-
if (vccm_chk_bank && (!is_inside_vccm))
79-
return MLI_STATUS_MEM_BANK_MISMATCH;
80-
//Check the alignment if the pointer is inside the VCCM memory or the non_alignment isn't supported
81-
if (is_inside_vccm ||
82-
(((_lr(ISA_CONFIG)&(1<<SUPPORT_NON_ALIGNMENT)) == 0) || ((_lr(STATUS32)&(1<<DISABLE_ALIGNMENT_CHECK)) == 0))) {
83-
if (((uint32_t)p & align_mask) != 0)
84-
return MLI_STATUS_MISALIGNMENT_ERROR;
85-
}
86-
#endif
87-
#if MLI_PTR_IS_XY
88-
if (check_bank && (!mli_chk_inside_ccm(p)))
89-
return MLI_STATUS_MEM_BANK_MISMATCH;
90-
#endif
91-
#if (PLATFORM == V2DSP_XY) || ((PLATFORM == V2DSP_VECTOR) && (!MLI_PTR_IS_VCCM))
92-
if (((_lr(ISA_CONFIG)&(1<<SUPPORT_NON_ALIGNMENT)) == 0) || ((_lr(STATUS32)&(1<<DISABLE_ALIGNMENT_CHECK)) == 0)) {
93-
if (((uint32_t)p & align_mask) != 0)
94-
return MLI_STATUS_MISALIGNMENT_ERROR;
95-
}
96-
#endif
97-
return MLI_STATUS_OK;
98-
}
9928
// vccm_chk_bank will be false for the APIs that does't require the tensor to be in VCCM like data Movement API.
10029
template <bool vccm_chk_bank = true>
10130
/*check_bank checks whether the tensor buffer have to be allocated in ccm memory or not and its value will be:
@@ -106,7 +35,7 @@ static MLI_FORCE_INLINE mli_status mli_mem_chk(const mli_tensor *t, bool check_b
10635
#if (PLATFORM == V2DSP_XY) || (PLATFORM == V2DSP_VECTOR)
10736
void *p = t->data.mem.void_p;
10837
uint32_t align_mask = mli_hlp_tensor_element_size(t) - 1;
109-
return mli_chk_ptr(p, align_mask, check_bank, vccm_chk_bank);
38+
return mli_mem_chk_ptr(p, align_mask, check_bank, vccm_chk_bank);
11039
#else
11140
return MLI_STATUS_OK;
11241
#endif
@@ -163,7 +92,7 @@ mli_status mli_chk_lut(const mli_lut * lut, int buff_size) {
16392
mli_tensor dummy = { .el_type = lut->type };
16493
uint32_t align_mask = mli_hlp_tensor_element_size(&dummy) - 1;
16594

166-
mli_status ret = mli_chk_ptr(p, align_mask, true, true);
95+
mli_status ret = mli_mem_chk_ptr(p, align_mask, true, true);
16796
return ret;
16897
#else
16998
return MLI_STATUS_OK;
@@ -416,19 +345,6 @@ static MLI_FORCE_INLINE bool check_quantized_on_tensor(const mli_tensor *t1, con
416345
return !fail;
417346
}
418347

419-
/* This function returns maximum value can be stored in tensor according to its type */
420-
static MLI_FORCE_INLINE const uint32_t mli_hlp_tensor_element_positive_limit(const mli_tensor *in) {
421-
switch (in->el_type) {
422-
case MLI_EL_FX_8: return (uint32_t)mli_math_limit_fx<int8_t>(1);
423-
case MLI_EL_SA_8: return (uint32_t)mli_math_limit_fx<int8_t>(1);
424-
case MLI_EL_FX_16: return (uint32_t)mli_math_limit_fx<int16_t>(1);
425-
case MLI_EL_SA_32: return (uint32_t)mli_math_limit_fx<int32_t>(1);
426-
default:
427-
MLI_ASSERT(0);
428-
return 0;
429-
}
430-
}
431-
432348
/******************************************************
433349
* mli_krn_conv2d_hwc parameters checking function
434350
******************************************************/

0 commit comments

Comments
 (0)