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

Function CheckTensorValidity

cpp/src/arrow/tensor.cc:167–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167Status CheckTensorValidity(const std::shared_ptr<DataType>& type,
168 const std::shared_ptr<Buffer>& data,
169 const std::vector<int64_t>& shape) {
170 if (!type) {
171 return Status::Invalid("Null type is supplied");
172 }
173 if (!is_tensor_supported(type->id())) {
174 return Status::TypeError(type->ToString(), " is not valid data type for a tensor");
175 }
176 if (!data) {
177 return Status::Invalid("Null data is supplied");
178 }
179 if (!std::all_of(shape.begin(), shape.end(), [](int64_t x) { return x >= 0; })) {
180 return Status::Invalid("Shape elements must be positive");
181 }
182 return Status::OK();
183}
184
185Status CheckTensorStridesValidity(const std::shared_ptr<Buffer>& data,
186 const std::vector<int64_t>& shape,

Callers 1

ValidateTensorParametersFunction · 0.85

Calls 8

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

Tested by

no test coverage detected