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

Function ValidateTensorParameters

cpp/src/arrow/tensor.cc:208–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206}
207
208Status ValidateTensorParameters(const std::shared_ptr<DataType>& type,
209 const std::shared_ptr<Buffer>& data,
210 const std::vector<int64_t>& shape,
211 const std::vector<int64_t>& strides,
212 const std::vector<std::string>& dim_names) {
213 RETURN_NOT_OK(CheckTensorValidity(type, data, shape));
214 if (!strides.empty()) {
215 RETURN_NOT_OK(CheckTensorStridesValidity(data, shape, strides, type));
216 } else {
217 std::vector<int64_t> tmp_strides;
218 RETURN_NOT_OK(ComputeRowMajorStrides(checked_cast<const FixedWidthType&>(*type),
219 shape, &tmp_strides));
220 RETURN_NOT_OK(CheckTensorStridesValidity(data, shape, tmp_strides, type));
221 }
222 if (dim_names.size() > shape.size()) {
223 return Status::Invalid("too many dim_names are supplied");
224 }
225 return Status::OK();
226}
227
228template <typename Out>
229struct ConvertArrayToTensorVisitor {

Callers 3

tensor.hFile · 0.85
ValidateFunction · 0.85
MakeMethod · 0.85

Calls 7

CheckTensorValidityFunction · 0.85
ComputeRowMajorStridesFunction · 0.85
InvalidFunction · 0.70
OKFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected