skip optional inputs for scan subgraphs (#3349)

* skip optional inputs for scan subgraphs

We may have cases where the subgraph has optionial inputs that appear
in both subgraph's input and initializer, but not in the node's input.
In such cases, the input model might be invalid, but let's not choke
on it. Instead, let's issue a warning, skip the optional inputs,
and keep going forward.

* address CR feedback
This commit is contained in:
Yang Chen 2020-03-28 16:15:45 -07:00 committed by GitHub
parent c3cea486d0
commit 33b5010e62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -903,7 +903,11 @@ class SymbolicShapeInference:
scan_input_axes = get_attribute(node, 'scan_input_axes', [0]*num_scan_inputs)
num_scan_states = len(node.input) - num_scan_inputs
scan_input_axes = [handle_negative_axis(ax, self._get_shape_rank(node, i + num_scan_states)) for i, ax in enumerate(scan_input_axes)]
for i, si in enumerate(subgraph.input):
# We may have cases where the subgraph has optionial inputs that appear in both subgraph's input and initializer,
# but not in the node's input. In such cases, the input model might be invalid, but let's skip those optional inputs.
assert len(subgraph.input) >= len(node.input)
subgraph_inputs = subgraph.input[:len(node.input)]
for i, si in enumerate(subgraph_inputs):
subgraph_name = si.name
si.CopyFrom(self.known_vi_[node.input[i]])
if i >= num_scan_states: