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
f46c7008
Unverified
Commit
f46c7008
authored
Nov 16, 2018
by
Paul Fultz II
Committed by
GitHub
Nov 16, 2018
Browse files
Merge pull request #118 from ROCmSoftwarePlatform/addSinOperator
Add sin operator
parents
e1bc4b99
4aecb94d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
128 additions
and
0 deletions
+128
-0
src/targets/gpu/CMakeLists.txt
src/targets/gpu/CMakeLists.txt
+2
-0
src/targets/gpu/device/sin.cpp
src/targets/gpu/device/sin.cpp
+18
-0
src/targets/gpu/include/migraphx/gpu/device/sin.hpp
src/targets/gpu/include/migraphx/gpu/device/sin.hpp
+21
-0
src/targets/gpu/include/migraphx/gpu/sin.hpp
src/targets/gpu/include/migraphx/gpu/sin.hpp
+37
-0
src/targets/gpu/lowering.cpp
src/targets/gpu/lowering.cpp
+11
-0
src/targets/gpu/sin.cpp
src/targets/gpu/sin.cpp
+26
-0
test/gpu/miopen.cpp
test/gpu/miopen.cpp
+13
-0
No files found.
src/targets/gpu/CMakeLists.txt
View file @
f46c7008
...
...
@@ -12,6 +12,7 @@ endif()
add_library
(
migraphx_device
device/add.cpp
device/sin.cpp
device/add_relu.cpp
device/contiguous.cpp
device/mul.cpp
...
...
@@ -38,6 +39,7 @@ add_library(migraphx_gpu
relu.cpp
leaky_relu.cpp
add.cpp
sin.cpp
mul.cpp
batchnorm.cpp
write_literals.cpp
...
...
src/targets/gpu/device/sin.cpp
0 → 100644
View file @
f46c7008
#include <migraphx/gpu/device/sin.hpp>
#include <migraphx/gpu/device/nary.hpp>
#include <migraphx/gpu/device/types.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPH_INLINE_NS
{
namespace
gpu
{
namespace
device
{
void
sin
(
hipStream_t
stream
,
const
argument
&
result
,
const
argument
&
arg
)
{
nary
(
stream
,
result
,
arg
)([](
auto
x
)
{
return
::
sin
(
x
);
});
}
}
// namespace device
}
// namespace gpu
}
// namespace MIGRAPH_INLINE_NS
}
// namespace migraphx
src/targets/gpu/include/migraphx/gpu/device/sin.hpp
0 → 100644
View file @
f46c7008
#ifndef MIGRAPH_GUARD_RTGLIB_DEVICE_ADD_HPP
#define MIGRAPH_GUARD_RTGLIB_DEVICE_ADD_HPP
#include <migraphx/argument.hpp>
#include <migraphx/config.hpp>
#include <hip/hip_runtime_api.h>
namespace
migraphx
{
inline
namespace
MIGRAPH_INLINE_NS
{
namespace
gpu
{
namespace
device
{
void
sin
(
hipStream_t
stream
,
const
argument
&
result
,
const
argument
&
arg
);
}
// namespace device
}
// namespace gpu
}
// namespace MIGRAPH_INLINE_NS
}
// namespace migraphx
#endif
src/targets/gpu/include/migraphx/gpu/sin.hpp
0 → 100644
View file @
f46c7008
#ifndef MIGRAPH_GUARD_RTGLIB_SIN_HPP
#define MIGRAPH_GUARD_RTGLIB_SIN_HPP
#include <migraphx/gpu/lowering.hpp>
#include <migraphx/manage_ptr.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/operators.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/shape_for_each.hpp>
#include <migraphx/gpu/miopen.hpp>
#include <migraphx/gpu/hip.hpp>
#include <migraphx/dfor.hpp>
#include <migraphx/gpu/device/contiguous.hpp>
#include <migraphx/gpu/device/sin.hpp>
#include <migraphx/iterator_for.hpp>
#include <migraphx/gpu/rocblas.hpp>
#include <migraphx/gpu/context.hpp>
#include <migraphx/config.hpp>
#include <utility>
namespace
migraphx
{
inline
namespace
MIGRAPH_INLINE_NS
{
namespace
gpu
{
struct
hip_sin
{
std
::
string
name
()
const
{
return
"gpu::sin"
;
}
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
;
argument
compute
(
context
&
,
const
shape
&
,
const
std
::
vector
<
argument
>&
args
)
const
;
int
output_alias
(
const
std
::
vector
<
shape
>&
shapes
)
const
{
return
shapes
.
size
()
-
1
;
}
};
}
// namespace gpu
}
// namespace MIGRAPH_INLINE_NS
}
// namespace migraphx
#endif
src/targets/gpu/lowering.cpp
View file @
f46c7008
...
...
@@ -19,6 +19,7 @@
#include <migraphx/gpu/leaky_relu.hpp>
#include <migraphx/gpu/softmax.hpp>
#include <migraphx/gpu/add.hpp>
#include <migraphx/gpu/sin.hpp>
#include <migraphx/gpu/mul.hpp>
#include <migraphx/gpu/batchnorm.hpp>
#include <migraphx/gpu/pooling.hpp>
...
...
@@ -67,6 +68,10 @@ struct miopen_apply
{
check_shape
(
s
,
apply_add
(
it
));
}
else
if
(
it
->
name
()
==
"sin"
)
{
check_shape
(
s
,
apply_sin
(
it
));
}
else
if
(
it
->
name
()
==
"mul"
)
{
check_shape
(
s
,
apply_mul
(
it
));
...
...
@@ -165,6 +170,12 @@ struct miopen_apply
ins
,
hip_add
{},
ins
->
inputs
().
at
(
0
),
ins
->
inputs
().
at
(
1
),
output
);
}
instruction_ref
apply_sin
(
instruction_ref
ins
)
{
auto
output
=
insert_allocation
(
ins
,
ins
->
get_shape
());
return
prog
->
replace_instruction
(
ins
,
hip_sin
{},
ins
->
inputs
().
at
(
0
),
output
);
}
instruction_ref
apply_mul
(
instruction_ref
ins
)
{
auto
output
=
insert_allocation
(
ins
,
ins
->
get_shape
());
...
...
src/targets/gpu/sin.cpp
0 → 100644
View file @
f46c7008
#include <migraphx/gpu/sin.hpp>
#include <migraphx/operators.hpp>
#include <migraphx/manage_ptr.hpp>
#include <migraphx/config.hpp>
#include <migraphx/gpu/miopen.hpp>
#include <utility>
namespace
migraphx
{
inline
namespace
MIGRAPH_INLINE_NS
{
namespace
gpu
{
shape
hip_sin
::
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
{
check_shapes
{
inputs
,
*
this
}.
has
(
2
);
return
inputs
.
at
(
0
);
}
argument
hip_sin
::
compute
(
context
&
ctx
,
const
shape
&
,
const
std
::
vector
<
argument
>&
args
)
const
{
device
::
sin
(
ctx
.
get_stream
().
get
(),
args
[
1
],
args
[
0
]);
return
args
[
1
];
}
}
// namespace gpu
}
// namespace MIGRAPH_INLINE_NS
}
// namespace migraphx
test/gpu/miopen.cpp
View file @
f46c7008
...
...
@@ -203,6 +203,18 @@ struct test_mul
}
};
struct
test_sin
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
10
}};
auto
x
=
p
.
add_parameter
(
"x"
,
s
);
p
.
add_instruction
(
migraphx
::
op
::
sin
{},
x
);
return
p
;
}
};
struct
test_scale
{
migraphx
::
program
create_program
()
const
...
...
@@ -843,6 +855,7 @@ int main()
verify_program
<
test_add
>
();
verify_program
<
test_add_half
>
();
verify_program
<
test_mul
>
();
verify_program
<
test_sin
>
();
verify_program
<
test_scale
>
();
verify_program
<
test_triadd
>
();
verify_program
<
test_triadd2
>
();
...
...
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