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
8bbdc2db
"...resnet50_tensorflow.git" did not exist on "f24fc412ff33ab9d141cebe6a3a74c1b003a456a"
Commit
8bbdc2db
authored
Jun 22, 2018
by
Paul
Browse files
Remove get_argument_gpu function
parent
4e44a1d8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
15 deletions
+29
-15
src/targets/miopen/include/rtg/miopen/hip.hpp
src/targets/miopen/include/rtg/miopen/hip.hpp
+26
-4
test/miopen/miopen.cpp
test/miopen/miopen.cpp
+3
-11
No files found.
src/targets/miopen/include/rtg/miopen/hip.hpp
View file @
8bbdc2db
...
@@ -18,15 +18,20 @@ inline hip_ptr gpu_allocate(std::size_t sz)
...
@@ -18,15 +18,20 @@ inline hip_ptr gpu_allocate(std::size_t sz)
return
hip_ptr
{
result
};
return
hip_ptr
{
result
};
}
}
inline
hip_ptr
write_to_gpu
(
const
void
*
x
,
std
::
size_t
sz
)
{
auto
result
=
gpu_allocate
(
sz
);
// TODO: Check status
hipMemcpy
(
result
.
get
(),
x
,
sz
,
hipMemcpyHostToDevice
);
return
result
;
}
template
<
class
T
>
template
<
class
T
>
hip_ptr
write_to_gpu
(
const
T
&
x
)
hip_ptr
write_to_gpu
(
const
T
&
x
)
{
{
using
type
=
typename
T
::
value_type
;
using
type
=
typename
T
::
value_type
;
auto
size
=
x
.
size
()
*
sizeof
(
type
);
auto
size
=
x
.
size
()
*
sizeof
(
type
);
auto
result
=
gpu_allocate
(
size
);
return
write_to_gpu
(
x
.
data
(),
size
);
// TODO: Check status
hipMemcpy
(
result
.
get
(),
x
.
data
(),
size
,
hipMemcpyHostToDevice
);
return
result
;
}
}
template
<
class
T
>
template
<
class
T
>
...
@@ -38,6 +43,23 @@ std::vector<T> read_from_gpu(const void* x, std::size_t sz)
...
@@ -38,6 +43,23 @@ std::vector<T> read_from_gpu(const void* x, std::size_t sz)
return
result
;
return
result
;
}
}
inline
rtg
::
argument
to_gpu
(
rtg
::
argument
arg
)
{
auto
p
=
share
(
write_to_gpu
(
arg
.
data
(),
arg
.
get_shape
().
bytes
()));
return
{
arg
.
get_shape
(),
[
p
]()
mutable
{
return
reinterpret_cast
<
char
*>
(
p
.
get
());
}};
}
inline
rtg
::
argument
from_gpu
(
rtg
::
argument
arg
)
{
rtg
::
argument
result
;
arg
.
visit
([
&
](
auto
x
)
{
using
type
=
typename
decltype
(
x
)
::
value_type
;
auto
v
=
read_from_gpu
<
type
>
(
arg
.
data
(),
x
.
get_shape
().
bytes
()
/
sizeof
(
type
));
result
=
{
x
.
get_shape
(),
[
v
]()
mutable
{
return
reinterpret_cast
<
char
*>
(
v
.
data
());
}};
});
return
result
;
}
struct
hip_allocate
struct
hip_allocate
{
{
std
::
string
name
()
const
{
return
"hip::allocate"
;
}
std
::
string
name
()
const
{
return
"hip::allocate"
;
}
...
...
test/miopen/miopen.cpp
View file @
8bbdc2db
...
@@ -23,14 +23,6 @@ rtg::program create_program()
...
@@ -23,14 +23,6 @@ rtg::program create_program()
return
p
;
return
p
;
}
}
// TODO: Move to header
rtg
::
argument
get_tensor_argument_gpu
(
rtg
::
shape
s
)
{
auto
v
=
rtg
::
generate_tensor_data
<
float
>
(
s
);
auto
p
=
rtg
::
share
(
rtg
::
miopen
::
write_to_gpu
(
v
));
return
{
s
,
[
p
]()
mutable
{
return
reinterpret_cast
<
char
*>
(
p
.
get
());
}};
}
std
::
vector
<
float
>
cpu
()
std
::
vector
<
float
>
cpu
()
{
{
std
::
vector
<
float
>
result
;
std
::
vector
<
float
>
result
;
...
@@ -48,10 +40,10 @@ std::vector<float> gpu()
...
@@ -48,10 +40,10 @@ std::vector<float> gpu()
{
{
std
::
vector
<
float
>
result
;
std
::
vector
<
float
>
result
;
auto
p
=
create_program
();
auto
p
=
create_program
();
auto
x
=
get_tensor
_argument
_gpu
({
rtg
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}});
auto
x
=
rtg
::
miopen
::
to_gpu
(
rtg
::
generate
_argument
({
rtg
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}})
)
;
auto
w
=
get_tensor
_argument
_gpu
({
rtg
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}});
auto
w
=
rtg
::
miopen
::
to_gpu
(
rtg
::
generate
_argument
({
rtg
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}})
)
;
p
.
compile
(
rtg
::
miopen
::
miopen_target
{});
p
.
compile
(
rtg
::
miopen
::
miopen_target
{});
auto
y
=
get_tensor
_argument
_gpu
(
p
.
get_parameter_shape
(
"output"
));
auto
y
=
rtg
::
miopen
::
to_gpu
(
rtg
::
generate
_argument
(
p
.
get_parameter_shape
(
"output"
))
)
;
auto
handle
=
rtg
::
miopen
::
make_obj
<
rtg
::
miopen
::
miopen_handle
>
(
&
miopenCreate
);
auto
handle
=
rtg
::
miopen
::
make_obj
<
rtg
::
miopen
::
miopen_handle
>
(
&
miopenCreate
);
auto
r
=
p
.
eval
(
auto
r
=
p
.
eval
(
{{
"x"
,
x
},
{
"w"
,
w
},
{
"output"
,
y
},
{
"handle"
,
{
rtg
::
shape
::
any_type
,
handle
.
get
()}}});
{{
"x"
,
x
},
{
"w"
,
w
},
{
"output"
,
y
},
{
"handle"
,
{
rtg
::
shape
::
any_type
,
handle
.
get
()}}});
...
...
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