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