MCPcopy Create free account
hub / github.com/pytorch/executorch / slot_map

Method slot_map

backends/mlx/builder/program_builder.py:200–222  ·  view source on GitHub ↗
(self, tree)

Source from the content-addressed store, hash-verified

198 return self.slot_map(node.kwargs)
199
200 def slot_map(self, tree):
201 leaves, spec = pytree.tree_flatten(tree)
202 new_leaves = []
203 for a in leaves:
204 if isinstance(a, Node):
205 # Use make_or_get_slots which handles both single and multi-output nodes.
206 # For single-output nodes, returns a 1-tuple; for multi-output, returns n-tuple.
207 # We unwrap single-element tuples for convenience.
208 slots = self.make_or_get_slots(a)
209 if len(slots) == 1:
210 new_leaves.append(slots[0])
211 else:
212 new_leaves.append(slots)
213 else:
214 new_leaves.append(a)
215
216 for a in new_leaves:
217 if isinstance(a, Slot):
218 assert self.slot_manager.is_alive(
219 a
220 ), f"Slot {a} is not alive; it was either already freed or never created"
221
222 return pytree.tree_unflatten(new_leaves, spec)
223
224 def make_or_get_slots(
225 self, node: Node, id_space: IdSpace = IdSpace.Temp

Callers 15

argsMethod · 0.95
kwargsMethod · 0.95
_gather_qmm_handlerFunction · 0.80
_emit_convFunction · 0.80
_emit_conv_transposeFunction · 0.80
_constant_pad_nd_handlerFunction · 0.80
_emit_pool_ndFunction · 0.80
__call__Method · 0.80
__call__Method · 0.80
__call__Method · 0.80
__call__Method · 0.80

Calls 3

make_or_get_slotsMethod · 0.95
is_aliveMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected