Skip to content

Commit ed07bba

Browse files
zichuan-weicopybara-github
authored andcommitted
fix a consumer generation bug, where when a single consumer uses the same tensor more than more we only record them once.
PiperOrigin-RevId: 764459982
1 parent b9bda33 commit ed07bba

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

ai_edge_quantizer/transformation_instruction_generator.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,13 @@ def _tensor_info_generator(
186186
A tuple of tensor_name and TensorGraphInfo.
187187
"""
188188
for tensor_id, tensor in enumerate(subgraph.tensors):
189-
consumers = [
190-
op_id
191-
for (op_id, op) in enumerate(subgraph.operators)
192-
if tensor_id in op.inputs
193-
]
189+
consumers = []
190+
for op_id, op in enumerate(subgraph.operators):
191+
# Some ops may use the same input tensor multiple times,
192+
# and we should handle each time independently.
193+
for op_input in op.inputs:
194+
if op_input == tensor_id:
195+
consumers.append(op_id)
194196
producer = -1
195197
for op_id, op in enumerate(subgraph.operators):
196198
if tensor_id in op.outputs:

0 commit comments

Comments
 (0)