Implement InvalidShapeException

This commit is contained in:
2025-11-21 18:54:45 +01:00
parent 6685aa6629
commit c83e1f0c45
6 changed files with 77 additions and 91 deletions

View File

@@ -18,35 +18,19 @@ AvgPool2d::AvgPool2d(
padding_shape(padding_shape),
backend(backend) {
if (in_shape.size() != 3) {
throw std::runtime_error(
std::format(
"Invalid input shape. Expected 3 dims, got {}", input_shape.size()
)
);
throw InvalidShapeException("input", 3, in_shape.size());
}
if (pool_shape.size() != 2) {
throw std::runtime_error(
std::format(
"Invalid pool shape. Expected 2 dims, got {}", pool_shape.size()
)
);
throw InvalidShapeException("pool", 2, pool_shape.size());
}
if (stride_shape.size() != 2) {
throw std::runtime_error(
std::format(
"Invalid stride shape. Expected 2 dims, got {}", stride_shape.size()
)
);
throw InvalidShapeException("stride", 2, stride_shape.size());
}
if (padding_shape.size() != 2) {
throw std::runtime_error(
std::format(
"Invalid padding shape. Expected 2 dims, got {}", padding_shape.size()
)
);
throw InvalidShapeException("padding", 2, padding_shape.size());
}
out_shape = {