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
ac230464
Commit
ac230464
authored
May 20, 2018
by
Scott Thornton
Browse files
Merge branch 'master' of
https://github.com/ROCmSoftwarePlatform/RTGLib
parents
9a7c3e30
6f0e001e
Changes
32
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
175 additions
and
35 deletions
+175
-35
CMakeLists.txt
CMakeLists.txt
+1
-8
Jenkinsfile
Jenkinsfile
+1
-1
doc/CMakeLists.txt
doc/CMakeLists.txt
+38
-0
frontend/CMakeLists.txt
frontend/CMakeLists.txt
+0
-1
src/CMakeLists.txt
src/CMakeLists.txt
+10
-0
src/include/rtg/argument.hpp
src/include/rtg/argument.hpp
+7
-0
src/include/rtg/builtin.hpp
src/include/rtg/builtin.hpp
+6
-1
src/include/rtg/erase.hpp
src/include/rtg/erase.hpp
+0
-0
src/include/rtg/errors.hpp
src/include/rtg/errors.hpp
+0
-0
src/include/rtg/fallthrough.hpp
src/include/rtg/fallthrough.hpp
+0
-0
src/include/rtg/float_equal.hpp
src/include/rtg/float_equal.hpp
+0
-0
src/include/rtg/instruction.hpp
src/include/rtg/instruction.hpp
+0
-0
src/include/rtg/instruction_ref.hpp
src/include/rtg/instruction_ref.hpp
+0
-0
src/include/rtg/literal.hpp
src/include/rtg/literal.hpp
+0
-0
src/include/rtg/operation.hpp
src/include/rtg/operation.hpp
+38
-12
src/include/rtg/operators.hpp
src/include/rtg/operators.hpp
+38
-12
src/include/rtg/program.hpp
src/include/rtg/program.hpp
+0
-0
src/include/rtg/raw_data.hpp
src/include/rtg/raw_data.hpp
+0
-0
src/include/rtg/shape.hpp
src/include/rtg/shape.hpp
+0
-0
src/include/rtg/streamutils.hpp
src/include/rtg/streamutils.hpp
+36
-0
No files found.
CMakeLists.txt
View file @
ac230464
...
@@ -89,14 +89,7 @@ rocm_enable_cppcheck(
...
@@ -89,14 +89,7 @@ rocm_enable_cppcheck(
${
CMAKE_CURRENT_SOURCE_DIR
}
/include
${
CMAKE_CURRENT_SOURCE_DIR
}
/include
)
)
add_library
(
rtg
add_subdirectory
(
src
)
src/program.cpp
src/shape.cpp
)
rocm_clang_tidy_check
(
rtg
)
target_include_directories
(
rtg PUBLIC $<BUILD_INTERFACE:
${
CMAKE_CURRENT_SOURCE_DIR
}
/include>
)
add_subdirectory
(
frontend
)
add_subdirectory
(
doc
)
add_subdirectory
(
doc
)
add_subdirectory
(
test
)
add_subdirectory
(
test
)
add_subdirectory
(
tools
)
add_subdirectory
(
tools
)
Jenkinsfile
View file @
ac230464
...
@@ -7,7 +7,7 @@ def rocmtestnode(variant, name, body) {
...
@@ -7,7 +7,7 @@ def rocmtestnode(variant, name, body) {
mkdir build
mkdir build
cd build
cd build
CXX=${compiler} CXXFLAGS='-Werror' cmake -DCMAKE_CXX_FLAGS_DEBUG='-g -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=undefined' ${flags} ..
CXX=${compiler} CXXFLAGS='-Werror' cmake -DCMAKE_CXX_FLAGS_DEBUG='-g -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=undefined' ${flags} ..
CTEST_PARALLEL_LEVEL=32 make -j32 check
CTEST_PARALLEL_LEVEL=32 make -j32
all doc
check
"""
"""
echo
cmd
echo
cmd
sh
cmd
sh
cmd
...
...
doc/CMakeLists.txt
0 → 100644
View file @
ac230464
include
(
DoxygenDoc
)
set
(
DOXYGEN_OUTPUT
${
CMAKE_CURRENT_BINARY_DIR
}
/doxygen/
)
add_doxygen_doc
(
OUTPUT_DIRECTORY
${
DOXYGEN_OUTPUT
}
INPUT
${
CMAKE_CURRENT_SOURCE_DIR
}
/../include
${
CMAKE_CURRENT_SOURCE_DIR
}
/../src
${
CMAKE_CURRENT_SOURCE_DIR
}
/../onnx
MACRO_EXPANSION YES
RECURSIVE YES
GENERATE_XML YES
GENERATE_LATEX YES
USE_PDFLATEX YES
CALL_GRAPH YES
CALLER_GRAPH YES
BUILTIN_STL_SUPPORT YES
SORT_MEMBERS_CTORS_1ST YES
SOURCE_BROWSER YES
GENERATE_TREEVIEW YES
REFERENCED_BY_RELATION YES
REFERENCES_RELATION YES
REFERENCES_LINK_SOURCE YES
EXTRACT_ALL YES
ENUM_VALUES_PER_LINE 1
)
# include(SphinxDoc)
# add_sphinx_doc(src
# BUILDER html
# OUTPUT_DIR html
# VARS
# breathe_projects.proj=${DOXYGEN_OUTPUT}/xml
# breathe_default_project=proj
# DEPENDS doxygen
# )
frontend/CMakeLists.txt
deleted
100644 → 0
View file @
9a7c3e30
add_subdirectory
(
onnx
)
src/CMakeLists.txt
0 → 100644
View file @
ac230464
add_library
(
rtg
program.cpp
shape.cpp
)
rocm_clang_tidy_check
(
rtg
)
target_include_directories
(
rtg PUBLIC $<BUILD_INTERFACE:
${
CMAKE_CURRENT_SOURCE_DIR
}
/include>
)
add_subdirectory
(
onnx
)
add_subdirectory
(
targets/cpu
)
include/rtg/argument.hpp
→
src/
include/rtg/argument.hpp
View file @
ac230464
...
@@ -18,6 +18,13 @@ struct argument : raw_data<argument>
...
@@ -18,6 +18,13 @@ struct argument : raw_data<argument>
{
{
argument
()
{}
argument
()
{}
argument
(
shape
s
)
:
m_shape
(
s
)
{
std
::
vector
<
char
>
buffer
(
s
.
bytes
());
// TODO: Move vector
data
=
[
=
]()
mutable
{
return
buffer
.
data
();
};
}
argument
(
shape
s
,
std
::
function
<
char
*
()
>
d
)
:
data
(
d
),
m_shape
(
s
)
{}
argument
(
shape
s
,
std
::
function
<
char
*
()
>
d
)
:
data
(
d
),
m_shape
(
s
)
{}
/// Provides a raw pointer to the data
/// Provides a raw pointer to the data
...
...
include/rtg/builtin.hpp
→
src/
include/rtg/builtin.hpp
View file @
ac230464
...
@@ -18,9 +18,14 @@ struct literal
...
@@ -18,9 +18,14 @@ struct literal
struct
param
struct
param
{
{
std
::
string
parameter
;
std
::
string
parameter
;
std
::
string
name
()
const
{
return
"@param
:"
+
parameter
;
}
std
::
string
name
()
const
{
return
"@param
"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
)
const
{
RTG_THROW
(
"builtin"
);
}
shape
compute_shape
(
std
::
vector
<
shape
>
)
const
{
RTG_THROW
(
"builtin"
);
}
argument
compute
(
std
::
vector
<
argument
>
)
const
{
RTG_THROW
(
"builtin"
);
}
argument
compute
(
std
::
vector
<
argument
>
)
const
{
RTG_THROW
(
"builtin"
);
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
param
&
op
)
{
os
<<
op
.
name
()
<<
":"
<<
op
.
parameter
;
return
os
;
}
};
};
}
// namespace builtin
}
// namespace builtin
...
...
include/rtg/erase.hpp
→
src/
include/rtg/erase.hpp
View file @
ac230464
File moved
include/rtg/errors.hpp
→
src/
include/rtg/errors.hpp
View file @
ac230464
File moved
include/rtg/fallthrough.hpp
→
src/
include/rtg/fallthrough.hpp
View file @
ac230464
File moved
include/rtg/float_equal.hpp
→
src/
include/rtg/float_equal.hpp
View file @
ac230464
File moved
include/rtg/instruction.hpp
→
src/
include/rtg/instruction.hpp
View file @
ac230464
File moved
include/rtg/instruction_ref.hpp
→
src/
include/rtg/instruction_ref.hpp
View file @
ac230464
File moved
include/rtg/literal.hpp
→
src/
include/rtg/literal.hpp
View file @
ac230464
File moved
include/rtg/operation.hpp
→
src/
include/rtg/operation.hpp
View file @
ac230464
...
@@ -11,14 +11,25 @@
...
@@ -11,14 +11,25 @@
namespace
rtg
{
namespace
rtg
{
namespace
operation_stream
{
template
<
class
T
>
auto
operator
<<
(
std
::
ostream
&
os
,
const
T
&
x
)
->
decltype
(
os
<<
x
.
name
())
{
return
os
<<
x
.
name
();
}
}
// namespace operation_stream
/*
/*
* Type-erased interface for:
* Type-erased interface for:
*
*
* struct operation
* struct operation
* {
* {
* std::string name() const;
* std::string name() const;
* shape compute_shape(std::vector<shape> input) const;
* shape compute_shape(std::vector<shape> input) const;
* argument compute(std::vector<argument> input) const;
* argument compute(std::vector<argument> input) const;
* friend std::ostream & operator<<(std::ostream & os,const operation & op) ;
* };
* };
*
*
*/
*/
...
@@ -74,20 +85,26 @@ struct operation
...
@@ -74,20 +85,26 @@ struct operation
std
::
string
name
()
const
std
::
string
name
()
const
{
{
assert
(
private_detail_te_handle_mem_var
);
assert
(
(
*
this
).
private_detail_te_handle_mem_var
);
return
private_detail_te_get_handle
().
name
();
return
(
*
this
).
private_detail_te_get_handle
().
name
();
}
}
shape
compute_shape
(
std
::
vector
<
shape
>
input
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
input
)
const
{
{
assert
(
private_detail_te_handle_mem_var
);
assert
(
(
*
this
).
private_detail_te_handle_mem_var
);
return
private_detail_te_get_handle
().
compute_shape
(
std
::
move
(
input
));
return
(
*
this
).
private_detail_te_get_handle
().
compute_shape
(
std
::
move
(
input
));
}
}
argument
compute
(
std
::
vector
<
argument
>
input
)
const
argument
compute
(
std
::
vector
<
argument
>
input
)
const
{
{
assert
(
private_detail_te_handle_mem_var
);
assert
((
*
this
).
private_detail_te_handle_mem_var
);
return
private_detail_te_get_handle
().
compute
(
std
::
move
(
input
));
return
(
*
this
).
private_detail_te_get_handle
().
compute
(
std
::
move
(
input
));
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
operation
&
op
)
{
assert
(
op
.
private_detail_te_handle_mem_var
);
return
op
.
private_detail_te_get_handle
().
operator_shift_left
(
os
);
}
}
private:
private:
...
@@ -97,9 +114,10 @@ struct operation
...
@@ -97,9 +114,10 @@ struct operation
virtual
std
::
shared_ptr
<
private_detail_te_handle_base_type
>
clone
()
const
=
0
;
virtual
std
::
shared_ptr
<
private_detail_te_handle_base_type
>
clone
()
const
=
0
;
virtual
const
std
::
type_info
&
type
()
const
=
0
;
virtual
const
std
::
type_info
&
type
()
const
=
0
;
virtual
std
::
string
name
()
const
=
0
;
virtual
std
::
string
name
()
const
=
0
;
virtual
shape
compute_shape
(
std
::
vector
<
shape
>
input
)
const
=
0
;
virtual
shape
compute_shape
(
std
::
vector
<
shape
>
input
)
const
=
0
;
virtual
argument
compute
(
std
::
vector
<
argument
>
input
)
const
=
0
;
virtual
argument
compute
(
std
::
vector
<
argument
>
input
)
const
=
0
;
virtual
std
::
ostream
&
operator_shift_left
(
std
::
ostream
&
os
)
const
=
0
;
};
};
template
<
typename
PrivateDetailTypeErasedT
>
template
<
typename
PrivateDetailTypeErasedT
>
...
@@ -134,14 +152,22 @@ struct operation
...
@@ -134,14 +152,22 @@ struct operation
shape
compute_shape
(
std
::
vector
<
shape
>
input
)
const
override
shape
compute_shape
(
std
::
vector
<
shape
>
input
)
const
override
{
{
return
private_detail_te_value
.
compute_shape
(
std
::
move
(
input
));
return
private_detail_te_value
.
compute_shape
(
std
::
move
(
input
));
}
}
argument
compute
(
std
::
vector
<
argument
>
input
)
const
override
argument
compute
(
std
::
vector
<
argument
>
input
)
const
override
{
{
return
private_detail_te_value
.
compute
(
std
::
move
(
input
));
return
private_detail_te_value
.
compute
(
std
::
move
(
input
));
}
}
std
::
ostream
&
operator_shift_left
(
std
::
ostream
&
os
)
const
override
{
using
rtg
::
operation_stream
::
operator
<<
;
return
os
<<
private_detail_te_value
;
}
PrivateDetailTypeErasedT
private_detail_te_value
;
PrivateDetailTypeErasedT
private_detail_te_value
;
};
};
...
...
include/rtg/operators.hpp
→
src/
include/rtg/operators.hpp
View file @
ac230464
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include <rtg/operation.hpp>
#include <rtg/operation.hpp>
#include <rtg/stringutils.hpp>
#include <rtg/stringutils.hpp>
#include <rtg/streamutils.hpp>
#include <cmath>
#include <cmath>
namespace
rtg
{
namespace
rtg
{
...
@@ -17,11 +18,7 @@ struct convolution
...
@@ -17,11 +18,7 @@ struct convolution
std
::
array
<
std
::
size_t
,
2
>
padding
=
{{
0
,
0
}};
std
::
array
<
std
::
size_t
,
2
>
padding
=
{{
0
,
0
}};
std
::
array
<
std
::
size_t
,
2
>
stride
=
{{
1
,
1
}};
std
::
array
<
std
::
size_t
,
2
>
stride
=
{{
1
,
1
}};
std
::
array
<
std
::
size_t
,
2
>
dilation
=
{{
1
,
1
}};
std
::
array
<
std
::
size_t
,
2
>
dilation
=
{{
1
,
1
}};
std
::
string
name
()
const
std
::
string
name
()
const
{
return
"convolution"
;
}
{
return
"convolution[padding={"
+
to_string
(
padding
)
+
"}, stride={"
+
to_string
(
stride
)
+
"}, dilation={"
+
to_string
(
dilation
)
+
"}]"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
{
if
(
inputs
.
size
()
!=
2
)
if
(
inputs
.
size
()
!=
2
)
...
@@ -56,6 +53,16 @@ struct convolution
...
@@ -56,6 +53,16 @@ struct convolution
}
}
argument
compute
(
std
::
vector
<
argument
>
)
const
{
RTG_THROW
(
"not computable"
);
}
argument
compute
(
std
::
vector
<
argument
>
)
const
{
RTG_THROW
(
"not computable"
);
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
convolution
&
op
)
{
os
<<
op
.
name
()
<<
"["
;
os
<<
"padding={"
<<
stream_range
(
op
.
padding
)
<<
"}, "
;
os
<<
"stride={"
<<
stream_range
(
op
.
stride
)
<<
"}, "
;
os
<<
"dilation={"
<<
stream_range
(
op
.
dilation
)
<<
"}"
;
os
<<
"]"
;
return
os
;
}
};
};
struct
pooling
struct
pooling
...
@@ -64,11 +71,7 @@ struct pooling
...
@@ -64,11 +71,7 @@ struct pooling
std
::
array
<
std
::
size_t
,
2
>
padding
=
{{
0
,
0
}};
std
::
array
<
std
::
size_t
,
2
>
padding
=
{{
0
,
0
}};
std
::
array
<
std
::
size_t
,
2
>
stride
=
{{
1
,
1
}};
std
::
array
<
std
::
size_t
,
2
>
stride
=
{{
1
,
1
}};
std
::
array
<
std
::
size_t
,
2
>
lengths
=
{{
1
,
1
}};
std
::
array
<
std
::
size_t
,
2
>
lengths
=
{{
1
,
1
}};
std
::
string
name
()
const
std
::
string
name
()
const
{
return
"pooling"
;
}
{
return
"pooling:"
+
mode
+
"[padding={"
+
to_string
(
padding
)
+
"}, stride={"
+
to_string
(
stride
)
+
"}, lengths={"
+
to_string
(
lengths
)
+
"}]"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
{
if
(
inputs
.
empty
())
if
(
inputs
.
empty
())
...
@@ -96,12 +99,22 @@ struct pooling
...
@@ -96,12 +99,22 @@ struct pooling
}
}
argument
compute
(
std
::
vector
<
argument
>
)
const
{
RTG_THROW
(
"not computable"
);
}
argument
compute
(
std
::
vector
<
argument
>
)
const
{
RTG_THROW
(
"not computable"
);
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
pooling
&
op
)
{
os
<<
op
.
name
()
<<
"["
;
os
<<
"padding={"
<<
stream_range
(
op
.
padding
)
<<
"}, "
;
os
<<
"stride={"
<<
stream_range
(
op
.
stride
)
<<
"}, "
;
os
<<
"lengths={"
<<
stream_range
(
op
.
lengths
)
<<
"}"
;
os
<<
"]"
;
return
os
;
}
};
};
struct
activation
struct
activation
{
{
std
::
string
mode
;
std
::
string
mode
;
std
::
string
name
()
const
{
return
"activation
:"
+
mode
;
}
std
::
string
name
()
const
{
return
"activation
"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
{
if
(
inputs
.
empty
())
if
(
inputs
.
empty
())
...
@@ -110,12 +123,17 @@ struct activation
...
@@ -110,12 +123,17 @@ struct activation
}
}
argument
compute
(
std
::
vector
<
argument
>
)
const
{
RTG_THROW
(
"not computable"
);
}
argument
compute
(
std
::
vector
<
argument
>
)
const
{
RTG_THROW
(
"not computable"
);
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
activation
&
op
)
{
os
<<
op
.
name
()
<<
":"
<<
op
.
mode
;
return
os
;
}
};
};
struct
reshape
struct
reshape
{
{
std
::
vector
<
int64_t
>
dims
;
std
::
vector
<
int64_t
>
dims
;
std
::
string
name
()
const
{
return
"reshape
[dims={"
+
to_string
(
dims
)
+
"}]
"
;
}
std
::
string
name
()
const
{
return
"reshape"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
{
if
(
inputs
.
empty
())
if
(
inputs
.
empty
())
...
@@ -136,6 +154,14 @@ struct reshape
...
@@ -136,6 +154,14 @@ struct reshape
}
}
argument
compute
(
std
::
vector
<
argument
>
)
const
{
RTG_THROW
(
"not computable"
);
}
argument
compute
(
std
::
vector
<
argument
>
)
const
{
RTG_THROW
(
"not computable"
);
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
reshape
&
op
)
{
os
<<
op
.
name
()
<<
"["
;
os
<<
"dims={"
<<
stream_range
(
op
.
dims
)
<<
"}, "
;
os
<<
"]"
;
return
os
;
}
};
};
}
// namespace rtg
}
// namespace rtg
...
...
include/rtg/program.hpp
→
src/
include/rtg/program.hpp
View file @
ac230464
File moved
include/rtg/raw_data.hpp
→
src/
include/rtg/raw_data.hpp
View file @
ac230464
File moved
include/rtg/shape.hpp
→
src/
include/rtg/shape.hpp
View file @
ac230464
File moved
src/include/rtg/streamutils.hpp
0 → 100644
View file @
ac230464
#ifndef RTG_GUARD_STREAMUTILS_HPP
#define RTG_GUARD_STREAMUTILS_HPP
#include <ostream>
#include <algorithm>
namespace
rtg
{
template
<
class
T
>
struct
stream_range_container
{
const
T
*
r
;
stream_range_container
(
const
T
&
x
)
:
r
(
&
x
)
{}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
stream_range_container
&
sr
)
{
assert
(
sr
.
r
!=
nullptr
);
if
(
!
sr
.
r
->
empty
())
{
os
<<
sr
.
r
->
front
();
std
::
for_each
(
std
::
next
(
sr
.
r
->
begin
()),
sr
.
r
->
end
(),
[
&
](
auto
&&
x
)
{
os
<<
", "
<<
x
;
});
}
return
os
;
}
};
template
<
class
Range
>
inline
stream_range_container
<
Range
>
stream_range
(
const
Range
&
r
)
{
return
{
r
};
}
}
// namespace rtg
#endif
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