State of a single emitter. Local to at least the entry point, and may be local to a subgraph of an entry point originating from control flow.
| 136 | |
| 137 | @dataclass |
| 138 | class _EmitterState: |
| 139 | """State of a single emitter. |
| 140 | |
| 141 | Local to at least the entry point, and may be local to a subgraph of an entry point originating |
| 142 | from control flow. |
| 143 | """ |
| 144 | |
| 145 | values: List[EValue] |
| 146 | operators: List[Operator] |
| 147 | delegates: List[BackendDelegate] |
| 148 | operator_cache: Dict[Tuple[str, str], int] |
| 149 | emit_stacktrace: bool |
| 150 | emit_mutable_buffer_names: bool |
| 151 | |
| 152 | spec2id_dict: Dict[TensorSpec, int] = field(default_factory=dict) |
| 153 | |
| 154 | def spec2id(self, spec: TensorSpec) -> int: |
| 155 | """Map a TensorSpec to value index in the values array.""" |
| 156 | assert spec in self.spec2id_dict, f"Spec is not found: {spec.debug()}" |
| 157 | return self.spec2id_dict[spec] |
| 158 | |
| 159 | |
| 160 | @dataclass |