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

Function CheckTensorValidity

cpp/src/arrow/tensor.cc:139–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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