Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
f26d3d2d
Commit
f26d3d2d
authored
Apr 30, 2019
by
Khalique
Browse files
modify lambda to use std::min
parent
768a5eca
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
src/include/migraphx/op/clip.hpp
src/include/migraphx/op/clip.hpp
+5
-1
src/targets/cpu/lowering.cpp
src/targets/cpu/lowering.cpp
+3
-1
No files found.
src/include/migraphx/op/clip.hpp
View file @
f26d3d2d
...
...
@@ -18,17 +18,21 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
struct
clip
:
unary
<
clip
>
{
float
max_val
=
std
::
numeric_limits
<
float
>::
max
();
float
min_val
=
std
::
numeric_limits
<
float
>::
min
();
std
::
string
name
()
const
{
return
"clip"
;
}
auto
apply
()
const
{
auto
&
max
=
max_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
>
...
...
src/targets/cpu/lowering.cpp
View file @
f26d3d2d
...
...
@@ -148,7 +148,9 @@ struct clip_op
{
auto
&
max
=
op
.
max_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
));
};
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment