Skip to content

Commit

Permalink
Remove clamping for converts (#1853)
Browse files Browse the repository at this point in the history
Fixes #1852  Fixes #1847
  • Loading branch information
umangyadav committed Jun 23, 2023
1 parent 01342ae commit e794a63
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
12 changes: 1 addition & 11 deletions src/include/migraphx/op/convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,7 @@ struct convert : unary<convert>
auto type = target_type;
return [type](auto x) {
auto y = x;
shape::visit(type, [&](auto as) {
// clamping value between target_type's max and min doesn't work for NaNs,
if(std::isnan(x))
{
y = as.nan();
}
else
{
y = std::min(std::max(as(x), as.min()), as.max());
}
});
shape::visit(type, [&](auto as) { y = as(x); });
return y;
};
}
Expand Down
2 changes: 1 addition & 1 deletion test/verify/test_pad_highest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct test_pad_highest : verify_program<test_pad_highest>
migraphx::shape s0{migraphx::shape::half_type, {2, 2}};
auto l0 = mm->add_literal(migraphx::literal{s0, data0});
migraphx::op::pad op{};
op.value = std::numeric_limits<float>::max();
op.value = std::numeric_limits<migraphx::half>::max();
op.pads = {0, 0, 1, 1};
mm->add_instruction(op, l0);
return p;
Expand Down
2 changes: 1 addition & 1 deletion test/verify/test_pad_lowest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct test_pad_lowest : verify_program<test_pad_lowest>
migraphx::shape s0{migraphx::shape::half_type, {2, 2}};
auto l0 = mm->add_literal(migraphx::literal{s0, data0});
migraphx::op::pad op{};
op.value = std::numeric_limits<float>::lowest();
op.value = std::numeric_limits<migraphx::half>::lowest();
op.pads = {0, 0, 1, 1};
mm->add_instruction(op, l0);
return p;
Expand Down

0 comments on commit e794a63

Please sign in to comment.