Skip to content

Commit 24b7921

Browse files
Jack-Khuufacebook-github-bot
authored andcommitted
Dropping Trailing None's When Calculating Emitted ExecutionPlan Outputs
Summary: Previously Support for outputting int/float was added in D53256808 for Seamless This extends on this by dropping None Outputs (Which can be outputted by NanoGPT) Differential Revision: D54328663
1 parent 49e1328 commit 24b7921

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

exir/emit/_emitter.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,6 +1366,10 @@ def output(
13661366
if isinstance(args_tuple, _AbstractValue):
13671367
self.outputs.append(args_tuple.id)
13681368
else:
1369+
# Drop all the None's present at the end of the list if there are any.
1370+
args_tuple = list(args_tuple)
1371+
while args_tuple and args_tuple[-1] is None:
1372+
args_tuple.pop()
13691373
for arg in args_tuple:
13701374
if isinstance(arg, (int, float, bool)):
13711375
arg = self._emit_evalue(self._constant_to_evalue(arg, None))

exir/emit/test/test_emit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def forward(
213213
def test_constant_output(self):
214214
class M(torch.nn.Module):
215215
def forward(self, x):
216-
return [((1, 3, 1.2), True, [x + x, x * x])]
216+
return [((1, 3, 1.2), True, [x + x, x * x], None)]
217217

218218
ep = torch.export.export(M(), (torch.ones(2, 3),))
219219
res = ep(torch.ones(2, 3))

0 commit comments

Comments
 (0)