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

Function ComputeColumnMajorStrides

cpp/src/arrow/tensor.cc:78–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78Status ComputeColumnMajorStrides(const FixedWidthType& type,
79 const std::vector<int64_t>& shape,
80 std::vector<int64_t>* strides) {
81 const int byte_width = type.byte_width();
82 const size_t ndim = shape.size();
83
84 int64_t total = 0;
85 if (!shape.empty() && shape.back() > 0) {
86 total = byte_width;
87 for (size_t i = 0; i < ndim - 1; ++i) {
88 if (internal::MultiplyWithOverflow(total, shape[i], &total)) {
89 return Status::Invalid(
90 "Column-major strides computed from shape would not fit in 64-bit "
91 "integer");
92 }
93 }
94 }
95
96 if (total == 0) {
97 strides->assign(shape.size(), byte_width);
98 return Status::OK();
99 }
100
101 total = byte_width;
102 for (size_t i = 0; i < ndim - 1; ++i) {
103 strides->push_back(total);
104 total *= shape[i];
105 }
106 strides->push_back(total);
107
108 return Status::OK();
109}
110
111} // namespace internal
112

Callers 4

TESTFunction · 0.85
RecordBatchToTensorFunction · 0.85
MakeRandomTensorFunction · 0.85

Calls 9

MultiplyWithOverflowFunction · 0.85
backMethod · 0.80
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