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
d2968df8
Commit
d2968df8
authored
May 01, 2019
by
Paul
Browse files
Merge branch 'develop' into reshape
parents
b49d8e66
17bc98d0
Changes
47
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
167 additions
and
77 deletions
+167
-77
README.md
README.md
+8
-4
src/CMakeLists.txt
src/CMakeLists.txt
+2
-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
No files found.
README.md
View file @
d2968df8
...
@@ -12,14 +12,18 @@ AMD's graph optimization engine.
...
@@ -12,14 +12,18 @@ AMD's graph optimization engine.
## Installing the dependencies
## Installing the dependencies
The dependencies can be installed with the
`install_deps.cmake`
, script:
`cmake -P install_deps.cmake`
.
Dependencies can be installed using the ROCm build tool
[
rbuild
](
https://github.com/RadeonOpenCompute/rbuild
)
.
This will install by default to
`/usr/local`
but it can be installed in another location with
`--prefix`
argument:
To install rbuild:
```
```
cmake -P install_deps.cmake --prefix /some/local/dir
pip install https://github.com/RadeonOpenCompute/rbuild/archive/master.tar.gz
```
```
To build dependencies along with MIGraphX
```
rbuild build -d depend --cxx=/opt/rocm/bin/hcc
```
This builds dependencies in the subdirectory named depend and then builds MIGraphX using these dependencies.
## Building MIGraphX from source
## Building MIGraphX from source
...
...
src/CMakeLists.txt
View file @
d2968df8
...
@@ -5,7 +5,7 @@ include(ROCMPackageConfigHelpers)
...
@@ -5,7 +5,7 @@ include(ROCMPackageConfigHelpers)
add_library
(
migraphx
add_library
(
migraphx
auto_contiguous.cpp
auto_contiguous.cpp
common_subexpression_elimination.cpp
common_subexpression_elimination.cpp
constant_
propagate.cpp
propagate
_constant
.cpp
dead_code_elimination.cpp
dead_code_elimination.cpp
eliminate_allocation.cpp
eliminate_allocation.cpp
eliminate_contiguous.cpp
eliminate_contiguous.cpp
...
@@ -20,6 +20,7 @@ add_library(migraphx
...
@@ -20,6 +20,7 @@ add_library(migraphx
program.cpp
program.cpp
shape.cpp
shape.cpp
schedule.cpp
schedule.cpp
pass_manager.cpp
simplify_algebra.cpp
simplify_algebra.cpp
simplify_reshapes.cpp
simplify_reshapes.cpp
opt/memory_coloring.cpp
opt/memory_coloring.cpp
...
...
src/constant_propagate.cpp
deleted
100644 → 0
View file @
b49d8e66
#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 @
d2968df8
#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 @
d2968df8
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#include <migraphx/literal.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/shape_for_each.hpp>
#include <migraphx/shape_for_each.hpp>
#include <migraphx/config.hpp>
#include <migraphx/config.hpp>
#include <migraphx/make_signed.hpp>
#include <cmath>
#include <cmath>
#include <utility>
#include <utility>
...
@@ -17,9 +18,12 @@ namespace migraphx {
...
@@ -17,9 +18,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
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
}
// namespace op
...
...
src/include/migraphx/op/acos.hpp
View file @
d2968df8
...
@@ -17,9 +17,12 @@ namespace migraphx {
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
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
}
// namespace op
...
...
src/include/migraphx/op/add.hpp
View file @
d2968df8
...
@@ -17,9 +17,12 @@ namespace migraphx {
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
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
}
// namespace op
...
...
src/include/migraphx/op/asin.hpp
View file @
d2968df8
...
@@ -17,9 +17,12 @@ namespace migraphx {
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
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
}
// namespace op
...
...
src/include/migraphx/op/atan.hpp
View file @
d2968df8
...
@@ -17,9 +17,12 @@ namespace migraphx {
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
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
}
// namespace op
...
...
src/include/migraphx/op/binary.hpp
View file @
d2968df8
#ifndef MIGRAPHX_GUARD_OPERATORS_BINARY_HPP
#ifndef MIGRAPHX_GUARD_OPERATORS_BINARY_HPP
#define MIGRAPHX_GUARD_OPERATORS_BINARY_HPP
#define MIGRAPHX_GUARD_OPERATORS_BINARY_HPP
#include <array>
#include <migraphx/op/name.hpp>
#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>
namespace
migraphx
{
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
namespace
op
{
struct
binary
template
<
class
Derived
>
struct
binary
:
op_name
<
Derived
>
{
{
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
{
check_shapes
{
inputs
}.
has
(
2
).
same_type
().
same_dims
();
check_shapes
{
inputs
}.
has
(
2
).
same_type
().
same_dims
();
auto
t
=
inputs
.
at
(
0
).
type
();
const
auto
&
s
=
inputs
.
front
();
auto
lens
=
inputs
.
at
(
0
).
lens
();
if
(
s
.
scalar
()
and
s
.
elements
()
==
1
)
return
{
t
,
lens
};
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 @
d2968df8
...
@@ -17,9 +17,12 @@ namespace migraphx {
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
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
}
// namespace op
...
...
src/include/migraphx/op/cosh.hpp
View file @
d2968df8
...
@@ -17,9 +17,12 @@ namespace migraphx {
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
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
}
// namespace op
...
...
src/include/migraphx/op/div.hpp
View file @
d2968df8
...
@@ -17,9 +17,12 @@ namespace migraphx {
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
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
}
// namespace op
...
...
src/include/migraphx/op/exp.hpp
View file @
d2968df8
...
@@ -17,9 +17,12 @@ namespace migraphx {
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
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
}
// namespace op
...
...
src/include/migraphx/op/log.hpp
View file @
d2968df8
...
@@ -17,9 +17,12 @@ namespace migraphx {
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
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
}
// namespace op
...
...
src/include/migraphx/op/max.hpp
View file @
d2968df8
...
@@ -17,9 +17,12 @@ namespace migraphx {
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
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
}
// namespace op
...
...
src/include/migraphx/op/min.hpp
View file @
d2968df8
...
@@ -17,9 +17,12 @@ namespace migraphx {
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
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
}
// namespace op
...
...
src/include/migraphx/op/mul.hpp
View file @
d2968df8
...
@@ -17,9 +17,12 @@ namespace migraphx {
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
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
}
// namespace op
...
...
src/include/migraphx/op/name.hpp
0 → 100644
View file @
d2968df8
#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 @
d2968df8
...
@@ -17,9 +17,12 @@ namespace migraphx {
...
@@ -17,9 +17,12 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
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
}
// namespace op
...
...
Prev
1
2
3
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