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
8ea9fc25
"example/vscode:/vscode.git/clone" did not exist on "9b7093aac0d93b37691454d5ff632b208e6b953f"
Commit
8ea9fc25
authored
Nov 19, 2018
by
Khalique
Browse files
formatting
parent
9cf50769
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
17 deletions
+88
-17
src/onnx/onnx.cpp
src/onnx/onnx.cpp
+2
-3
src/targets/cpu/lowering.cpp
src/targets/cpu/lowering.cpp
+5
-4
src/targets/gpu/elu.cpp
src/targets/gpu/elu.cpp
+38
-0
src/targets/gpu/include/migraphx/gpu/elu.hpp
src/targets/gpu/include/migraphx/gpu/elu.hpp
+39
-0
test/cpu_ops_test.cpp
test/cpu_ops_test.cpp
+4
-10
No files found.
src/onnx/onnx.cpp
View file @
8ea9fc25
...
@@ -391,9 +391,8 @@ struct onnx_parser
...
@@ -391,9 +391,8 @@ struct onnx_parser
return
prog
.
add_instruction
(
op
,
args
.
front
());
return
prog
.
add_instruction
(
op
,
args
.
front
());
}
}
instruction_ref
parse_elu
(
const
std
::
string
&
,
instruction_ref
attribute_map
attributes
,
parse_elu
(
const
std
::
string
&
,
attribute_map
attributes
,
std
::
vector
<
instruction_ref
>
args
)
std
::
vector
<
instruction_ref
>
args
)
{
{
float
alpha
=
1.0
;
// default alpha val for elu
float
alpha
=
1.0
;
// default alpha val for elu
if
(
contains
(
attributes
,
"alpha"
))
if
(
contains
(
attributes
,
"alpha"
))
...
...
src/targets/cpu/lowering.cpp
View file @
8ea9fc25
...
@@ -19,9 +19,10 @@ T zero(const T&)
...
@@ -19,9 +19,10 @@ T zero(const T&)
return
T
(
0
);
return
T
(
0
);
}
}
template
<
class
T
>
template
<
class
T
>
typename
std
::
conditional_t
<
std
::
is_integral
<
T
>
{},
std
::
make_signed
<
T
>
,
std
::
enable_if
<
true
,
T
>>::
type
typename
std
::
conditional_t
<
std
::
is_integral
<
T
>
{},
std
::
make_signed
<
T
>
,
std
::
enable_if
<
true
,
T
>>::
make_signed
(
T
x
)
type
make_signed
(
T
x
)
{
{
return
x
;
return
x
;
}
}
...
...
src/targets/gpu/elu.cpp
0 → 100644
View file @
8ea9fc25
#include <migraphx/gpu/elu.hpp>
#include <migraphx/operators.hpp>
#include <migraphx/manage_ptr.hpp>
#include <migraphx/gpu/miopen.hpp>
#include <utility>
namespace
migraphx
{
inline
namespace
MIGRAPH_INLINE_NS
{
namespace
gpu
{
shape
miopen_elu
::
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
{
check_shapes
{
inputs
,
*
this
}.
has
(
2
).
not_broadcasted
();
return
inputs
.
at
(
1
);
}
argument
miopen_elu
::
compute
(
context
&
ctx
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>&
args
)
const
{
float
alpha
=
1
,
beta
=
0
;
auto
x_desc
=
make_tensor
(
args
[
0
].
get_shape
());
auto
y_desc
=
make_tensor
(
output_shape
);
miopenActivationForward
(
ctx
.
get_stream
().
get_miopen
(),
ad
.
get
(),
&
alpha
,
x_desc
.
get
(),
args
[
0
].
implicit
(),
&
beta
,
y_desc
.
get
(),
args
[
1
].
implicit
());
return
args
[
1
];
}
}
// namespace gpu
}
// namespace MIGRAPH_INLINE_NS
}
// namespace migraphx
src/targets/gpu/include/migraphx/gpu/elu.hpp
0 → 100644
View file @
8ea9fc25
#ifndef MIGRAPH_GUARD_RTGLIB_ELU_HPP
#define MIGRAPH_GUARD_RTGLIB_ELU_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/config.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/add.hpp>
#include <migraphx/iterator_for.hpp>
#include <migraphx/gpu/rocblas.hpp>
#include <migraphx/gpu/context.hpp>
#include <utility>
namespace
migraphx
{
inline
namespace
MIGRAPH_INLINE_NS
{
namespace
gpu
{
struct
miopen_elu
{
shared
<
activation_descriptor
>
ad
;
std
::
string
name
()
const
{
return
"gpu::elu"
;
}
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
;
argument
compute
(
context
&
ctx
,
const
shape
&
output_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
test/cpu_ops_test.cpp
View file @
8ea9fc25
...
@@ -7,15 +7,9 @@
...
@@ -7,15 +7,9 @@
#include <migraphx/verify.hpp>
#include <migraphx/verify.hpp>
#include "test.hpp"
#include "test.hpp"
float
sigmoid
(
float
x
)
float
sigmoid
(
float
x
)
{
return
1
/
(
1
+
expf
(
-
x
));
}
{
return
1
/
(
1
+
expf
(
-
x
));
}
float
elu
(
float
a
,
float
x
)
float
elu
(
float
a
,
float
x
)
{
return
x
>
0
?
x
:
a
*
std
::
expm1
(
x
);
}
{
return
x
>
0
?
x
:
a
*
std
::
expm1
(
x
);
}
TEST_CASE
(
slice_test
)
TEST_CASE
(
slice_test
)
{
{
...
@@ -1168,7 +1162,7 @@ TEST_CASE(elu_test)
...
@@ -1168,7 +1162,7 @@ TEST_CASE(elu_test)
auto
result
=
p
.
eval
({});
auto
result
=
p
.
eval
({});
std
::
vector
<
float
>
results_vector
(
4
);
std
::
vector
<
float
>
results_vector
(
4
);
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
elu
(
alpha
,
-
1
),
elu
(
alpha
,
2
),
elu
(
alpha
,
-
3
),
elu
(
alpha
,
4
)};
std
::
vector
<
float
>
gold
{
elu
(
alpha
,
-
1
),
elu
(
alpha
,
2
),
elu
(
alpha
,
-
3
),
elu
(
alpha
,
4
)};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
}
...
...
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