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

Function alloc

exir/memory.py:25–33  ·  view source on GitHub ↗
(spec: AllocSpec)

Source from the content-addressed store, hash-verified

23
24
25def alloc(spec: AllocSpec) -> pytree.PyTree:
26 if isinstance(spec, list):
27 return [alloc(s) for s in spec]
28
29 shape, dtype = spec
30 # evaluate the shape to int so we can run the traced module
31 # in python for testing
32 shape = eval_shape(shape)
33 return torch.empty(shape, dtype=dtype)
34
35
36def free(spec: TensorSpec) -> None:

Callers

nothing calls this directly

Calls 1

eval_shapeFunction · 0.90

Tested by

no test coverage detected