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
5f1ea74f
Unverified
Commit
5f1ea74f
authored
Jul 02, 2018
by
Paul Fultz II
Committed by
GitHub
Jul 02, 2018
Browse files
Merge pull request #9 from ROCmSoftwarePlatform/context
Add context object for execution
parents
7591b7ff
a7dcd9fb
Changes
26
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
6 deletions
+36
-6
test/operation.cpp
test/operation.cpp
+2
-2
tools/generate.sh
tools/generate.sh
+1
-1
tools/include/context.hpp
tools/include/context.hpp
+12
-0
tools/include/operation.hpp
tools/include/operation.hpp
+2
-1
tools/include/target.hpp
tools/include/target.hpp
+3
-1
tools/te.py
tools/te.py
+16
-1
No files found.
test/operation.cpp
View file @
5f1ea74f
...
...
@@ -9,7 +9,7 @@ struct simple_operation
int
data
=
1
;
std
::
string
name
()
const
{
return
"simple"
;
}
rtg
::
shape
compute_shape
(
std
::
vector
<
rtg
::
shape
>
)
const
{
RTG_THROW
(
"not computable"
);
}
rtg
::
argument
compute
(
rtg
::
shape
,
std
::
vector
<
rtg
::
argument
>
)
const
rtg
::
argument
compute
(
rtg
::
context
&
,
rtg
::
shape
,
std
::
vector
<
rtg
::
argument
>
)
const
{
RTG_THROW
(
"not computable"
);
}
...
...
@@ -24,7 +24,7 @@ struct simple_operation_no_print
{
std
::
string
name
()
const
{
return
"simple"
;
}
rtg
::
shape
compute_shape
(
std
::
vector
<
rtg
::
shape
>
)
const
{
RTG_THROW
(
"not computable"
);
}
rtg
::
argument
compute
(
rtg
::
shape
,
std
::
vector
<
rtg
::
argument
>
)
const
rtg
::
argument
compute
(
rtg
::
context
&
,
rtg
::
shape
,
std
::
vector
<
rtg
::
argument
>
)
const
{
RTG_THROW
(
"not computable"
);
}
...
...
tools/generate.sh
View file @
5f1ea74f
DIR
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
&&
pwd
)
"
ls
-1
$DIR
/include/ | xargs
-n
1
-P
$(
nproc
)
-I
{}
-t
bash
-c
"python
$DIR
/te.py
$DIR
/include/{} | clang-format-5.0 -style=file >
$DIR
/../src/include/rtg/{}"
ls
-1
$DIR
/include/ | xargs
-n
1
-P
$(
nproc
)
-I
{}
-t
bash
-c
"python
3.6
$DIR
/te.py
$DIR
/include/{} | clang-format-5.0 -style=file >
$DIR
/../src/include/rtg/{}"
tools/include/context.hpp
0 → 100644
View file @
5f1ea74f
#ifndef RTG_GUARD_CONTEXT_HPP
#define RTG_GUARD_CONTEXT_HPP
namespace
rtg
{
<%
interface
(
'
context
'
)
%>
}
// namespace rtg
#endif
tools/include/operation.hpp
View file @
5f1ea74f
...
...
@@ -8,6 +8,7 @@
#include <utility>
#include <rtg/shape.hpp>
#include <rtg/argument.hpp>
#include <rtg/context.hpp>
namespace
rtg
{
...
...
@@ -25,7 +26,7 @@ auto operator<<(std::ostream& os, const T& x) -> decltype(os << x.name())
interface
(
'
operation
'
,
virtual
(
'
name
'
,
returns
=
'
std
::
string
'
,
const
=
True
),
virtual
(
'
compute_shape
'
,
returns
=
'
shape
'
,
input
=
'
std
::
vector
<
shape
>
'
,
const
=
True
),
virtual
(
'
compute
'
,
returns
=
'
argument
'
,
output
=
'
shape
'
,
input
=
'
std
::
vector
<
argument
>
'
,
const
=
True
),
virtual
(
'
compute
'
,
returns
=
'
argument
'
,
ctx
=
'
context
&
'
,
output
=
'
shape
'
,
input
=
'
std
::
vector
<
argument
>
'
,
const
=
True
),
friend
(
'
operator
<<
'
,
returns
=
'
std
::
ostream
&
'
,
os
=
'
std
::
ostream
&
'
,
op
=
'
const
operation
&
'
,
using
=
'
rtg
::
operation_stream
::
operator
<<
'
)
)
%>
...
...
tools/include/target.hpp
View file @
5f1ea74f
...
...
@@ -6,6 +6,7 @@
#include <memory>
#include <type_traits>
#include <utility>
#include <rtg/context.hpp>
namespace
rtg
{
...
...
@@ -14,7 +15,8 @@ struct program;
<%
interface
(
'
target
'
,
virtual
(
'
name
'
,
returns
=
'
std
::
string
'
,
const
=
True
),
virtual
(
'
apply
'
,
returns
=
'
void
'
,
p
=
'
program
&
'
,
const
=
True
)
virtual
(
'
apply
'
,
returns
=
'
void
'
,
p
=
'
program
&
'
,
const
=
True
),
virtual
(
'
get_context
'
,
returns
=
'
context
'
,
const
=
True
)
)
%>
...
...
tools/te.py
View file @
5f1ea74f
...
...
@@ -63,6 +63,12 @@ struct ${struct_name}
nullptr;
}
const std::type_info& type_id() const
{
if(private_detail_te_handle_empty()) return typeid(std::nullptr_t);
else return private_detail_te_get_handle().type();
}
${nonvirtual_members}
private:
...
...
@@ -118,11 +124,20 @@ private:
{}
};
bool private_detail_te_handle_empty() const
{
return private_detail_te_handle_mem_var == nullptr;
}
const private_detail_te_handle_base_type & private_detail_te_get_handle () const
{ return *private_detail_te_handle_mem_var; }
{
assert(private_detail_te_handle_mem_var != nullptr);
return *private_detail_te_handle_mem_var;
}
private_detail_te_handle_base_type & private_detail_te_get_handle ()
{
assert(private_detail_te_handle_mem_var != nullptr);
if (!private_detail_te_handle_mem_var.unique())
private_detail_te_handle_mem_var = private_detail_te_handle_mem_var->clone();
return *private_detail_te_handle_mem_var;
...
...
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