(cls, name, bases, dct)
| 27 | class FunctionMeta(base_meta): |
| 28 | |
| 29 | def __new__(cls, name, bases, dct): |
| 30 | if name == "CompiledFunction": |
| 31 | original_backward_impl = _unwrap_staticmethod(dct.get("_backward_impl")) |
| 32 | frame_key = backward_frame_keys.popleft() if backward_frame_keys else None |
| 33 | |
| 34 | def wrapped_backward_impl(ctx, all_args): |
| 35 | assert original_backward_impl is not None |
| 36 | |
| 37 | if enabled_patched_func and frame_key is not None: |
| 38 | backward_inputs.setdefault(frame_key, []).append(all_args) |
| 39 | wrapped_backward_impl.owner_class.compiled_bw = None |
| 40 | |
| 41 | return original_backward_impl(ctx, all_args) |
| 42 | |
| 43 | wrapped_backward_impl.owner_class = None |
| 44 | dct["_backward_impl"] = staticmethod(wrapped_backward_impl) |
| 45 | new_class = super().__new__(cls, name, bases, dct) |
| 46 | wrapped_backward_impl.owner_class = new_class |
| 47 | |
| 48 | return new_class |
| 49 | |
| 50 | return super().__new__(cls, name, bases, dct) |
| 51 | |
| 52 | elif required_torch_version(min_version=2.6): |
| 53 |
nothing calls this directly
no test coverage detected