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
a61c9fef
"git@developer.sourcefind.cn:gaoqiong/migraphx.git" did not exist on "9aa3f5d3b9339eacc35580238341668b2d5818b7"
Commit
a61c9fef
authored
Jul 18, 2019
by
Khalique
Browse files
manual merge
parents
7115b5b8
292b6aab
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
130 additions
and
0 deletions
+130
-0
src/include/migraphx/op/rsqrt.hpp
src/include/migraphx/op/rsqrt.hpp
+23
-0
src/include/migraphx/operators.hpp
src/include/migraphx/operators.hpp
+1
-0
src/targets/gpu/CMakeLists.txt
src/targets/gpu/CMakeLists.txt
+1
-0
src/targets/gpu/device/rsqrt.cpp
src/targets/gpu/device/rsqrt.cpp
+18
-0
src/targets/gpu/include/migraphx/gpu/device/rsqrt.hpp
src/targets/gpu/include/migraphx/gpu/device/rsqrt.hpp
+20
-0
src/targets/gpu/include/migraphx/gpu/rsqrt.hpp
src/targets/gpu/include/migraphx/gpu/rsqrt.hpp
+19
-0
src/targets/gpu/lowering.cpp
src/targets/gpu/lowering.cpp
+2
-0
src/tf/tf.cpp
src/tf/tf.cpp
+1
-0
test/cpu_ops_test.cpp
test/cpu_ops_test.cpp
+14
-0
test/gpu/miopen.cpp
test/gpu/miopen.cpp
+13
-0
test/tf/rsqrt_test.pb
test/tf/rsqrt_test.pb
+8
-0
test/tf/tf_test.cpp
test/tf/tf_test.cpp
+10
-0
No files found.
src/include/migraphx/op/rsqrt.hpp
0 → 100644
View file @
a61c9fef
#ifndef MIGRAPHX_GUARD_OPERATORS_RSQRT_HPP
#define MIGRAPHX_GUARD_OPERATORS_RSQRT_HPP
#include <migraphx/op/unary.hpp>
#include <cmath>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
struct
rsqrt
:
unary
<
rsqrt
>
{
auto
apply
()
const
{
return
[](
auto
x
)
{
return
1
/
std
::
sqrt
(
x
);
};
}
};
}
// namespace op
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
#endif
src/include/migraphx/operators.hpp
View file @
a61c9fef
...
@@ -53,6 +53,7 @@
...
@@ -53,6 +53,7 @@
#include <migraphx/op/rnn.hpp>
#include <migraphx/op/rnn.hpp>
#include <migraphx/op/rnn_last_cell_output.hpp>
#include <migraphx/op/rnn_last_cell_output.hpp>
#include <migraphx/op/rnn_last_output.hpp>
#include <migraphx/op/rnn_last_output.hpp>
#include <migraphx/op/rsqrt.hpp>
#include <migraphx/op/scalar.hpp>
#include <migraphx/op/scalar.hpp>
#include <migraphx/op/sigmoid.hpp>
#include <migraphx/op/sigmoid.hpp>
#include <migraphx/op/sinh.hpp>
#include <migraphx/op/sinh.hpp>
...
...
src/targets/gpu/CMakeLists.txt
View file @
a61c9fef
...
@@ -40,6 +40,7 @@ add_library(migraphx_device
...
@@ -40,6 +40,7 @@ add_library(migraphx_device
device/div.cpp
device/div.cpp
device/clip.cpp
device/clip.cpp
device/reduce_sum.cpp
device/reduce_sum.cpp
device/rsqrt.cpp
device/sqrt.cpp
device/sqrt.cpp
device/reduce_mean.cpp
device/reduce_mean.cpp
device/pow.cpp
device/pow.cpp
...
...
src/targets/gpu/device/rsqrt.cpp
0 → 100644
View file @
a61c9fef
#include <migraphx/gpu/device/rsqrt.hpp>
#include <migraphx/gpu/device/nary.hpp>
#include <migraphx/gpu/device/types.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
gpu
{
namespace
device
{
void
rsqrt
(
hipStream_t
stream
,
const
argument
&
result
,
const
argument
&
arg
)
{
nary
(
stream
,
result
,
arg
)([](
auto
x
)
__device__
{
return
::
rsqrt
(
to_hip_type
(
x
));
});
}
}
// namespace device
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
src/targets/gpu/include/migraphx/gpu/device/rsqrt.hpp
0 → 100644
View file @
a61c9fef
#ifndef MIGRAPHX_GUARD_RTGLIB_DEVICE_RSQRT_HPP
#define MIGRAPHX_GUARD_RTGLIB_DEVICE_RSQRT_HPP
#include <migraphx/argument.hpp>
#include <migraphx/config.hpp>
#include <hip/hip_runtime_api.h>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
gpu
{
namespace
device
{
void
rsqrt
(
hipStream_t
stream
,
const
argument
&
result
,
const
argument
&
arg
);
}
// namespace device
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
#endif
src/targets/gpu/include/migraphx/gpu/rsqrt.hpp
0 → 100644
View file @
a61c9fef
#ifndef MIGRAPHX_GUARD_RTGLIB_RSQRT_HPP
#define MIGRAPHX_GUARD_RTGLIB_RSQRT_HPP
#include <migraphx/gpu/oper.hpp>
#include <migraphx/gpu/device/rsqrt.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
gpu
{
struct
hip_rsqrt
:
unary_device
<
hip_rsqrt
,
device
::
rsqrt
>
{
};
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
#endif
src/targets/gpu/lowering.cpp
View file @
a61c9fef
...
@@ -52,6 +52,7 @@
...
@@ -52,6 +52,7 @@
#include <migraphx/gpu/convert.hpp>
#include <migraphx/gpu/convert.hpp>
#include <migraphx/gpu/clip.hpp>
#include <migraphx/gpu/clip.hpp>
#include <migraphx/gpu/reduce_sum.hpp>
#include <migraphx/gpu/reduce_sum.hpp>
#include <migraphx/gpu/rsqrt.hpp>
#include <migraphx/gpu/sqrt.hpp>
#include <migraphx/gpu/sqrt.hpp>
#include <migraphx/gpu/reduce_mean.hpp>
#include <migraphx/gpu/reduce_mean.hpp>
#include <migraphx/gpu/pow.hpp>
#include <migraphx/gpu/pow.hpp>
...
@@ -107,6 +108,7 @@ struct miopen_apply
...
@@ -107,6 +108,7 @@ struct miopen_apply
add_generic_op
<
hip_div
>
(
"div"
);
add_generic_op
<
hip_div
>
(
"div"
);
add_generic_op
<
hip_max
>
(
"max"
);
add_generic_op
<
hip_max
>
(
"max"
);
add_generic_op
<
hip_min
>
(
"min"
);
add_generic_op
<
hip_min
>
(
"min"
);
add_generic_op
<
hip_rsqrt
>
(
"rsqrt"
);
add_generic_op
<
hip_pow
>
(
"pow"
);
add_generic_op
<
hip_pow
>
(
"pow"
);
add_generic_op
<
hip_sqdiff
>
(
"sqdiff"
);
add_generic_op
<
hip_sqdiff
>
(
"sqdiff"
);
...
...
src/tf/tf.cpp
View file @
a61c9fef
...
@@ -154,6 +154,7 @@ struct tf_parser
...
@@ -154,6 +154,7 @@ struct tf_parser
add_generic_op
(
"Identity"
,
op
::
identity
{});
add_generic_op
(
"Identity"
,
op
::
identity
{});
add_generic_op
(
"Relu"
,
op
::
relu
{});
add_generic_op
(
"Relu"
,
op
::
relu
{});
add_generic_op
(
"Relu6"
,
op
::
clip
{
6.0
,
0.0
});
add_generic_op
(
"Relu6"
,
op
::
clip
{
6.0
,
0.0
});
add_generic_op
(
"Rsqrt"
,
op
::
rsqrt
{});
add_generic_op
(
"Tanh"
,
op
::
tanh
{});
add_generic_op
(
"Tanh"
,
op
::
tanh
{});
add_generic_op
(
"StopGradient"
,
op
::
identity
{});
add_generic_op
(
"StopGradient"
,
op
::
identity
{});
...
...
test/cpu_ops_test.cpp
View file @
a61c9fef
...
@@ -1808,6 +1808,20 @@ TEST_CASE(reduce_sum_axis12)
...
@@ -1808,6 +1808,20 @@ TEST_CASE(reduce_sum_axis12)
EXPECT
(
results_vector
==
gold
);
EXPECT
(
results_vector
==
gold
);
}
}
TEST_CASE
(
rsqrt_test
)
{
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
}};
auto
l
=
p
.
add_literal
(
migraphx
::
literal
{
s
,
{
4.0
,
16.0
,
64.0
}});
p
.
add_instruction
(
migraphx
::
op
::
rsqrt
{},
l
);
p
.
compile
(
migraphx
::
cpu
::
target
{});
auto
result
=
p
.
eval
({});
std
::
vector
<
float
>
results_vector
(
3
);
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
=
{
0.5
,
0.25
,
0.125
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
reduce_mean_axis1
)
TEST_CASE
(
reduce_mean_axis1
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
...
...
test/gpu/miopen.cpp
View file @
a61c9fef
...
@@ -3570,6 +3570,19 @@ struct test_reduce_sum_half : verify_program<test_reduce_sum_half>
...
@@ -3570,6 +3570,19 @@ struct test_reduce_sum_half : verify_program<test_reduce_sum_half>
};
};
};
};
struct
test_rsqrt
:
verify_program
<
test_rsqrt
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
16
,
16
}};
auto
x
=
p
.
add_parameter
(
"x"
,
s
);
auto
l0
=
p
.
add_instruction
(
migraphx
::
op
::
clip
{
std
::
numeric_limits
<
float
>::
max
(),
1.0
},
x
);
p
.
add_instruction
(
migraphx
::
op
::
rsqrt
{},
l0
);
return
p
;
};
};
struct
test_reduce_mean
:
verify_program
<
test_reduce_mean
>
struct
test_reduce_mean
:
verify_program
<
test_reduce_mean
>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
...
...
test/tf/rsqrt_test.pb
0 → 100644
View file @
a61c9fef
:
0Placeholder*
shape:*
dtype0
rsqrtRsqrt0*
T0"
\ No newline at end of file
test/tf/tf_test.cpp
View file @
a61c9fef
...
@@ -351,6 +351,16 @@ TEST_CASE(reshape_test)
...
@@ -351,6 +351,16 @@ TEST_CASE(reshape_test)
EXPECT
(
p
==
prog
);
EXPECT
(
p
==
prog
);
}
}
TEST_CASE
(
rsqrt_test
)
{
migraphx
::
program
p
;
auto
l0
=
p
.
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
16
,
16
}});
p
.
add_instruction
(
migraphx
::
op
::
rsqrt
{},
l0
);
auto
prog
=
optimize_tf
(
"rsqrt_test.pb"
,
false
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
slice_test
)
TEST_CASE
(
slice_test
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
...
...
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