You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/02/04 00:28:51 UTC
[GitHub] [arrow] mrkn commented on a change in pull request #9395: ARROW-11470: [C++] Detect overflow on computation of tensor strides
mrkn commented on a change in pull request #9395:
URL: https://github.com/apache/arrow/pull/9395#discussion_r569854746
##########
File path: cpp/src/arrow/tensor.cc
##########
@@ -127,14 +163,25 @@ Status CheckTensorStridesValidity(const std::shared_ptr<Buffer>& data,
return Status::OK();
}
- std::vector<int64_t> last_index(shape);
- const int64_t n = static_cast<int64_t>(shape.size());
- for (int64_t i = 0; i < n; ++i) {
- --last_index[i];
+ // Check the largest offset can be computed without overflow
+ const auto ndim = shape.size();
+ int64_t largest_offset = 0;
+ for (auto i = decltype(ndim){0}; i < ndim; ++i) {
+ if (strides[i] <= 0) continue;
Review comment:
Oops. I should check `dim_offset < 0` after `MultiplyWithOverflow` instead of `strides` here. I'll fix it.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org