From 759d1422a240b300a199f111614bee0f879a9d05 Mon Sep 17 00:00:00 2001 From: i-evi Date: Sun, 21 Jun 2020 16:38:20 +0800 Subject: [PATCH] update --- makefile | 43 ++++++---- readme.md | 2 +- src/cc_array.c | 213 +++++++++++++++++++++++++++++++----------------- src/cc_array.h | 23 ++++-- src/cc_basic.c | 72 +++++++++++++++- src/cc_basic.h | 13 +++ src/cc_tsrmgr.c | 8 +- 7 files changed, 276 insertions(+), 98 deletions(-) diff --git a/makefile b/makefile index 9f417ee..183acf7 100644 --- a/makefile +++ b/makefile @@ -1,14 +1,17 @@ -cc = gcc +CC = gcc + +# Build Ctrl Flag +BCTRL = # Debug flag, cc_assert DFLAG += -DENABLE_CC_ASSERT # AddressSanitizer for gcc/clang -DFLAG += -g -fsanitize=address -fno-omit-frame-pointer +DFLAG += # -g -fsanitize=address -fno-omit-frame-pointer CFLAG += # -std=c89 CFLAG += -Wall # -Wpedantic -OFLAG += -Os +OFLAG += -O3 # Enable OpenMP OFLAG += -DENABLE_OPENMP -fopenmp @@ -23,9 +26,16 @@ CFLAG += -DAUTO_TSRMGR # will only support bmp image if disabled 3RDSRC_CF += stb +ifneq ($(findstring MINI, $(BCTRL)),) + CC = tcc + CFLAG = -std=c89 + CFLAG += -DAUTO_TSRMGR + 3RDSRC_CF = +endif + ifneq ($(findstring -std=c89, $(CFLAG)),) CFLAG += -DCONFIG_STD_C89 - ifneq ($(findstring $(cc), gcc clang),) + ifneq ($(findstring $(CC), gcc clang),) WFLAG += -Wno-long-long endif endif @@ -37,26 +47,28 @@ ALL_O = catcoon.o cc_tensor.o cc_dtype.o cc_tsrmgr.o cc_fmap2d.o cc_pool2d.o \ cc_conv2d.o cc_normfn.o cc_image.o util_rbt.o util_list.o util_log.o \ util_image.o global_fn_cfg.o +CATCOON_A = libcatcoon.a + APP_NAMES = simple lenet lenet_pack lenet_unpack ifeq ($(OS),Windows_NT) RM = del - APPS = $(foreach v, $(APP_NAMES), $(v).exe) + APPS = $(foreach v, $(APP_NAMES), $(v).exe) else RM = rm APPS = $(APP_NAMES) endif -all: $(APPS) +all: $(APPS) # $(CATCOON_A) %.o: ./src/%.c - $(cc) -c -o $@ $< $(CFLAG) $(INC) -# APPS For Linux + $(CC) -c -o $@ $< $(CFLAG) $(INC) +# Targets For Linux %: ./demo/%.c $(ALL_O) - $(cc) -o $@ $< $(ALL_O) $(CFLAG) $(INC) $(LINK) -# APPS For Windows + $(CC) -o $@ $< $(ALL_O) $(CFLAG) $(INC) $(LINK) +# Targets For Windows %.exe: ./demo/%.c $(ALL_O) - $(cc) -o $@ $< $(ALL_O) $(CFLAG) $(INC) $(LINK) + $(CC) -o $@ $< $(ALL_O) $(CFLAG) $(INC) $(LINK) global_fn_cfg.o : $(patsubst %, ./src/%, global_fn_cfg.h global_fn_cfg.c) @@ -79,13 +91,16 @@ cc_tensor.o : $(patsubst %, ./src/%, cc_tensor.h cc_tensor.c) util_log.o : $(patsubst %, ./src/%, util_log.h util_log.c) util_rbt.o : $(patsubst %, ./src/%, util_rbt.h util_rbt.c) util_list.o : ./src/util_list.h ./src/util_list.c - $(cc) -c -o $@ ./src/util_list.c $(CFLAG) -DENABLE_FOPS + $(CC) -c -o $@ ./src/util_list.c $(CFLAG) -DENABLE_FOPS UTIM_COND = ifneq ($(findstring stb, $(3RDSRC_CF)),) UTIM_COND += -DUSE3RD_STB_IMAGE -I ./src/3rd_party/stb/ endif util_image.o : ./src/util_image.h ./src/util_image.c - $(cc) -c -o $@ ./src/util_image.c $(CFLAG) $(UTIM_COND) + $(CC) -c -o $@ ./src/util_image.c $(CFLAG) $(UTIM_COND) + +minimal: + $(MAKE) "BCTRL = MINI" clean: - $(RM) *.o && $(RM) $(APPS) \ No newline at end of file + $(RM) *.o && $(RM) $(APPS) diff --git a/readme.md b/readme.md index 825943a..5b45693 100644 --- a/readme.md +++ b/readme.md @@ -37,7 +37,7 @@ Catcoon 使用 tensor 进行计算。神经网络的计算过程中,经常产 ```c typedef struct { - list_t *container; + list_t *container; const char *name; unsigned char *data; const cc_int32 *shape; diff --git a/src/cc_array.c b/src/cc_array.c index 89b5d80..08fc798 100644 --- a/src/cc_array.c +++ b/src/cc_array.c @@ -6,15 +6,34 @@ #include "cc_dtype.h" #include "cc_array.h" -#define ELEM_OPS_ON_ARRAY(op, elem, arr, arrlen, dtype) \ +#define ARRAY_SC_OPS(op, arr, elem, arrlen, dtype) \ for (i = 0; i < arrlen; ++i) { \ *((dtype*)arr + i) op ## = *(dtype*)elem; \ } -#define ARRAY_ELEM_OPS(op, elem, inp, oup, arrlen, dtype) \ - for (i = 0; i < arrlen; ++i) { \ - *((dtype*)oup + i) = *((dtype*)inp + i) \ - op *(dtype*)elem; \ +#define ARRAY_ELEM_SET(arr, elem, arrlen, dtype) \ + for (i = 0; i < arrlen; ++i) { \ + *((dtype*)arr + i) = *(dtype*)elem; \ + } + +#define ARRAY_ELEM_CLIP(arr, min, max, arrlen, dtype) \ + for (i = 0; i < arrlen; ++i) { \ + if (min) { \ + *((dtype*)arr + i) = \ + *((dtype*)arr + i) < *(dtype*)min ? \ + *(dtype*)min : *((dtype*)arr + i); \ + } \ + if (max) { \ + *((dtype*)arr + i) = \ + *((dtype*)arr + i) > *(dtype*)max ? \ + *(dtype*)max : *((dtype*)arr + i); \ + } \ + } + +#define ARRAY_EW_OPS(op, oup, a, b, arrlen, dtype) \ + for (i = 0; i < arrlen; ++i) { \ + *((dtype*)oup + i) = *((dtype*)a + i) op \ + *((dtype*)b + i); \ } #define ARRAY_SUM(arr, arrlen, dtype, sum) \ @@ -23,11 +42,6 @@ *(dtype*)sum += *((dtype*)arr + i); \ } -#define ARRAY_OPS(op, dst, src, arrlen, dtype) \ - for (i = 0; i < arrlen; ++i) { \ - *((dtype*)dst + i) += *((dtype*)src + i); \ - } - #define ARRAY_CAST_CASE(_DT, _srcdt, _dstdt) \ case _DT: \ for (i = 0; i < arrlen; ++i) \ @@ -56,6 +70,57 @@ void cc_array_cast_ ## dtype(void *dst, void *src, int arrlen, int dt) \ } \ } +#define ARRAY_SET_CASE(_DT, _dt) \ +case _DT: \ + ARRAY_ELEM_SET(arr, x, arrlen, _dt) \ + break; +void cc_array_set(void *arr, int arrlen, void *x, int dt) +{ + cc_int32 i; + switch (dt) { + ARRAY_SET_CASE(CC_UINT8, cc_uint8); + ARRAY_SET_CASE(CC_UINT16, cc_uint16); + ARRAY_SET_CASE(CC_UINT32, cc_uint32); + ARRAY_SET_CASE(CC_UINT64, cc_uint64); + ARRAY_SET_CASE(CC_INT8, cc_int8); + ARRAY_SET_CASE(CC_INT16, cc_int16); + ARRAY_SET_CASE(CC_INT32, cc_int32); + ARRAY_SET_CASE(CC_INT64, cc_int64); + ARRAY_SET_CASE(CC_FLOAT32, cc_float32); + ARRAY_SET_CASE(CC_FLOAT64, cc_float64); + default: + utlog_format(UTLOG_ERR, + "cc_array: unsupported dtype %x\n", dt); + break; + } +} + +#define ARRAY_CLIP_CASE(_DT, _dt) \ +case _DT: \ + ARRAY_ELEM_CLIP(arr, min, max, arrlen, _dt); \ + break; +void cc_array_clip_by_value( + void *arr, int arrlen, void *min, void *max, int dt) +{ + cc_int32 i; + switch (dt) { + ARRAY_CLIP_CASE(CC_UINT8, cc_uint8); + ARRAY_CLIP_CASE(CC_UINT16, cc_uint16); + ARRAY_CLIP_CASE(CC_UINT32, cc_uint32); + ARRAY_CLIP_CASE(CC_UINT64, cc_uint64); + ARRAY_CLIP_CASE(CC_INT8, cc_int8); + ARRAY_CLIP_CASE(CC_INT16, cc_int16); + ARRAY_CLIP_CASE(CC_INT32, cc_int32); + ARRAY_CLIP_CASE(CC_INT64, cc_int64); + ARRAY_CLIP_CASE(CC_FLOAT32, cc_float32); + ARRAY_CLIP_CASE(CC_FLOAT64, cc_float64); + default: + utlog_format(UTLOG_ERR, + "cc_array: unsupported dtype %x\n", dt); + break; + } +} + CC_ARRAY_CAST_IMPLEMENTATION (uint8) CC_ARRAY_CAST_IMPLEMENTATION (uint16) CC_ARRAY_CAST_IMPLEMENTATION (uint32) @@ -68,8 +133,8 @@ CC_ARRAY_CAST_IMPLEMENTATION (float32) CC_ARRAY_CAST_IMPLEMENTATION (float64) #define ARRAY_ADD_BY_CASE(_DT, _dt) \ -case _DT: \ - ELEM_OPS_ON_ARRAY(+, x, arr, arrlen, _dt); \ +case _DT: \ + ARRAY_SC_OPS(+, arr, x, arrlen, _dt); \ break; void cc_array_add_by(void *arr, int arrlen, void *x, int dt) { @@ -93,8 +158,8 @@ void cc_array_add_by(void *arr, int arrlen, void *x, int dt) } #define ARRAY_SUB_BY_CASE(_DT, _dt) \ -case _DT: \ - ELEM_OPS_ON_ARRAY(-, x, arr, arrlen, _dt); \ +case _DT: \ + ARRAY_SC_OPS(-, arr, x, arrlen, _dt); \ break; void cc_array_sub_by(void *arr, int arrlen, void *x, int dt) { @@ -118,8 +183,8 @@ void cc_array_sub_by(void *arr, int arrlen, void *x, int dt) } #define ARRAY_MUL_BY_CASE(_DT, _dt) \ -case _DT: \ - ELEM_OPS_ON_ARRAY(*, x, arr, arrlen, _dt); \ +case _DT: \ + ARRAY_SC_OPS(*, arr, x, arrlen, _dt); \ break; void cc_array_mul_by(void *arr, int arrlen, void *x, int dt) { @@ -143,8 +208,8 @@ void cc_array_mul_by(void *arr, int arrlen, void *x, int dt) } #define ARRAY_DIV_BY_CASE(_DT, _dt) \ -case _DT: \ - ELEM_OPS_ON_ARRAY(/, x, arr, arrlen, _dt); \ +case _DT: \ + ARRAY_SC_OPS(/, arr, x, arrlen, _dt); \ break; void cc_array_div_by(void *arr, int arrlen, void *x, int dt) { @@ -168,10 +233,10 @@ void cc_array_div_by(void *arr, int arrlen, void *x, int dt) } #define ARRAY_ADD_EW_CASE(_DT, _dt) \ -case _DT: \ - ARRAY_ELEM_OPS(+, x, inp, oup, arrlen, _dt); \ +case _DT: \ + ARRAY_EW_OPS(+, oup, a, b, arrlen, _dt); \ break; -void cc_array_add_ew(void *inp, void *oup, int arrlen, void *x, int dt) +void cc_array_add_ew(void *oup, int arrlen, void *a, void *b, int dt) { cc_int32 i; switch (dt) { @@ -192,11 +257,36 @@ void cc_array_add_ew(void *inp, void *oup, int arrlen, void *x, int dt) } } +#define ARRAY_SUB_EW_CASE(_DT, _dt) \ +case _DT: \ + ARRAY_EW_OPS(-, oup, a, b, arrlen, _dt); \ + break; +void cc_array_sub_ew(void *oup, int arrlen, void *a, void *b, int dt) +{ + cc_int32 i; + switch (dt) { + ARRAY_SUB_EW_CASE(CC_UINT8, cc_uint8); + ARRAY_SUB_EW_CASE(CC_UINT16, cc_uint16); + ARRAY_SUB_EW_CASE(CC_UINT32, cc_uint32); + ARRAY_SUB_EW_CASE(CC_UINT64, cc_uint64); + ARRAY_SUB_EW_CASE(CC_INT8, cc_int8); + ARRAY_SUB_EW_CASE(CC_INT16, cc_int16); + ARRAY_SUB_EW_CASE(CC_INT32, cc_int32); + ARRAY_SUB_EW_CASE(CC_INT64, cc_int64); + ARRAY_SUB_EW_CASE(CC_FLOAT32, cc_float32); + ARRAY_SUB_EW_CASE(CC_FLOAT64, cc_float64); + default: + utlog_format(UTLOG_ERR, + "cc_array: unsupported dtype %x\n", dt); + break; + } +} + #define ARRAY_MUL_EW_CASE(_DT, _dt) \ -case _DT: \ - ARRAY_ELEM_OPS(*, x, inp, oup, arrlen, _dt); \ +case _DT: \ + ARRAY_EW_OPS(*, oup, a, b, arrlen, _dt); \ break; -void cc_array_mul_ew(void *inp, void *oup, int arrlen, void *x, int dt) +void cc_array_mul_ew(void *oup, int arrlen, void *a, void *b, int dt) { cc_int32 i; switch (dt) { @@ -217,6 +307,31 @@ void cc_array_mul_ew(void *inp, void *oup, int arrlen, void *x, int dt) } } +#define ARRAY_DIV_EW_CASE(_DT, _dt) \ +case _DT: \ + ARRAY_EW_OPS(/, oup, a, b, arrlen, _dt); \ + break; +void cc_array_div_ew(void *oup, int arrlen, void *a, void *b, int dt) +{ + cc_int32 i; + switch (dt) { + ARRAY_DIV_EW_CASE(CC_UINT8, cc_uint8); + ARRAY_DIV_EW_CASE(CC_UINT16, cc_uint16); + ARRAY_DIV_EW_CASE(CC_UINT32, cc_uint32); + ARRAY_DIV_EW_CASE(CC_UINT64, cc_uint64); + ARRAY_DIV_EW_CASE(CC_INT8, cc_int8); + ARRAY_DIV_EW_CASE(CC_INT16, cc_int16); + ARRAY_DIV_EW_CASE(CC_INT32, cc_int32); + ARRAY_DIV_EW_CASE(CC_INT64, cc_int64); + ARRAY_DIV_EW_CASE(CC_FLOAT32, cc_float32); + ARRAY_DIV_EW_CASE(CC_FLOAT64, cc_float64); + default: + utlog_format(UTLOG_ERR, + "cc_array: unsupported dtype %x\n", dt); + break; + } +} + #define ARRAY_SUM_CASE(_DT, _dt) \ case _DT: \ ARRAY_SUM(arr, arrlen, _dt, x); \ @@ -268,56 +383,6 @@ void cc_array_mean(void *arr, int arrlen, void *x, int dt) } } -#define ADD_TO_ARRAY_EW_CASE(_DT, _dt) \ -case _DT: \ - ARRAY_OPS(+, dst, src, arrlen, _dt); \ - break; -void cc_add_to_array_ew(void *dst, void *src, int arrlen, int dt) -{ - cc_int32 i; - switch (dt) { - ADD_TO_ARRAY_EW_CASE(CC_UINT8, cc_uint8); - ADD_TO_ARRAY_EW_CASE(CC_UINT16, cc_uint16); - ADD_TO_ARRAY_EW_CASE(CC_UINT32, cc_uint32); - ADD_TO_ARRAY_EW_CASE(CC_UINT64, cc_uint64); - ADD_TO_ARRAY_EW_CASE(CC_INT8, cc_int8); - ADD_TO_ARRAY_EW_CASE(CC_INT16, cc_int16); - ADD_TO_ARRAY_EW_CASE(CC_INT32, cc_int32); - ADD_TO_ARRAY_EW_CASE(CC_INT64, cc_int64); - ADD_TO_ARRAY_EW_CASE(CC_FLOAT32, cc_float32); - ADD_TO_ARRAY_EW_CASE(CC_FLOAT64, cc_float64); - default: - utlog_format(UTLOG_ERR, - "cc_array: unsupported dtype %x\n", dt); - break; - } -} - -#define MUL_TO_ARRAY_EW_CASE(_DT, _dt) \ -case _DT: \ - ARRAY_OPS(*, dst, src, arrlen, _dt); \ - break; -void cc_mul_to_array_ew(void *dst, void *src, int arrlen, int dt) -{ - cc_int32 i; - switch (dt) { - MUL_TO_ARRAY_EW_CASE(CC_UINT8, cc_uint8); - MUL_TO_ARRAY_EW_CASE(CC_UINT16, cc_uint16); - MUL_TO_ARRAY_EW_CASE(CC_UINT32, cc_uint32); - MUL_TO_ARRAY_EW_CASE(CC_UINT64, cc_uint64); - MUL_TO_ARRAY_EW_CASE(CC_INT8, cc_int8); - MUL_TO_ARRAY_EW_CASE(CC_INT16, cc_int16); - MUL_TO_ARRAY_EW_CASE(CC_INT32, cc_int32); - MUL_TO_ARRAY_EW_CASE(CC_INT64, cc_int64); - MUL_TO_ARRAY_EW_CASE(CC_FLOAT32, cc_float32); - MUL_TO_ARRAY_EW_CASE(CC_FLOAT64, cc_float64); - default: - utlog_format(UTLOG_ERR, - "cc_array: unsupported dtype %x\n", dt); - break; - } -} - #define PRINT_ARRAY_CASE(_DT, _dt) \ case _DT: \ fprintf(fp, pat, *((_dt*)a + i)); \ diff --git a/src/cc_array.h b/src/cc_array.h index e51a1d2..8d9ea0c 100644 --- a/src/cc_array.h +++ b/src/cc_array.h @@ -23,20 +23,33 @@ CC_ARRAY_CAST_DEFINITION (int64) CC_ARRAY_CAST_DEFINITION (float32) CC_ARRAY_CAST_DEFINITION (float64) +void cc_array_set(void *arr, int arrlen, void *x, int dt); + +void cc_array_clip_by_value( + void *arr, int arrlen, void *min, void *max, int dt); + void cc_array_add_by(void *arr, int arrlen, void *x, int dt); void cc_array_sub_by(void *arr, int arrlen, void *x, int dt); void cc_array_mul_by(void *arr, int arrlen, void *x, int dt); void cc_array_div_by(void *arr, int arrlen, void *x, int dt); -void cc_array_add_ew(void *inp, void *oup, int arrlen, void *x, int dt); -void cc_array_mul_ew(void *inp, void *oup, int arrlen, void *x, int dt); +void cc_array_add_ew(void *oup, int arrlen, void *a, void *b, int dt); +void cc_array_sub_ew(void *oup, int arrlen, void *a, void *b, int dt); +void cc_array_mul_ew(void *oup, int arrlen, void *a, void *b, int dt); +void cc_array_div_ew(void *oup, int arrlen, void *a, void *b, int dt); + +#define cc_add_to_array_ew(dst, src, arrlen, dt) \ + cc_array_add_ew(dst, arrlen, dst, src, dt) +#define cc_sub_to_array_ew(dst, src, arrlen, dt) \ + cc_array_sub_ew(dst, arrlen, dst, src, dt) +#define cc_mul_to_array_ew(dst, src, arrlen, dt) \ + cc_array_mul_ew(dst, arrlen, dst, src, dt) +#define cc_div_to_array_ew(dst, src, arrlen, dt) \ + cc_array_div_ew(dst, arrlen, dst, src, dt) void cc_array_sum(void *arr, int arrlen, void *x, int dt); void cc_array_mean(void *arr, int arrlen, void *x, int dt); -void cc_add_to_array_ew(void *dst, void *src, int arrlen, int dt); -void cc_mul_to_array_ew(void *dst, void *src, int arrlen, int dt); - void cc_print_array(void *a, int arrlen, int dt, void *stream); #ifdef __cplusplus diff --git a/src/cc_basic.c b/src/cc_basic.c index e7bebec..d77e760 100644 --- a/src/cc_basic.c +++ b/src/cc_basic.c @@ -105,12 +105,35 @@ int cc_tsrcmp_by_shape(cc_tensor_t *a, cc_tensor_t *b) void cc_print_tensor(cc_tensor_t *tensor) { - utlog_format(UTLOG_INFO, ""); + cc_print_tensor_property(tensor); cc_print_array(tensor->data, cc_tensor_elements(tensor), *tensor->dtype, utlog_get_ostream()); } +void cc_set_tensor(cc_tensor_t *tensor, void *v) +{ + cc_array_set(tensor->data, + cc_tensor_elements(tensor), v, *tensor->dtype); +} + +cc_tensor_t *cc_clip_by_value(cc_tensor_t *tensor, + void *min, void *max, const char *name) +{ + cc_tensor_t *yield; + cc_int32 elems = *tensor->shape; + const cc_int32 *sptr = tensor->shape; + while (*++sptr) + elems *= *sptr; + if (!name || !strcmp(name, tensor->name)) + yield = tensor; + else + yield = cc_copy_tensor(tensor, name); + cc_array_clip_by_value(tensor->data, + cc_tensor_elements(tensor), min, max, *tensor->dtype); + return yield; +} + cc_tensor_t *cc_cast_tensor(cc_tensor_t *tensor, cc_dtype dtype, const char *name) { @@ -231,3 +254,50 @@ cc_tensor_t *cc_tensor_by_scalar(cc_tensor_t *tensor, } return yield; } + +cc_tensor_t *cc_tensor_ewop(cc_tensor_t *a, + cc_tensor_t *b, char op, const char *name) +{ + cc_tensor_t *yield; + cc_int32 elems = *a->shape; + const cc_int32 *sptr = a->shape; + while (*++sptr) + elems *= *sptr; +#ifdef ENABLE_CC_ASSERT + cc_assert_zero(cc_tsrcmp_by_shape(a, b)); +#endif + if (!name || !strcmp(name, a->name)) + yield = a; + else + yield = cc_copy_tensor(a, name); + switch (op) { + case '+': + cc_add_to_array_ew( + yield->data, b->data, elems, *yield->dtype); + break; + case '-': + cc_sub_to_array_ew( + yield->data, b->data, elems, *yield->dtype); + break; + case '*': + cc_mul_to_array_ew( + yield->data, b->data, elems, *yield->dtype); + break; + case '/': + cc_div_to_array_ew( + yield->data, b->data, elems, *yield->dtype); + break; + default: + utlog_format(UTLOG_ERR, + "cc_tensor_by_scalar: unsupported operator [%c]\n", + op); +#ifdef AUTO_TSRMGR + if (strcmp(name, a->name)) + cc_tsrmgr_del(name); +#else + cc_free_tensor(yield); +#endif + return NULL; + } + return yield; +} diff --git a/src/cc_basic.h b/src/cc_basic.h index c450727..d21bd73 100644 --- a/src/cc_basic.h +++ b/src/cc_basic.h @@ -19,12 +19,25 @@ int cc_tsrcmp_by_shape(cc_tensor_t *a, cc_tensor_t *b); void cc_print_tensor(cc_tensor_t *tensor); +void cc_set_tensor(cc_tensor_t *tensor, void *v); + cc_tensor_t *cc_cast_tensor(cc_tensor_t *tensor, cc_dtype dtype, const char *name); cc_tensor_t *cc_tensor_by_scalar(cc_tensor_t *tensor, char op, void *data, const char *name); +/* + * Element wise operations + * a = op(a, b) if name not set(NULL) + * c = op(a, b) if set name for c + */ +cc_tensor_t *cc_tensor_ewop(cc_tensor_t *a, + cc_tensor_t *b, char op, const char *name); + +cc_tensor_t *cc_clip_by_value(cc_tensor_t *tensor, + void *min, void *max, const char *name); + #ifdef __cplusplus } #endif diff --git a/src/cc_tsrmgr.c b/src/cc_tsrmgr.c index 4a9585f..d7c7199 100644 --- a/src/cc_tsrmgr.c +++ b/src/cc_tsrmgr.c @@ -223,7 +223,8 @@ list_t *cc_tsrmgr_pack() list_t *pack; cc_tensor_t *csr; cc_uint8 *dptr; - cc_int32 len, off, i, idc = 0; + cc_int32 len, off; + cc_uint32 i, idc = 0; rbt_iterator *it; if (!global_tsrmgr_table) { utlog_format(UTLOG_WARN, "cc_tsrmgr: not initialized\n"); @@ -257,7 +258,8 @@ void cc_tsrmgr_unpack(list_t *tls) cc_tensor_t *t; list_t *container; cc_uint8 *dptr, *rptr; - cc_int32 i, j, off, len; + cc_int32 j, off, len; + cc_uint32 i; if (!cc_tsrmgr_status()) cc_tsrmgr_init(); for (i = 0; i < tls->counter; ++i) { @@ -306,4 +308,4 @@ void cc_tsrmgr_import(const char *filename) cc_assert_ptr(pack = list_import(filename)); cc_tsrmgr_unpack(pack); list_del(pack); -} \ No newline at end of file +}