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
composable_kernel
Commits
60ab70d8
Commit
60ab70d8
authored
Sep 06, 2022
by
Po-Yen, Chen
Browse files
Generalize variable naming in example code
parent
31d758fb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
example/36_elementwise_permute/run_elementwise_permute_example.inc
...6_elementwise_permute/run_elementwise_permute_example.inc
+12
-11
No files found.
example/36_elementwise_permute/run_elementwise_permute_example.inc
View file @
60ab70d8
...
@@ -5,12 +5,14 @@
...
@@ -5,12 +5,14 @@
bool
run_elementwise_permute
(
const
ExecutionConfig
&
config
,
const
Problem
&
problem
)
bool
run_elementwise_permute
(
const
ExecutionConfig
&
config
,
const
Problem
&
problem
)
{
{
const
auto
&
nchw
=
problem
.
shape
;
using
std
::
begin
,
std
::
end
;
std
::
vector
<
std
::
size_t
>
nhwc
;
transpose_shape
(
problem
.
shape
,
problem
.
axes
,
std
::
back_inserter
(
nhwc
));
Tensor
<
ADataType
>
a
(
nchw
);
const
auto
&
shape
=
problem
.
shape
;
Tensor
<
BDataType
>
b
(
nhwc
);
ck
::
remove_cvref_t
<
decltype
(
shape
)
>
transposed_shape
;
transpose_shape
(
problem
.
shape
,
problem
.
axes
,
begin
(
transposed_shape
));
Tensor
<
ADataType
>
a
(
shape
);
Tensor
<
BDataType
>
b
(
transposed_shape
);
std
::
iota
(
begin
(
a
.
mData
),
end
(
a
.
mData
),
0
);
std
::
iota
(
begin
(
a
.
mData
),
end
(
a
.
mData
),
0
);
...
@@ -23,12 +25,11 @@ bool run_elementwise_permute(const ExecutionConfig& config, const Problem& probl
...
@@ -23,12 +25,11 @@ bool run_elementwise_permute(const ExecutionConfig& config, const Problem& probl
std
::
array
<
void
*
,
1
>
output
=
{
b_device_buf
.
GetDeviceBuffer
()};
std
::
array
<
void
*
,
1
>
output
=
{
b_device_buf
.
GetDeviceBuffer
()};
std
::
array
<
ck
::
index_t
,
4
>
ab_lengths
;
std
::
array
<
ck
::
index_t
,
4
>
ab_lengths
;
std
::
array
<
ck
::
index_t
,
4
>
a_strides
;
std
::
array
<
ck
::
index_t
,
4
>
a_strides
,
b_strides
;
std
::
array
<
ck
::
index_t
,
4
>
b_strides
;
std
::
copy
(
nchw
.
begin
(
),
nchw
.
end
(),
ab_lengths
.
begin
(
));
std
::
copy
(
begin
(
shape
),
end
(
shape
),
begin
(
ab_lengths
));
std
::
copy
(
a
.
mDesc
.
GetStrides
()
.
begin
(),
a
.
mDesc
.
GetStrides
()
.
end
(),
a_strides
.
begin
(
));
std
::
copy
(
begin
(
a
.
mDesc
.
GetStrides
()
),
end
(
a
.
mDesc
.
GetStrides
()
),
begin
(
a_strides
));
std
::
copy
(
b
.
mDesc
.
GetStrides
()
.
begin
(),
b
.
mDesc
.
GetStrides
()
.
end
(),
b_strides
.
begin
(
));
std
::
copy
(
begin
(
b
.
mDesc
.
GetStrides
()
),
end
(
b
.
mDesc
.
GetStrides
()
),
begin
(
b_strides
));
auto
permute
=
DeviceElementwisePermuteInstance
{};
auto
permute
=
DeviceElementwisePermuteInstance
{};
auto
argument
=
auto
argument
=
...
@@ -48,7 +49,7 @@ bool run_elementwise_permute(const ExecutionConfig& config, const Problem& probl
...
@@ -48,7 +49,7 @@ bool run_elementwise_permute(const ExecutionConfig& config, const Problem& probl
if
(
config
.
do_verification
)
if
(
config
.
do_verification
)
{
{
Tensor
<
BDataType
>
host_b
(
nhwc
);
Tensor
<
BDataType
>
host_b
(
transposed_shape
);
host_elementwise_permute
(
a
,
problem
.
axes
,
PassThrough
{},
host_b
);
host_elementwise_permute
(
a
,
problem
.
axes
,
PassThrough
{},
host_b
);
b_device_buf
.
FromDevice
(
b
.
mData
.
data
());
b_device_buf
.
FromDevice
(
b
.
mData
.
data
());
...
...
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