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

Function CheckTensorValidity

cpp/src/arrow/tensor.cc:140–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138}
139
140inline Status CheckTensorValidity(const std::shared_ptr<DataType>& type,
141 const std::shared_ptr<Buffer>& data,
142 const std::vector<int64_t>& shape) {
143 if (!type) {
144 return Status::Invalid("Null type is supplied");
145 }
146 if (!is_tensor_supported(type->id())) {
147 return Status::Invalid(type->ToString(), " is not valid data type for a tensor");
148 }
149 if (!data) {
150 return Status::Invalid("Null data is supplied");
151 }
152 if (!std::all_of(shape.begin(), shape.end(), [](int64_t x) { return x >= 0; })) {
153 return Status::Invalid("Shape elements must be positive");
154 }
155 return Status::OK();
156}
157
158Status CheckTensorStridesValidity(const std::shared_ptr<Buffer>& data,
159 const std::vector<int64_t>& shape,

Callers 1

ValidateTensorParametersFunction · 0.85

Calls 7

is_tensor_supportedFunction · 0.85
InvalidFunction · 0.70
OKFunction · 0.70
idMethod · 0.45
ToStringMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected