Skip to content

Commit

Permalink
Remove num_values from emitter
Browse files Browse the repository at this point in the history
Summary: Use `len(self.emitter_state.values)` to track number of values emitted.

Reviewed By: dbort

Differential Revision: D54340269

fbshipit-source-id: 55d8e59e1d5f54d0af56e8e38eb326340420cb61
  • Loading branch information
lucylq authored and facebook-github-bot committed Mar 1, 2024
1 parent e2a8f95 commit 06035f3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
1 change: 0 additions & 1 deletion exir/emit/_emit_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ def emit_program(
values=[],
operators=[],
delegates=[],
num_values=0,
operator_cache={},
delegate_cache={},
emit_stacktrace=emit_stacktrace,
Expand Down
5 changes: 1 addition & 4 deletions exir/emit/_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ class _EmitterState:
values: List[EValue]
operators: List[Operator]
delegates: List[BackendDelegate]
num_values: int
operator_cache: Dict[Tuple[str, str], int]
delegate_cache: Dict[bytes, int]
emit_stacktrace: bool
Expand Down Expand Up @@ -493,11 +492,9 @@ def _emit_evalue(self, val: EValue) -> _AbstractValue:
Given an Evalue, adds it to the emitter_state's values table, and returns the AbstractValue
representing it.
"""
ret = self.emitter_state.num_values
self.emitter_state.values.append(val)
self.emitter_state.num_values += 1
tensor = val.val if isinstance(val.val, Tensor) else None
return _AbstractValue(ret, tensor)
return _AbstractValue(len(self.emitter_state.values) - 1, tensor)

def _emit_spec(self, spec: ValueSpec) -> _EmitterValue:
"""Given the provided spec constructs the corresponding EValue from it and then emits it."""
Expand Down

0 comments on commit 06035f3

Please sign in to comment.