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
b171e9ad
"git@developer.sourcefind.cn:Wenxuan/LightX2V.git" did not exist on "2e5794c7b60854856e070492ec24ec93a116edab"
Commit
b171e9ad
authored
Jun 23, 2019
by
Paul
Browse files
Refactor pad
parent
1599d553
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
22 deletions
+15
-22
src/targets/gpu/device/include/migraphx/gpu/device/tensor_view.hpp
...ts/gpu/device/include/migraphx/gpu/device/tensor_view.hpp
+1
-0
src/targets/gpu/device/pad.cpp
src/targets/gpu/device/pad.cpp
+14
-22
No files found.
src/targets/gpu/device/include/migraphx/gpu/device/tensor_view.hpp
View file @
b171e9ad
...
@@ -13,6 +13,7 @@ template <class T, std::size_t N>
...
@@ -13,6 +13,7 @@ template <class T, std::size_t N>
struct
hip_tensor_view
struct
hip_tensor_view
{
{
using
value_type
=
T
;
using
value_type
=
T
;
using
hip_index
=
typename
hip_shape
<
N
>::
hip_index
;
__device__
__host__
hip_tensor_view
()
=
default
;
__device__
__host__
hip_tensor_view
()
=
default
;
__host__
hip_tensor_view
(
tensor_view
<
T
>
x
)
:
d
(
x
.
data
()),
s
(
x
.
get_shape
())
{}
__host__
hip_tensor_view
(
tensor_view
<
T
>
x
)
:
d
(
x
.
data
()),
s
(
x
.
get_shape
())
{}
__host__
hip_tensor_view
(
T
*
x
,
const
shape
&
ss
)
:
d
(
x
),
s
(
ss
)
{}
__host__
hip_tensor_view
(
T
*
x
,
const
shape
&
ss
)
:
d
(
x
),
s
(
ss
)
{}
...
...
src/targets/gpu/device/pad.cpp
View file @
b171e9ad
...
@@ -15,34 +15,26 @@ argument
...
@@ -15,34 +15,26 @@ argument
pad
(
hipStream_t
stream
,
argument
result
,
argument
arg1
,
float
value
,
std
::
vector
<
std
::
int64_t
>
pads
)
pad
(
hipStream_t
stream
,
argument
result
,
argument
arg1
,
float
value
,
std
::
vector
<
std
::
int64_t
>
pads
)
{
{
std
::
size_t
nelements
=
arg1
.
get_shape
().
elements
();
std
::
size_t
nelements
=
arg1
.
get_shape
().
elements
();
visit_all
(
result
)([
&
](
auto
output
)
{
hip_visit_all
(
result
,
arg1
)([
&
](
auto
output
,
auto
input
)
{
auto
*
outptr
=
device_cast
(
output
.
data
());
using
type
=
typename
decltype
(
output
)
::
value_type
;
using
type
=
typename
decltype
(
output
)
::
value_type
;
device_type
<
type
>
device_val
=
value
;
using
hip_index
=
typename
decltype
(
output
)
::
hip_index
;
type
device_val
=
value
;
if
(
float_equal
(
value
,
std
::
numeric_limits
<
float
>::
lowest
()))
if
(
float_equal
(
value
,
std
::
numeric_limits
<
float
>::
lowest
()))
{
{
device_val
=
device_cast
(
std
::
numeric_limits
<
type
>::
lowest
());
device_val
=
device_cast
(
std
::
numeric_limits
<
type
>::
lowest
());
}
}
gs_launch
(
stream
,
result
.
get_shape
().
elements
())([
=
](
auto
i
)
{
outptr
[
i
]
=
device_val
;
});
gs_launch
(
stream
,
result
.
get_shape
().
elements
())([
=
](
auto
i
)
{
output
.
data
()[
i
]
=
device_val
;
});
});
visit_all
(
result
,
arg1
)([
&
](
auto
output
,
auto
input
)
{
hip_index
offsets
;
visit_tensor_size
(
result
.
get_shape
().
lens
().
size
(),
[
&
](
auto
ndim
)
{
std
::
copy
(
pads
.
begin
(),
pads
.
begin
()
+
offsets
.
size
(),
offsets
.
begin
());
std
::
size_t
offsets
[
ndim
];
gs_launch
(
stream
,
nelements
)([
=
](
auto
i
)
{
std
::
copy
(
pads
.
begin
(),
pads
.
begin
()
+
ndim
,
offsets
);
auto
idx
=
input
.
get_shape
().
multi
(
i
);
auto
*
outptr
=
output
.
data
();
for
(
std
::
size_t
j
=
0
;
j
<
offsets
.
size
();
j
++
)
const
auto
*
inptr
=
input
.
data
();
{
hip_tensor_descriptor
<
ndim
>
desc_input
(
input
.
get_shape
());
idx
[
j
]
+=
offsets
[
j
];
hip_tensor_descriptor
<
ndim
>
desc_output
(
output
.
get_shape
());
}
gs_launch
(
stream
,
nelements
)([
=
](
auto
i
)
{
output
[
idx
]
=
input
.
data
()[
i
];
auto
idx
=
desc_input
.
multi
(
i
);
});
for
(
std
::
size_t
j
=
0
;
j
<
ndim
;
j
++
)
{
idx
[
j
]
+=
offsets
[
j
];
}
outptr
[
desc_output
.
linear
(
idx
)]
=
inptr
[
i
];
});
});
});
});
return
result
;
return
result
;
}
}
...
...
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