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

Method ComputeNumBytes

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

Number of bytes needed to store this tensor data.

Source from the content-addressed store, hash-verified

343
344 /// Number of bytes needed to store this tensor data.
345 Result<int64_t> ComputeNumBytes() const {
346 ARROW_ASSIGN_OR_RAISE(const auto nelements, ComputeNumElements());
347 int64_t nbytes = 0;
348 if (ARROW_PREDICT_FALSE(internal::MultiplyWithOverflow(
349 nelements, static_cast<int64_t>(byte_width()), &nbytes))) {
350 return Status::Invalid("Overflow computing DLPack tensor size in bytes.");
351 }
352 return nbytes;
353 }
354
355 private:
356 struct Deleter {

Callers

nothing calls this directly

Calls 3

MultiplyWithOverflowFunction · 0.85
byte_widthFunction · 0.50
InvalidFunction · 0.50

Tested by

no test coverage detected