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

Conv conversion: getting rank from weights if possible #524

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 8 additions & 1 deletion onnx_coreml/_operators_nd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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):
Expand Down