fix infer float compare

This commit is contained in:
zhaodezan 2022-07-20 14:39:00 +08:00
parent 476484c2d9
commit b689657f5d
3 changed files with 5 additions and 3 deletions

View File

@ -28,6 +28,8 @@
extern "C" {
#endif
#define EPSILON 1e-6
enum NNACLLshProjectionType {
LshProjectionType_UNKNOWN = 0,
LshProjectionType_SPARSE = 1,

View File

@ -45,13 +45,13 @@ int PriorBoxInferShape(const TensorC *const *inputs, size_t inputs_size, TensorC
MS_CHECK_TRUE_RET(aspect_ratios_size <= MAX_SHAPE_SIZE, NNACL_ERR);
for (int32_t i = 0; i < aspect_ratios_size; i++) {
float ratio = aspect_ratios[i];
if (ratio == 0) {
if (fabsf(ratio) < EPSILON) {
return NNACL_ERR;
}
bool exist = false;
for (size_t j = 0; j < different_aspect_ratios_size; j++) {
if (fabsf(ratio - different_aspect_ratios[j]) < 1e-6) {
if (fabsf(ratio - different_aspect_ratios[j]) < EPSILON) {
exist = true;
break;
}

View File

@ -60,7 +60,7 @@ int RangeInferShape(const TensorC *const *inputs, size_t inputs_size, TensorC **
float start = *(float *)(inputs[0]->data_);
float limit = *(float *)(inputs[1]->data_);
float delta = *(float *)(inputs[2]->data_);
if (delta == 0) {
if (fabsf(delta) < EPSILON) {
return NNACL_ERR;
}
shape_size = imax((int)(ceil((float)(limit - start) / delta)), 0);