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

Function StridesInBytes

cpp/src/arrow/c/dlpack.cc:430–443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

428}
429
430Result<std::vector<int64_t>> StridesInBytes(std::span<const int64_t> strides,
431 int64_t byte_width) {
432 std::vector<int64_t> out{};
433 out.reserve(strides.size());
434 for (const auto& s : strides) {
435 int64_t stride_bytes = 0;
436 if (ARROW_PREDICT_FALSE(
437 internal::MultiplyWithOverflow(s, byte_width, &stride_bytes))) {
438 return Status::Invalid("Overflow computing DLPack tensor stride in bytes.");
439 }
440 out.push_back(stride_bytes);
441 }
442 return out;
443}
444
445Result<std::shared_ptr<Buffer>> ImportBuffer(CppDLTensor&& dl) {
446 ARROW_ASSIGN_OR_RAISE(const int64_t nbytes, dl.ComputeNumBytes());

Callers

nothing calls this directly

Calls 5

MultiplyWithOverflowFunction · 0.85
push_backMethod · 0.80
InvalidFunction · 0.50
reserveMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected