| 210 | } |
| 211 | |
| 212 | void validate_shape(const TensorValue & value, const TensorShape & expected, const char * name) { |
| 213 | if (!value.valid()) { |
| 214 | throw std::runtime_error(name_or_default(name) + " is invalid"); |
| 215 | } |
| 216 | if (value.shape.rank != expected.rank) { |
| 217 | throw std::runtime_error(name_or_default(name) + " rank mismatch: expected " + expected.to_string() + |
| 218 | ", got " + value.shape.to_string()); |
| 219 | } |
| 220 | for (size_t i = 0; i < expected.rank; ++i) { |
| 221 | if (value.shape.dims[i] != expected.dims[i]) { |
| 222 | throw std::runtime_error(name_or_default(name) + " shape mismatch: expected " + expected.to_string() + |
| 223 | ", got " + value.shape.to_string()); |
| 224 | } |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | void validate_last_dim(const TensorValue & value, int64_t expected, const char * name) { |
| 229 | if (!value.valid()) { |
no test coverage detected