| 138 | } |
| 139 | |
| 140 | inline 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 | |
| 158 | Status CheckTensorStridesValidity(const std::shared_ptr<Buffer>& data, |
| 159 | const std::vector<int64_t>& shape, |
no test coverage detected