Skip to content

Commit 09ae9b7

Browse files
committed
Allow to disable "static"
Not supported on all platforms/ports. Specifically the mpy_ld.py linker for MicroPython dynamic native modules Fixes #75
1 parent 3ec1917 commit 09ae9b7

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

include/tinymaix.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ limitations under the License.
2626
#define TM_MDL_FP8_152 5 //experimental
2727
#include "tm_port.h"
2828

29+
#ifndef TM_STATIC
30+
// Set default value, if not defined in tm_port.h
31+
#define TM_STATIC static
32+
#endif
33+
2934
/******************************* MARCO ************************************/
3035
#define TM_MDL_MAGIC 'XIAM' //mdl magic sign
3136
#define TM_ALIGN_SIZE (8) //8 byte align

src/arch_rv64v.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ TM_INLINE void tm_dot_prod_3x3x1(mtype_t* sptr, mtype_t* kptr, sumtype_t* result
279279
//Vector Widening Integer Multiply-Add Operations
280280
// vint32m4_t vwmacc_vv_i32m4 (vint32m4_t vd, vint16m2_t vs1, vint16m2_t vs2, size_t vl);
281281
uint32_t tdot = 0;
282-
static uint32_t size0=0;
282+
TM_STATIC uint32_t size0=0;
283283
TM_INLINE void tm_dot_prod(mtype_t* sptr, mtype_t* kptr,uint32_t size, sumtype_t* result)
284284
{
285285
int32_t sumbuf[PACK_N];

src/tm_layers.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@ TM_PERF_REG(t_valid); TM_PERF_REG(t_pad);
4242
TM_PERF_REG(t_conv); TM_PERF_REG(t_pwconv); TM_PERF_REG(t_dwconv);
4343

4444
/*************************** TML_CONV2D **********************************/
45-
static uint32_t k_oft[TM_MAX_KSIZE];
46-
static mtype_t sbuf[TM_MAX_KCSIZE];
45+
TM_STATIC uint32_t k_oft[TM_MAX_KSIZE];
46+
TM_STATIC mtype_t sbuf[TM_MAX_KCSIZE];
4747
#if (TM_MDL_TYPE==TM_MDL_FP32) || (TM_MDL_TYPE==TM_MDL_FP16)
4848
#define SUMSCALE NULL
4949
#define OUTSCALE outscale
5050

5151
#elif (TM_MDL_TYPE==TM_MDL_INT8) || (TM_MDL_TYPE==TM_MDL_INT16)
5252

5353
#if TM_FASTSCALE
54-
static int32_t sumscale[TM_MAX_CSIZE];
54+
TM_STATIC int32_t sumscale[TM_MAX_CSIZE];
5555
#define OUTSCALE outscale
5656
#else
57-
static float sumscale[TM_MAX_CSIZE];
57+
TM_STATIC float sumscale[TM_MAX_CSIZE];
5858
#define OUTSCALE outscale_inv
5959
#endif
6060
#define SUMSCALE (sumscale + c)

src/tm_layers_O1.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,23 @@ TM_PERF_REG(t_conv); TM_PERF_REG(t_pwconv); TM_PERF_REG(t_dwconv);
5252

5353
#define BATCH_SIZE 8 //batch sum size
5454
/*************************** TML_CONV2D **********************************/
55-
static uint32_t k_oft[TM_MAX_KSIZE];
56-
static mtype_t sbuf[TM_MAX_KCSIZE];
55+
TM_STATIC uint32_t k_oft[TM_MAX_KSIZE];
56+
TM_STATIC mtype_t sbuf[TM_MAX_KCSIZE];
5757
#if (TM_MDL_TYPE==TM_MDL_FP32) || (TM_MDL_TYPE==TM_MDL_FP16)
5858
#define SUMSCALE NULL
59-
static sctype_t outscale;
59+
TM_STATIC sctype_t outscale;
6060
#define OUTSCALE outscale
6161

6262
#elif (TM_MDL_TYPE==TM_MDL_INT8) || (TM_MDL_TYPE==TM_MDL_INT16)
6363

6464
#if TM_FASTSCALE
65-
static int32_t sumscale[TM_MAX_CSIZE];
66-
static int32_t outscale;
65+
TM_STATIC int32_t sumscale[TM_MAX_CSIZE];
66+
TM_STATIC int32_t outscale;
6767
#define OUTSCALE outscale
6868
#else
69-
static float sumscale[TM_MAX_CSIZE];
70-
static sctype_t outscale;
71-
static sctype_t outscale_inv;
69+
TM_STATIC float sumscale[TM_MAX_CSIZE];
70+
TM_STATIC sctype_t outscale;
71+
TM_STATIC sctype_t outscale_inv;
7272
#define OUTSCALE outscale_inv
7373
#endif
7474
#define SUMSCALE (sumscale + c)
@@ -397,8 +397,8 @@ TM_INLINE tm_err_t l_tml_dwconv2d_3x3_part(tm_mat_t* in, tm_mat_t* out, wtype_t*
397397
#define CONV_BLK_H (4)
398398
#define CONV_BLK_STEPX (CONV_BLK_W-3+1)
399399
#define CONV_BLK_STEPY (CONV_BLK_H-3+1)
400-
static mtype_t dw_sbuf[CONV_BLK_W*CONV_BLK_H*TM_MAX_CSIZE];
401-
static uint32_t dw_koft[CONV_BLK_W*CONV_BLK_H];
400+
TM_STATIC mtype_t dw_sbuf[CONV_BLK_W*CONV_BLK_H*TM_MAX_CSIZE];
401+
TM_STATIC uint32_t dw_koft[CONV_BLK_W*CONV_BLK_H];
402402

403403
// 40ms->27ms
404404
TM_INLINE tm_err_t l_tml_dwconv2d_3x3_nostride(tm_mat_t* in, tm_mat_t* out, wtype_t* w, btype_t* b, \

0 commit comments

Comments
 (0)