| 17 | namespace { |
| 18 | |
| 19 | void ensure_positive_dims(const TensorShape & shape) { |
| 20 | if (shape.rank == 0 || shape.rank > kMaxTensorRank) { |
| 21 | throw std::runtime_error("Tensor rank must be between 1 and 4"); |
| 22 | } |
| 23 | |
| 24 | for (size_t i = 0; i < shape.rank; ++i) { |
| 25 | if (shape.dims[i] <= 0) { |
| 26 | throw std::runtime_error("Tensor dimensions must be positive"); |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | std::string name_or_default(const char * name) { |
| 32 | return name == nullptr ? std::string("tensor") : std::string(name); |
no outgoing calls
no test coverage detected