| 19 | } |
| 20 | |
| 21 | int64_t num_elements(const std::vector<int64_t> & shape) { |
| 22 | if (shape.empty() || shape.size() > engine::core::kMaxTensorRank) { |
| 23 | throw std::runtime_error("MioCodec weight tensor rank must be between 1 and 4"); |
| 24 | } |
| 25 | int64_t count = 1; |
| 26 | for (const int64_t dim : shape) { |
| 27 | if (dim <= 0) { |
| 28 | throw std::runtime_error("MioCodec weight tensor dimensions must be positive"); |
| 29 | } |
| 30 | count *= dim; |
| 31 | } |
| 32 | return count; |
| 33 | } |
| 34 | |
| 35 | engine::core::TensorShape shape_from_vector(const std::vector<int64_t> & shape) { |
| 36 | switch (shape.size()) { |
no test coverage detected