(cast_fn, args, kwargs)
| 120 | |
| 121 | # NB: returneds casted `args`, mutates `kwargs` in-place |
| 122 | def casted_args(cast_fn, args, kwargs): |
| 123 | new_args = [] |
| 124 | for x in args: |
| 125 | if is_fp_tensor(x): |
| 126 | new_args.append(cast_fn(x)) |
| 127 | else: |
| 128 | new_args.append(x) |
| 129 | for k in kwargs: |
| 130 | val = kwargs[k] |
| 131 | if is_fp_tensor(val): |
| 132 | kwargs[k] = cast_fn(val) |
| 133 | return new_args |
| 134 | |
| 135 | def cached_cast(cast_fn, x, cache): |
| 136 | if is_nested(x): |
nothing calls this directly
no test coverage detected