minor fix for removing reshape for fc
Summary: sometimes the reshape parameter of Reshape is from external input thus no producer.
@@ -831,7 +831,9 @@ def _get_dependency_chain(ssa, versioned_target, versioned_source):
consumer_map = get_consumer_map(ssa)
producer_map = get_producer_map(ssa)
start_op = min(x[0] for x in consumer_map[versioned_source]) - 15
- end_op = producer_map[versioned_target][0] + 15
+ end_op = (
+ producer_map[versioned_target][0] + 15 if versioned_target in producer_map else start_op
+ )
sub_graph_ssa = ssa[start_op : end_op + 1]
if len(sub_graph_ssa) > 30:
logger.warning(
