MCPcopy Create free account
hub / github.com/apache/arrow / ComputeRowMajorStrides

Function ComputeRowMajorStrides

cpp/src/arrow/tensor.cc:47–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45namespace internal {
46
47Status ComputeRowMajorStrides(const FixedWidthType& type,
48 const std::vector<int64_t>& shape,
49 std::vector<int64_t>* strides) {
50 const int byte_width = type.byte_width();
51 const size_t ndim = shape.size();
52
53 int64_t remaining = 0;
54 if (!shape.empty() && shape.front() > 0) {
55 remaining = byte_width;
56 for (size_t i = 1; i < ndim; ++i) {
57 if (internal::MultiplyWithOverflow(remaining, shape[i], &remaining)) {
58 return Status::Invalid(
59 "Row-major strides computed from shape would not fit in 64-bit integer");
60 }
61 }
62 }
63
64 if (remaining == 0) {
65 strides->assign(shape.size(), byte_width);
66 return Status::OK();
67 }
68
69 strides->push_back(remaining);
70 for (size_t i = 1; i < ndim; ++i) {
71 remaining /= shape[i];
72 strides->push_back(remaining);
73 }
74
75 return Status::OK();
76}
77
78Status ComputeColumnMajorStrides(const FixedWidthType& type,
79 const std::vector<int64_t>& shape,

Callers 10

TESTFunction · 0.85
IsTensorStridesRowMajorFunction · 0.85
ValidateTensorParametersFunction · 0.85
RecordBatchToTensorFunction · 0.85
TensorMethod · 0.85
ConvertMethod · 0.85
BuildMethod · 0.85
MakeRandomTensorFunction · 0.85

Calls 8

MultiplyWithOverflowFunction · 0.85
assignMethod · 0.80
push_backMethod · 0.80
InvalidFunction · 0.70
OKFunction · 0.70
byte_widthMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by 2

TESTFunction · 0.68
MakeRandomTensorFunction · 0.68