-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added fix for test_msgpack_float and test_msgpack_object #2155
Conversation
Check results before merge 🔆 |
🔴bert_base_cased_fp16: FAILED: MIGraphX is not within tolerance - check verbose output🔴bert_large_uncased_fp16: FAILED: MIGraphX is not within tolerance - check verbose output🔴distilgpt2_fp16: FAILED: MIGraphX is not within tolerance - check verbose output |
Codecov Report
@@ Coverage Diff @@
## develop #2155 +/- ##
========================================
Coverage 91.50% 91.50%
========================================
Files 431 431
Lines 16140 16140
========================================
Hits 14769 14769
Misses 1371 1371 |
test/msgpack.cpp
Outdated
@@ -76,7 +76,7 @@ TEST_CASE(test_msgpack_float) | |||
migraphx::value v = 3.0; | |||
auto buffer = migraphx::to_msgpack(v); | |||
EXPECT(buffer == msgpack_buffer(3.0)); | |||
EXPECT(migraphx::from_msgpack(buffer) == v); | |||
EXPECT(migraphx::from_msgpack(buffer).to<float>() == v.to<float>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need to be converted to float
first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function migraphx::from_msgpack returns value which needs to be converted to other types (except for string and bool case) when we are comparing output values. The tests above convert value to appropriate type (here is the example for int).
test/msgpack.cpp
Outdated
EXPECT(migraphx::from_msgpack(buffer) == v); | ||
|
||
// converted to vector in the following line because in value.cpp value constructor with | ||
// unordered map is creating vector<value> with map items as vector elements |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are we using an unordered map?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In value definition inside value.hpp I haven't seen constructor for map, I found just constructor for unordered map
Its not using the std::unordered_map
constructor, its using the std::initializer_list
constructor which will preserve the order of the list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw value constructor for std::initializer_list in value.cpp. In this case (where size is not 2 and elements have key) it is calling set_vector
function, so I think to_vector()
function can be used for comparing if result values are equal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to_vector
will only compare the values and not the keys. The ==
operator for value will compare the keys as well: migraphx::from_msgpack(buffer) == v
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If migraphx::from_msgpack(buffer)
function is fixed, I won't have need to cast output to float
in the following way which i committed in this PR too (EXPECT(migraphx::from_msgpack(buffer).to<float>() == v.to<float>());
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but the problem here is that migraphx::from_msgpack(buffer) converts any numeric value to uint64_t
Where do you see this happening? from_msgpack
converts the float32 or float64 to double here: https://github.com/ROCmSoftwarePlatform/AMDMIGraphX/blob/develop/src/msgpack.cpp#L85.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see it in the debugger during comparing EXPECT(migraphx::from_msgpack(buffer) == v);
. You can see debugger output in the following screenshot when debugging test_msgpack_float, here x
is migraphx::from_msgpack(buffer)
output and y
is migraphx::value v
which is double. If we cast v
to be uint64_t
, the test passes.
Also, if there is type conversion why do we need to cast function output to int here (which already exists in develop branch)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion since we do want to keep comparing the keys and the types are different for the values that we should either change operator== to have a specialization that can properly compare types, call the compare function directly if that will allow us to compare types or create a compare function that can compare the keys and compare with an explicit type conversion (passed as a template parameter).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So there is something wrong with either msgpack serialization or the value construction as it should be float_type
as well.
I changed code without cast msgpack output to expected type according to following findings on Windows (tests pass on Linux): the thing here is that That function is calling
The thing here is that when we have If I change inputs inside test code for example from 3.0 to 3.01 or whatever value which is not same as value after conversion to |
fixed result comparison in msgpack test with float and map