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
8afbb10d
Commit
8afbb10d
authored
Sep 18, 2019
by
Chao Liu
Browse files
reduce some register usage in index
parent
94bb1b48
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
composable_kernel/include/tensor_description/tensor_coordinate.hpp
...e_kernel/include/tensor_description/tensor_coordinate.hpp
+14
-2
No files found.
composable_kernel/include/tensor_description/tensor_coordinate.hpp
View file @
8afbb10d
...
@@ -166,7 +166,7 @@ struct MergedTensorCoordinate
...
@@ -166,7 +166,7 @@ struct MergedTensorCoordinate
// do carry check in reversed order, starting from lowest dimension
// do carry check in reversed order, starting from lowest dimension
// don't check the highest dimension
// don't check the highest dimension
static_for
<
0
,
ndim_partial_original
,
1
>
{}([
&
](
auto
IReverse
)
{
static_for
<
0
,
ndim_partial_original
-
1
,
1
>
{}([
&
](
auto
IReverse
)
{
constexpr
index_t
i
=
ndim_partial_original
-
1
-
IReverse
;
constexpr
index_t
i
=
ndim_partial_original
-
1
-
IReverse
;
if
(
carry
)
if
(
carry
)
...
@@ -182,6 +182,12 @@ struct MergedTensorCoordinate
...
@@ -182,6 +182,12 @@ struct MergedTensorCoordinate
carry
=
true
;
carry
=
true
;
}
}
});
});
// highest dimension
if
(
carry
)
{
++
partial_original_id
(
0
);
}
}).
Else
([
&
](
auto
)
{
}).
Else
([
&
](
auto
)
{
// shift up multi-id to avoid unsigned integer underflow during intermediate
// shift up multi-id to avoid unsigned integer underflow during intermediate
// calculations. After the shift, should have new_multi_id[...] >= 1
// calculations. After the shift, should have new_multi_id[...] >= 1
...
@@ -192,7 +198,7 @@ struct MergedTensorCoordinate
...
@@ -192,7 +198,7 @@ struct MergedTensorCoordinate
// do borrow check in reversed order, starting from lowest dimension
// do borrow check in reversed order, starting from lowest dimension
// don't check the highest dimension
// don't check the highest dimension
static_for
<
0
,
ndim_partial_original
,
1
>
{}([
&
](
auto
IReverse
)
{
static_for
<
0
,
ndim_partial_original
-
1
,
1
>
{}([
&
](
auto
IReverse
)
{
constexpr
index_t
i
=
ndim_partial_original
-
1
-
IReverse
;
constexpr
index_t
i
=
ndim_partial_original
-
1
-
IReverse
;
if
(
borrow
)
if
(
borrow
)
...
@@ -209,6 +215,12 @@ struct MergedTensorCoordinate
...
@@ -209,6 +215,12 @@ struct MergedTensorCoordinate
}
}
});
});
// highest dimension
if
(
borrow
)
{
--
partial_original_id
(
0
);
}
// shift back down multi-id
// shift back down multi-id
// here, should have new_multi_id[...] >= GetLengths()
// here, should have new_multi_id[...] >= GetLengths()
partial_original_id
=
partial_original_id
-
partial_original_desc
.
GetLengths
();
partial_original_id
=
partial_original_id
-
partial_original_desc
.
GetLengths
();
...
...
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