| 165 | } |
| 166 | |
| 167 | Status 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 | |
| 185 | Status CheckTensorStridesValidity(const std::shared_ptr<Buffer>& data, |
| 186 | const std::vector<int64_t>& shape, |
no test coverage detected