Skip to content

Commit

Permalink
Refactor binary-elementwise-nd.cc and binary.cc to reduce the number …
Browse files Browse the repository at this point in the history
…of test suites via type erasure. This should make the test easier to read and maintain.

PiperOrigin-RevId: 688580770
  • Loading branch information
xnnpack-bot committed Oct 22, 2024
1 parent 8731139 commit faa2fd8
Show file tree
Hide file tree
Showing 6 changed files with 593 additions and 554 deletions.
6 changes: 6 additions & 0 deletions src/operator-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,9 @@ enum xnn_operator_type xnn_reduce_operator_to_operator_type(enum xnn_reduce_oper
return xnn_operator_type_invalid;
}
}


const char* xnn_binary_operator_to_string(enum xnn_binary_operator type) {
return xnn_operator_type_to_string(
xnn_binary_operator_to_operator_type(type));
}
6 changes: 0 additions & 6 deletions src/operators/binary-elementwise-nd.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ static uint32_t xnn_datatype_get_log2_element_size(enum xnn_datatype datatype) {
}
}

static const char* xnn_binary_operator_to_string(
enum xnn_binary_operator type) {
return xnn_operator_type_to_string(
xnn_binary_operator_to_operator_type(type));
}

static const struct xnn_binary_elementwise_config* init_config(
enum xnn_binary_operator type, enum xnn_datatype datatype, int* sign_b) {
switch (type) {
Expand Down
1 change: 1 addition & 0 deletions src/xnnpack/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ extern "C" {
#endif

const char* xnn_datatype_to_string(enum xnn_datatype type);
const char* xnn_binary_operator_to_string(enum xnn_binary_operator type);

#ifdef __cplusplus
} // extern "C"
Expand Down
5 changes: 4 additions & 1 deletion test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,9 @@ xnnpack_unit_test(
name = "binary_elementwise_nd_test",
timeout = "long",
srcs = ["binary-elementwise-nd.cc"],
deps = OPERATOR_TEST_DEPS,
deps = OPERATOR_TEST_DEPS + [
"//:logging",
],
)

xnnpack_unit_test(
Expand Down Expand Up @@ -1840,6 +1842,7 @@ xnnpack_unit_test(
":replicable_random_device",
"//:XNNPACK",
"//:buffer",
"//:logging",
"//:math",
"//:operators",
"//:subgraph",
Expand Down
Loading

0 comments on commit faa2fd8

Please sign in to comment.