Function
patch_align
(value: int, patch: int, mode: str)
Source from the content-addressed store, hash-verified
| 108 | |
| 109 | |
| 110 | def patch_align(value: int, patch: int, mode: str) -> int: |
| 111 | if value % patch == 0: |
| 112 | return value |
| 113 | if mode == "error": |
| 114 | raise ValueError(f"{value} is not divisible by patch size {patch}") |
| 115 | if mode == "floor": |
| 116 | return (value // patch) * patch |
| 117 | return ((value + patch - 1) // patch) * patch |
| 118 | |
| 119 | |
| 120 | def resolve_dtype(device: str, dtype: str) -> torch.dtype: |
Tested by
no test coverage detected