Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow 1x1 pooling #7141

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions src/operators/average-pooling-nhwc.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,34 +68,13 @@ enum xnn_status create_average_pooling2d_nhwc(
return xnn_status_invalid_parameter;
}

if (pooling_size == 1) {
xnn_log_error(
"failed to create %s operator with 1 pooling element: 1x1 pooling is meaningless",
xnn_operator_type_to_string(operator_type));
return xnn_status_invalid_parameter;
}

if (stride_height == 0 || stride_width == 0) {
xnn_log_error(
"failed to create %s operator with %" PRIu32 "x%" PRIu32 " stride: stride dimensions must be non-zero",
xnn_operator_type_to_string(operator_type), stride_width, stride_height);
return xnn_status_invalid_parameter;
}

if (stride_height > pooling_height) {
xnn_log_error(
"failed to create %s operator with %" PRIu32 " stride height: must be less than pooling height %" PRIu32,
xnn_operator_type_to_string(operator_type), stride_height, pooling_height);
return xnn_status_invalid_parameter;
}

if (stride_width > pooling_width) {
xnn_log_error(
"failed to create %s operator with %" PRIu32 " stride width: must be less than pooling width %" PRIu32,
xnn_operator_type_to_string(operator_type), stride_width, pooling_width);
return xnn_status_invalid_parameter;
}

if (isnan(output_min)) {
xnn_log_error(
"failed to create %s operator with NaN output lower bound: lower bound must be non-NaN",
Expand Down
21 changes: 0 additions & 21 deletions src/subgraph/average-pooling-2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,6 @@ enum xnn_status xnn_define_average_pooling_2d(
return xnn_status_invalid_parameter;
}

if (pooling_size == 1) {
xnn_log_error(
"failed to define %s operator with 1 pooling element: 1x1 pooling is meaningless",
xnn_node_type_to_string(xnn_node_type_average_pooling_2d));
return xnn_status_invalid_parameter;
}

if (stride_height == 0 || stride_width == 0) {
xnn_log_error(
"failed to define %s operator with %" PRIu32 "x%" PRIu32 " stride: "
Expand All @@ -227,20 +220,6 @@ enum xnn_status xnn_define_average_pooling_2d(
return xnn_status_invalid_parameter;
}

if (stride_height > pooling_height) {
xnn_log_error(
"failed to define %s operator with %" PRIu32 " stride height: must be less than pooling height %" PRIu32,
xnn_node_type_to_string(xnn_node_type_max_pooling_2d), stride_height, pooling_height);
return xnn_status_invalid_parameter;
}

if (stride_width > pooling_width) {
xnn_log_error(
"failed to define %s operator with %" PRIu32 " stride width: must be less than pooling width %" PRIu32,
xnn_node_type_to_string(xnn_node_type_max_pooling_2d), stride_width, pooling_width);
return xnn_status_invalid_parameter;
}

status = xnn_subgraph_check_output_min_max(xnn_node_type_average_pooling_2d, output_min, output_max);
if (status != xnn_status_success) {
return status;
Expand Down
2 changes: 1 addition & 1 deletion test/average-pooling-2d.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AveragePoolingTest : public ::testing::Test {
protected:
AveragePoolingTest() {
input_size_dist = std::uniform_int_distribution<uint32_t>(10, 15);
pooling_size_dist = std::uniform_int_distribution<uint32_t>(2, 5);
pooling_size_dist = std::uniform_int_distribution<uint32_t>(1, 5);
stride_dist = std::uniform_int_distribution<uint32_t>(1, 2);
batch_size = input_size_dist(rng);
input_height = input_size_dist(rng);
Expand Down