Skip to content

Commit

Permalink
Make const
Browse files Browse the repository at this point in the history
  • Loading branch information
Aba committed Nov 1, 2023
1 parent 6f69af8 commit c2515c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
24 changes: 12 additions & 12 deletions c/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define EXT_C
#endif

typedef struct {
typedef const struct {
const int32_t n, l, kw, coe, coe_tl, r_ll, h, w, ci, co, w_kw2, t, p, cm, cm_p0;
const int32_t w_bpt, w_bpt_p0, x_bpt, x_bpt_p0, o_bytes; // bytes per transfer
const int8_t is_bias, is_pool, is_flatten;
Expand All @@ -27,13 +27,13 @@ typedef enum {POOL_NONE, POOL_MAX, POOL_AVG} Pool_t;
#define X_BITS (1<<X_BITS_L2)

typedef struct {
int8_t w [W_BYTES ];
B_TYPE b [B_WORDS ]; // keep next to w. weights are loaded to w_ptr
int8_t x [X_BYTES_ALL ];
int8_t nx [O_BYTES_MAX ];
int32_t y [O_WORDS ];
int32_t nhwc [Y_BYTES/4 ];
int32_t debug_nhwc [Y_BYTES/4];
int8_t w [W_BYTES ];
B_TYPE b [B_WORDS ]; // keep next to w. weights are loaded to w_ptr
int8_t x [X_BYTES_ALL ];
int8_t nx [O_BYTES_MAX ];
int32_t y [O_WORDS ];
int32_t nhwc [Y_BYTES/4 ];
int32_t debug_nhwc [Y_BYTES/4 ];
} Memory_st;
Memory_st mem;

Expand Down Expand Up @@ -150,7 +150,7 @@ extern EXT_C void load_y (uint8_t *p_done, uint8_t *pt_done_proc, const uint32_
int32_t ph_end, ph_beg_const, ph_beg, ixh_beg, xh_sweep;
int32_t pw_end, pw_beg_const, pw_beg, ixw_beg, xw_sweep;

int8_t f_path_raw [1000], f_path_sum [1000]; // make sure full f_path_raw is shorter than 1000
char f_path_raw [1000], f_path_sum [1000]; // make sure full f_path_raw is shorter than 1000
sprintf(f_path_raw, "%s/%0d_%0d_%0d_y_raw_sim.txt", DATA_DIR, ib, ip, it);
sprintf(f_path_sum, "%s/%0d_y_sum_sim.txt", DATA_DIR, ib);
FILE *fp_raw = fopen(f_path_raw, "a");
Expand Down Expand Up @@ -315,14 +315,14 @@ extern EXT_C void load_y (uint8_t *p_done, uint8_t *pt_done_proc, const uint32_

printf("done bundle!! iw_kw2:%d in:%d il:%d it:%d ip:%d ib:%d\n", iw_kw2, in, il, it, ip, ib);

int8_t f_path_tiled [1000];
char f_path_tiled [1000];
sprintf(f_path_tiled, "%s/%0d_y_tiled_sim.txt", DATA_DIR, ib);
FILE *fp_tiled = fopen(f_path_tiled, "w");
for (int32_t i=0; i<pb->o_bytes; i++)
fprintf(fp_tiled,"%d\n", ib == N_BUNDLES-1 ? mem.y[i] : mem.nx[i]);
fclose(fp_tiled);

int8_t f_path_debug [1000];
char f_path_debug [1000];
sprintf(f_path_debug, "%s/%0d_y_nhwc_sim.txt", DATA_DIR, ib);
FILE *fp_debug = fopen(f_path_debug, "w");
for (int32_t i=0; i<pb->debug_nhwc_words; i++)
Expand Down Expand Up @@ -388,7 +388,7 @@ extern EXT_C void load_w (uint8_t *p_done, int32_t *p_offset, int32_t *p_bpt) {

extern EXT_C void fill_memory (){
FILE *fp;
int8_t f_path [1000];
char f_path [1000];

sprintf(f_path, "%s/w.bin", DATA_DIR);
fp = fopen(f_path, "rb");
Expand Down
4 changes: 2 additions & 2 deletions test/py/param_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class Config:

@pytest.mark.parametrize("COMPILE", list(product_dict(
X_BITS = [8 ],
K_BITS = [4 ],
K_BITS = [8 ],
B_BITS = [16 ],
Y_BITS = [24 ],
INT_BITS = [32 ], # size of integer in target CPU
Expand Down Expand Up @@ -307,7 +307,7 @@ def test_dnn_engine(COMPILE):
ch.write( f".b_offset={b_words}, .b_val_shift={b.bias_val_shift}, .b_bias_shift={b.bias_b_shift}, ")
ch.write( f".ca_nzero={ca_nzero}, .ca_shift={ca_shift}, .ca_pl_scale={ca_pl_scale}, ")
ch.write( f".csh={b.r.CSH}, .ch={b.r.CYH}, .csh_shift={b.r.CSH_SHIFT}, .pkh={b.r.PKH}, .psh={b.r.PSH}, .ph={b.r.PYH}, .psh_shift={b.r.PSH_SHIFT}, .csw={b.r.CSW}, .cw={b.r.CYW}, .csw_shift={b.r.CSW_SHIFT}, .pkw={b.r.PKW}, .psw={b.r.PSW}, .pw={b.r.PYW}, .psw_shift={b.r.PSW_SHIFT}, .pool={pool_type}, .on={b.r.ON}, .oh={b.r.OH}, .ow={b.r.OW}, .oc={b.r.OC}, ")
ch.write( f".x_header={b.r.x_header_be_p[-1][0]}, .x_header_p0={b.r.x_header_be_p[0][0]}, .w_header={b.r.w_header_be_p[-1][0]}, .w_header_p0={b.r.x_header_be_p[0][0]} , ")
ch.write( f".x_header={b.r.x_header_be_p[-1][0]}u, .x_header_p0={b.r.x_header_be_p[0][0]}u, .w_header={b.r.w_header_be_p[-1][0]}u, .w_header_p0={b.r.x_header_be_p[0][0]}u , ")
ch.write( f".debug_nhwc_words={b.oe_exp_nhwc.size} }}")

b_words += b.be.size if b.b else 0
Expand Down

0 comments on commit c2515c6

Please sign in to comment.