Skip to content

Commit 943b4df

Browse files
authored
Merge pull request #83 from jonnor/no-double
Avoid double precision operations
2 parents 4e7aadd + 7bcb087 commit 943b4df

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/tm_layers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ tm_err_t TM_WEAK tml_softmax(tm_mat_t* in, tm_mat_t* out, sctype_t in_s, zptype_
261261
dout[c] -= dmax;
262262
dout[c] = (float)tm_exp(dout[c]);
263263
sum += dout[c];
264-
dout[c] -= 0.000001; //prevent 1.0 value (cause 256 overflow)
264+
dout[c] -= 0.000001f; //prevent 1.0 value (cause 256 overflow)
265265
}
266266
for(int c=0; c <in->c; c++){ //int8/int16 <= fp32, so it is ok
267267
#if TM_MDL_TYPE == TM_MDL_INT8 || TM_MDL_TYPE == TM_MDL_INT16

src/tm_model.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ tm_err_t TM_WEAK tm_preprocess(tm_mdl_t* mdl, tm_pp_t pp_type, tm_mat_t* in, tm_
6767
#else
6868
case TMPP_UINT2FP01:
6969
for(int i=0; i<in_size; i++)
70-
out->data[i] = (((uint8_t*)(in->data))[i])/255.0;
70+
out->data[i] = (((uint8_t*)(in->data))[i])/255.0f;
7171
break;
7272
case TMPP_UINT2FPN11:
7373
for(int i=0; i<in_size; i++)
74-
out->data[i] = ((((uint8_t*)(in->data))[i])-128)/128.0;
74+
out->data[i] = ((((uint8_t*)(in->data))[i])-128)/128.0f;
7575
break;
7676
#endif
7777
default: //don't do anything

0 commit comments

Comments
 (0)