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
3e0b715a
Commit
3e0b715a
authored
Apr 29, 2019
by
Khalique
Browse files
manual merge
parents
f4178abd
6f115a0f
Changes
40
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
163 additions
and
75 deletions
+163
-75
src/CMakeLists.txt
src/CMakeLists.txt
+1
-1
src/constant_propagate.cpp
src/constant_propagate.cpp
+0
-30
src/include/migraphx/make_signed.hpp
src/include/migraphx/make_signed.hpp
+22
-0
src/include/migraphx/op/abs.hpp
src/include/migraphx/op/abs.hpp
+6
-2
src/include/migraphx/op/acos.hpp
src/include/migraphx/op/acos.hpp
+5
-2
src/include/migraphx/op/add.hpp
src/include/migraphx/op/add.hpp
+5
-2
src/include/migraphx/op/asin.hpp
src/include/migraphx/op/asin.hpp
+5
-2
src/include/migraphx/op/atan.hpp
src/include/migraphx/op/atan.hpp
+5
-2
src/include/migraphx/op/binary.hpp
src/include/migraphx/op/binary.hpp
+29
-14
src/include/migraphx/op/cos.hpp
src/include/migraphx/op/cos.hpp
+5
-2
src/include/migraphx/op/cosh.hpp
src/include/migraphx/op/cosh.hpp
+5
-2
src/include/migraphx/op/div.hpp
src/include/migraphx/op/div.hpp
+5
-2
src/include/migraphx/op/exp.hpp
src/include/migraphx/op/exp.hpp
+5
-2
src/include/migraphx/op/log.hpp
src/include/migraphx/op/log.hpp
+5
-2
src/include/migraphx/op/max.hpp
src/include/migraphx/op/max.hpp
+5
-2
src/include/migraphx/op/min.hpp
src/include/migraphx/op/min.hpp
+5
-2
src/include/migraphx/op/mul.hpp
src/include/migraphx/op/mul.hpp
+5
-2
src/include/migraphx/op/name.hpp
src/include/migraphx/op/name.hpp
+35
-0
src/include/migraphx/op/neg.hpp
src/include/migraphx/op/neg.hpp
+5
-2
src/include/migraphx/op/relu.hpp
src/include/migraphx/op/relu.hpp
+5
-2
No files found.
src/CMakeLists.txt
View file @
3e0b715a
...
...
@@ -5,7 +5,7 @@ include(ROCMPackageConfigHelpers)
add_library
(
migraphx
auto_contiguous.cpp
common_subexpression_elimination.cpp
constant_
propagate.cpp
propagate
_constant
.cpp
dead_code_elimination.cpp
eliminate_allocation.cpp
eliminate_contiguous.cpp
...
...
src/constant_propagate.cpp
deleted
100644 → 0
View file @
f4178abd
#include <migraphx/constant_propagate.hpp>
#include <migraphx/program.hpp>
#include <migraphx/matcher.hpp>
#include <migraphx/literal.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
struct
match_const_add
{
auto
matcher
()
const
{
return
match
::
name
(
"add"
)(
match
::
args
(
match
::
name
(
"@literal"
),
match
::
name
(
"@literal"
)));
}
void
apply
(
program
&
p
,
const
match
::
matcher_result
&
r
)
const
{
auto
ins
=
r
.
result
;
auto
arg1
=
ins
->
inputs
().
at
(
0
)
->
get_literal
();
auto
arg2
=
ins
->
inputs
().
at
(
1
)
->
get_literal
();
auto
sum
=
p
.
add_literal
(
transform
(
arg1
,
arg2
,
[](
auto
x
,
auto
y
)
{
return
x
+
y
;
}));
p
.
replace_instruction
(
ins
,
sum
);
}
};
void
constant_propagate
::
apply
(
program
&
p
)
const
{
match
::
find_matches
(
p
,
match_const_add
{});
}
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
src/include/migraphx/make_signed.hpp
0 → 100644
View file @
3e0b715a
#ifndef MIGRAPHX_GUARD_RTGLIB_MAKE_SIGNED_HPP
#define MIGRAPHX_GUARD_RTGLIB_MAKE_SIGNED_HPP
#include <migraphx/config.hpp>
#include <type_traits>
#include <utility>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
template
<
class
T
>
typename
std
::
conditional_t
<
std
::
is_integral
<
T
>
{},
std
::
make_signed
<
T
>
,
std
::
enable_if
<
true
,
T
>>::
type
make_signed
(
T
x
)
{
return
x
;
}
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
#endif
src/include/migraphx/op/abs.hpp
View file @
3e0b715a
...
...
@@ -10,6 +10,7 @@
#include <migraphx/literal.hpp>
#include <migraphx/shape_for_each.hpp>
#include <migraphx/config.hpp>
#include <migraphx/make_signed.hpp>
#include <cmath>
#include <utility>
...
...
@@ -17,9 +18,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
struct
abs
:
unary
struct
abs
:
unary
<
abs
>
{
std
::
string
name
()
const
{
return
"abs"
;
}
auto
apply
()
const
{
return
[](
auto
x
)
{
return
std
::
abs
(
make_signed
(
x
));
};
}
};
}
// namespace op
...
...
src/include/migraphx/op/acos.hpp
View file @
3e0b715a
...
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
struct
acos
:
unary
struct
acos
:
unary
<
acos
>
{
std
::
string
name
()
const
{
return
"acos"
;
}
auto
apply
()
const
{
return
[](
auto
x
)
{
return
std
::
acos
(
x
);
};
}
};
}
// namespace op
...
...
src/include/migraphx/op/add.hpp
View file @
3e0b715a
...
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
struct
add
:
binary
struct
add
:
binary
<
add
>
{
std
::
string
name
()
const
{
return
"add"
;
}
auto
apply
()
const
{
return
[](
auto
x
,
auto
y
)
{
return
x
+
y
;
};
}
};
}
// namespace op
...
...
src/include/migraphx/op/asin.hpp
View file @
3e0b715a
...
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
struct
asin
:
unary
struct
asin
:
unary
<
asin
>
{
std
::
string
name
()
const
{
return
"asin"
;
}
auto
apply
()
const
{
return
[](
auto
x
)
{
return
std
::
asin
(
x
);
};
}
};
}
// namespace op
...
...
src/include/migraphx/op/atan.hpp
View file @
3e0b715a
...
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
struct
atan
:
unary
struct
atan
:
unary
<
atan
>
{
std
::
string
name
()
const
{
return
"atan"
;
}
auto
apply
()
const
{
return
[](
auto
x
)
{
return
std
::
atan
(
x
);
};
}
};
}
// namespace op
...
...
src/include/migraphx/op/binary.hpp
View file @
3e0b715a
#ifndef MIGRAPHX_GUARD_OPERATORS_BINARY_HPP
#define MIGRAPHX_GUARD_OPERATORS_BINARY_HPP
#include <array>
#include <migraphx/operation.hpp>
#include <migraphx/check_shapes.hpp>
#include <migraphx/stringutils.hpp>
#include <migraphx/streamutils.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/shape_for_each.hpp>
#include <migraphx/config.hpp>
#include <cmath>
#include <utility>
#include <migraphx/op/name.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
struct
binary
template
<
class
Derived
>
struct
binary
:
op_name
<
Derived
>
{
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
check_shapes
{
inputs
}.
has
(
2
).
same_type
().
same_dims
();
auto
t
=
inputs
.
at
(
0
).
type
();
auto
lens
=
inputs
.
at
(
0
).
lens
();
return
{
t
,
lens
};
const
auto
&
s
=
inputs
.
front
();
if
(
s
.
scalar
()
and
s
.
elements
()
==
1
)
return
{
s
.
type
()};
return
{
s
.
type
(),
s
.
lens
()};
}
argument
compute
(
const
shape
&
output_shape
,
std
::
vector
<
argument
>
args
)
const
{
argument
result
{
output_shape
};
visit_all
(
result
,
args
[
0
],
args
[
1
])([
&
](
auto
output
,
auto
input1
,
auto
input2
)
{
if
(
input1
.
get_shape
().
standard
()
and
input2
.
get_shape
().
standard
())
{
std
::
transform
(
input1
.
begin
(),
input1
.
end
(),
input2
.
begin
(),
output
.
begin
(),
static_cast
<
const
Derived
&>
(
*
this
).
apply
());
}
else
{
shape_for_each
(
output
.
get_shape
(),
[
&
](
const
auto
&
idx
)
{
output
(
idx
.
begin
(),
idx
.
end
())
=
static_cast
<
const
Derived
&>
(
*
this
).
apply
()(
input1
(
idx
.
begin
(),
idx
.
end
()),
input2
(
idx
.
begin
(),
idx
.
end
()));
});
}
});
return
result
;
}
};
...
...
src/include/migraphx/op/cos.hpp
View file @
3e0b715a
...
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
struct
cos
:
unary
struct
cos
:
unary
<
cos
>
{
std
::
string
name
()
const
{
return
"cos"
;
}
auto
apply
()
const
{
return
[](
auto
x
)
{
return
std
::
cos
(
x
);
};
}
};
}
// namespace op
...
...
src/include/migraphx/op/cosh.hpp
View file @
3e0b715a
...
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
struct
cosh
:
unary
struct
cosh
:
unary
<
cosh
>
{
std
::
string
name
()
const
{
return
"cosh"
;
}
auto
apply
()
const
{
return
[](
auto
x
)
{
return
std
::
cosh
(
x
);
};
}
};
}
// namespace op
...
...
src/include/migraphx/op/div.hpp
View file @
3e0b715a
...
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
struct
div
:
binary
struct
div
:
binary
<
div
>
{
std
::
string
name
()
const
{
return
"div"
;
}
auto
apply
()
const
{
return
[](
auto
x
,
auto
y
)
{
return
x
/
y
;
};
}
};
}
// namespace op
...
...
src/include/migraphx/op/exp.hpp
View file @
3e0b715a
...
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
struct
exp
:
unary
struct
exp
:
unary
<
exp
>
{
std
::
string
name
()
const
{
return
"exp"
;
}
auto
apply
()
const
{
return
[](
auto
x
)
{
return
std
::
exp
(
x
);
};
}
};
}
// namespace op
...
...
src/include/migraphx/op/log.hpp
View file @
3e0b715a
...
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
struct
log
:
unary
struct
log
:
unary
<
log
>
{
std
::
string
name
()
const
{
return
"log"
;
}
auto
apply
()
const
{
return
[](
auto
x
)
{
return
std
::
log
(
x
);
};
}
};
}
// namespace op
...
...
src/include/migraphx/op/max.hpp
View file @
3e0b715a
...
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
struct
max
:
binary
struct
max
:
binary
<
max
>
{
std
::
string
name
()
const
{
return
"max"
;
}
auto
apply
()
const
{
return
[](
auto
x
,
auto
y
)
{
return
std
::
max
(
x
,
y
);
};
}
};
}
// namespace op
...
...
src/include/migraphx/op/min.hpp
View file @
3e0b715a
...
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
struct
min
:
binary
struct
min
:
binary
<
min
>
{
std
::
string
name
()
const
{
return
"min"
;
}
auto
apply
()
const
{
return
[](
auto
x
,
auto
y
)
{
return
std
::
min
(
x
,
y
);
};
}
};
}
// namespace op
...
...
src/include/migraphx/op/mul.hpp
View file @
3e0b715a
...
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
struct
mul
:
binary
struct
mul
:
binary
<
mul
>
{
std
::
string
name
()
const
{
return
"mul"
;
}
auto
apply
()
const
{
return
[](
auto
x
,
auto
y
)
{
return
x
*
y
;
};
}
};
}
// namespace op
...
...
src/include/migraphx/op/name.hpp
0 → 100644
View file @
3e0b715a
#ifndef MIGRAPHX_GUARD_RTGLIB_NAME_HPP
#define MIGRAPHX_GUARD_RTGLIB_NAME_HPP
#include <array>
#include <migraphx/operation.hpp>
#include <migraphx/check_shapes.hpp>
#include <migraphx/stringutils.hpp>
#include <migraphx/streamutils.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/shape_for_each.hpp>
#include <migraphx/type_name.hpp>
#include <migraphx/config.hpp>
#include <cmath>
#include <utility>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
/// Create name from class
template
<
class
Derived
>
struct
op_name
{
std
::
string
name
()
const
{
static
const
std
::
string
&
name
=
get_type_name
<
Derived
>
();
return
name
.
substr
(
name
.
rfind
(
"::"
)
+
2
);
}
};
}
// namespace op
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
#endif
src/include/migraphx/op/neg.hpp
View file @
3e0b715a
...
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
struct
neg
:
unary
struct
neg
:
unary
<
neg
>
{
std
::
string
name
()
const
{
return
"neg"
;
}
auto
apply
()
const
{
return
[](
auto
x
)
{
return
-
x
;
};
}
};
}
// namespace op
...
...
src/include/migraphx/op/relu.hpp
View file @
3e0b715a
...
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
struct
relu
:
unary
struct
relu
:
unary
<
relu
>
{
std
::
string
name
()
const
{
return
"relu"
;
}
auto
apply
()
const
{
return
[](
auto
x
)
{
return
std
::
max
(
decltype
(
x
){
0
},
x
);
};
}
};
}
// namespace op
...
...
Prev
1
2
Next
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