(e: LeafValue, proxy: torch.fx.Proxy)
| 356 | # Wrap the output tensors with the PythonTensor subclass to propagate to |
| 357 | # future tracing |
| 358 | def wrap_with_proxy(e: LeafValue, proxy: torch.fx.Proxy) -> LeafValue: |
| 359 | # Some ops (like native_batch_norm_backward) return undefined tensors that get |
| 360 | # converted into None in python. |
| 361 | # As the function signature expects tensors, if we directly return these None |
| 362 | # tensors back to C++, we'll error. |
| 363 | if e is None: |
| 364 | e = torch.empty(()) |
| 365 | |
| 366 | if isinstance(e, torch.Tensor): |
| 367 | return PythonTensor(e, proxy) |
| 368 | |
| 369 | # Inplace and out-variant ops may return one of their arguments, which is already |
| 370 | # a PythonTensor. In this case, we need to update the PythonTensor's associated |
| 371 | # proxy to the newly created proxy. |
| 372 | if isinstance(e, PythonTensor): |
| 373 | e.update_proxy(proxy) |
| 374 | return e |
| 375 | |
| 376 | return e |
| 377 | |
| 378 | retval = None |
| 379 | if not isinstance(real_out, (list, tuple)): |
nothing calls this directly
no test coverage detected