diff --git a/onnx_coreml/_operators_nd.py b/onnx_coreml/_operators_nd.py index 6bc6fdd..29b0fe0 100644 --- a/onnx_coreml/_operators_nd.py +++ b/onnx_coreml/_operators_nd.py @@ -40,7 +40,14 @@ def load_input_constants(builder, node, graph, err): def _add_conv_like_op(add_func, get_params_func, params_dict, builder, node, graph, err): + + # To do: Need to avoid dependence on rank for conversion since rank is not always available. + rank = builder._get_rank(node.inputs[0]) + + if rank < 0 and node.op_type == "Conv" and "w_shape" in params_dict: + rank = len(params_dict["w_shape"]) + if rank == 4: get_params_func(builder, node, graph, err, params_dict) add_func(node.inputs, node.outputs, params_dict=params_dict, builder=builder, node=node, graph=graph, err=err) @@ -67,7 +74,7 @@ def _add_conv_like_op(add_func, get_params_func, params_dict, axes=axes ) else: - return err.unsupported_op_configuration(builder, node, graph, "provided number axes {} not supported".format(rank)) + return err.unsupported_op_configuration(builder, node, graph, "Unable to infer rank of the input. Invalid rank {} not supported".format(rank)) def add_broadcastable_op_chain(builder, node, err, add_op_function):