Skip to content

Commit a1178f4

Browse files
yufengleeRyanUnderhill
authored andcommitted
fix float16 comparison in initializer (#2629)
1 parent b05eaae commit a1178f4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

onnxruntime/core/optimizer/utils.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ bool IsInitializerWithExpectedValue(const Graph& graph, const NodeArg& input_arg
6363
}
6464
} else if (data_type == ONNX_NAMESPACE::TensorProto_DataType_FLOAT16) {
6565
const MLFloat16* val = init_const->data<MLFloat16>();
66-
float diff = std::abs(math::halfToFloat(val[0].val) - static_cast<float>(expected_value));
66+
float diff = std::abs(math::halfToFloat(val[0].val) - math::halfToFloat(math::floatToHalf(expected_value)));
6767
if (diff > FLT_EPSILON) {
6868
return false;
6969
}

0 commit comments

Comments
 (0)