Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.

Commit 6424992

Browse files
authored
Adding Where Op (#487)
* Adding Where Op * erf conversion change input_names to input_name
1 parent 7f7a30c commit 6424992

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

onnx_coreml/_operators_nd.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ def _convert_erf(builder, node, graph, err):
575575
load_input_constants(builder, node, graph, err)
576576
builder.add_erf(
577577
name=node.name,
578-
input_names=node.inputs[0],
578+
input_name=node.inputs[0],
579579
output_name=node.outputs[0]
580580
)
581581

@@ -2198,6 +2198,18 @@ def _convert_unsqueeze(builder, node, graph, err):
21982198
axes=axes
21992199
)
22002200

2201+
def _convert_where(builder, node, graph, err):
2202+
'''
2203+
convert to CoreML WhereBroadcastable Layer:
2204+
https://github.com/apple/coremltools/blob/655b3be5cc0d42c3c4fa49f0f0e4a93a26b3e492/mlmodel/format/NeuralNetwork.proto#L3742
2205+
'''
2206+
load_input_constants(builder, node, graph, err)
2207+
builder.add_where_broadcastable(
2208+
name=node.name,
2209+
input_names=node.inputs,
2210+
output_name=node.outputs[0],
2211+
)
2212+
22012213
_ONNX_NODE_REGISTRY_ND = {
22022214
"Abs": _convert_abs,
22032215
"Acos": _convert_acos,
@@ -2305,6 +2317,7 @@ def _convert_unsqueeze(builder, node, graph, err):
23052317
"Unsqueeze": _convert_unsqueeze,
23062318
"Upsample": _convert_upsample,
23072319
"Xor": _convert_logical,
2320+
"Where": _convert_where
23082321
}
23092322

23102323
def _get_node_converter_fn(builder, node, err): # type: (NeuralNetworkBuilder, Node, ErrorHandling) -> Callable[[NeuralNetworkBuilder, Node, Graph, ErrorHandling], None]

tests/onnx_backend_node_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,9 +579,7 @@ def exclude_test_cases(backend_test):
579579
'test_acosh_cpu',
580580
'test_asinh_cpu',
581581
'test_atanh_cpu',
582-
'test_erf_cpu',
583582
'test_isnan_cpu',
584-
'test_where_example_cpu',
585583
'test_acosh_example_cpu',
586584
'test_asinh_example_cpu',
587585
'test_atanh_example_cpu',

0 commit comments

Comments
 (0)