Commit f26d3d2d authored by Khalique's avatar Khalique
Browse files

modify lambda to use std::min

parent 768a5eca
...@@ -18,17 +18,21 @@ namespace migraphx { ...@@ -18,17 +18,21 @@ namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS { inline namespace MIGRAPHX_INLINE_NS {
namespace op { namespace op {
struct clip : unary<clip> struct clip : unary<clip>
{ {
float max_val = std::numeric_limits<float>::max(); float max_val = std::numeric_limits<float>::max();
float min_val = std::numeric_limits<float>::min(); float min_val = std::numeric_limits<float>::min();
std::string name() const { return "clip"; } std::string name() const { return "clip"; }
auto apply() const auto apply() const
{ {
auto& max = max_val; auto& max = max_val;
auto& min = min_val; auto& min = min_val;
return [max, min](auto x) { return x > min ? (x < max ? x : max) : min; }; return [max, min](auto x) {
using type = decltype(x);
return std::min(std::max(type(min), x), type(max)); };
} }
template <class Self, class F> template <class Self, class F>
......
...@@ -148,7 +148,9 @@ struct clip_op ...@@ -148,7 +148,9 @@ struct clip_op
{ {
auto& max = op.max_val; auto& max = op.max_val;
auto& min = op.min_val; auto& min = op.min_val;
return [max, min](auto x) { return x > min ? (x < max ? x : max) : min; }; return [max, min](auto x) {
using type = decltype(x);
return std::min(std::max(type(min), x), type(max)); };
} }
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment