Skip to content

Commit 7bcb087

Browse files
committed
Use single-precision literals
This was pulling in double precision math operations The GCC option -Wdouble-promotion can be used to find these
1 parent 09ae9b7 commit 7bcb087

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)