| 78 | } |
| 79 | |
| 80 | void ThrowCheckONNXNode(const std::string_view name, |
| 81 | const std::string_view expected_name, |
| 82 | const std::vector<int64_t>& shape, |
| 83 | const std::vector<int64_t>& expected_shape) { |
| 84 | THROW_CHECK_EQ(name, expected_name); |
| 85 | THROW_CHECK_EQ(shape.size(), expected_shape.size()) |
| 86 | << "Invalid shape for " << name << ": " << FormatONNXTensorShape(shape) |
| 87 | << " != " << FormatONNXTensorShape(expected_shape); |
| 88 | for (size_t i = 0; i < shape.size(); ++i) { |
| 89 | // -1 is treated as a wildcard for dynamic dimensions. |
| 90 | if (expected_shape[i] != -1) { |
| 91 | THROW_CHECK_EQ(shape[i], expected_shape[i]) |
| 92 | << "Invalid shape for " << name << ": " |
| 93 | << FormatONNXTensorShape(shape) |
| 94 | << " != " << FormatONNXTensorShape(expected_shape); |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | ONNXModel::ONNXModel(std::string model_path, |
| 100 | int num_threads, |
no test coverage detected