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
e1f959fd
Commit
e1f959fd
authored
Sep 06, 2022
by
Po-Yen, Chen
Browse files
Use better name for tensor indices
parent
db32635c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
example/36_elementwise_permute/common.hpp
example/36_elementwise_permute/common.hpp
+8
-5
No files found.
example/36_elementwise_permute/common.hpp
View file @
e1f959fd
...
@@ -302,7 +302,7 @@ inline std::enable_if_t<detail::is_random_access_range_v<Shape> &&
...
@@ -302,7 +302,7 @@ inline std::enable_if_t<detail::is_random_access_range_v<Shape> &&
transpose_shape
(
const
Shape
&
shape
,
const
Axes
&
axes
,
OutputIterator
iter
)
transpose_shape
(
const
Shape
&
shape
,
const
Axes
&
axes
,
OutputIterator
iter
)
{
{
using
std
::
size
;
using
std
::
size
;
assert
(
size
(
shape
)
==
size
(
axes
)
&&
);
assert
(
size
(
shape
)
==
size
(
axes
));
assert
(
is_valid_shape
(
shape
)
&&
is_valid_axes
(
axes
));
assert
(
is_valid_shape
(
shape
)
&&
is_valid_axes
(
axes
));
for
(
const
auto
axis
:
axes
)
for
(
const
auto
axis
:
axes
)
...
@@ -319,6 +319,7 @@ std::enable_if_t<detail::is_bidirectional_range_v<Shape> && detail::is_sized_ran
...
@@ -319,6 +319,7 @@ std::enable_if_t<detail::is_bidirectional_range_v<Shape> && detail::is_sized_ran
bool
>
bool
>
advance_indices
(
const
Shape
&
shape
,
Indices
&
indices
)
advance_indices
(
const
Shape
&
shape
,
Indices
&
indices
)
{
{
using
std
::
size
;
assert
(
is_valid_shape
(
shape
));
assert
(
is_valid_shape
(
shape
));
assert
(
is_valid_indices
(
indices
));
assert
(
is_valid_indices
(
indices
));
assert
(
size
(
shape
)
==
size
(
indices
));
assert
(
size
(
shape
)
==
size
(
indices
));
...
@@ -355,11 +356,13 @@ host_elementwise_permute(const Tensor<Src>& src, Functor functor, Tensor<Dest>&
...
@@ -355,11 +356,13 @@ host_elementwise_permute(const Tensor<Src>& src, Functor functor, Tensor<Dest>&
using
std
::
size
;
using
std
::
size
;
assert
(
size
(
shape
)
==
4
&&
size
(
transposed_shape
)
==
4
);
assert
(
size
(
shape
)
==
4
&&
size
(
transposed_shape
)
==
4
);
std
::
array
<
std
::
size_t
,
4
>
dims
{};
std
::
array
<
std
::
size_t
,
4
>
indices
{};
assert
(
is_valid_indices
(
indices
));
do
do
{
{
Dest
b_val
=
0
;
Dest
b_val
=
0
;
functor
(
b_val
,
src
(
dims
[
0
],
dims
[
1
],
dims
[
2
],
dim
s
[
3
]));
functor
(
b_val
,
src
(
indices
[
0
],
indices
[
1
],
indices
[
2
],
indice
s
[
3
]));
dest
(
dims
[
0
],
dims
[
2
],
dims
[
3
],
dim
s
[
1
])
=
b_val
;
dest
(
indices
[
0
],
indices
[
2
],
indices
[
3
],
indice
s
[
1
])
=
b_val
;
}
while
(
advance_indices
(
shape
,
dim
s
));
}
while
(
advance_indices
(
shape
,
indice
s
));
}
}
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