(spec: AllocSpec)
| 23 | |
| 24 | |
| 25 | def 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 | |
| 36 | def free(spec: TensorSpec) -> None: |
nothing calls this directly
no test coverage detected