Commit 8afbb10d authored by Chao Liu's avatar Chao Liu
Browse files

reduce some register usage in index

parent 94bb1b48
...@@ -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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment