|
6 | 6 | # /// script |
7 | 7 | # requires-python = ">=3.11" |
8 | 8 | # dependencies = [ |
9 | | -# "coreai-core==1.0.0b1", |
10 | | -# "coreai-torch==0.4.0", |
| 9 | +# "coreai-core==1.0.0b2", |
| 10 | +# "coreai-torch==0.4.1", |
11 | 11 | # "timm", |
12 | 12 | # ] |
13 | 13 | # |
|
27 | 27 | from coreai_torch import TorchConverter, get_decomp_table |
28 | 28 |
|
29 | 29 |
|
30 | | -def reference_inputs(dynamic: bool = False) -> dict[str, torch.Tensor]: |
| 30 | +def reference_inputs( |
| 31 | + dynamic: bool = False, dtype: torch.dtype = torch.float32 |
| 32 | +) -> dict[str, torch.Tensor]: |
31 | 33 | B = 2 if dynamic else 1 |
32 | | - return {"x": torch.randn(B, 3, 224, 224)} |
| 34 | + return {"x": torch.randn(B, 3, 224, 224, dtype=dtype)} |
33 | 35 |
|
34 | 36 |
|
35 | 37 | def dynamic_shapes() -> dict: |
@@ -97,7 +99,7 @@ def create_pvt( |
97 | 99 | model.to(dtype) |
98 | 100 | print("[INFO] Model sourced. Running torch export with decompositions...") |
99 | 101 |
|
100 | | - example_inputs = {k: v.to(dtype) for k, v in reference_inputs(dynamic).items()} |
| 102 | + example_inputs = example_inputs = reference_inputs(dynamic, dtype) |
101 | 103 | ds = dynamic_shapes() if dynamic else None |
102 | 104 |
|
103 | 105 | with torch.autocast(device_type="cpu", dtype=dtype): |
|
0 commit comments