已合并
[PROF] fix mstx patch err in pytorch graph mode #16175
mei-feiyao创建于 2024年11月20日
[PROF] fix mstx patch err in pytorch graph mode #16175
已合并
从refs/pull/16175/head合入到master
共 2 个文件变更+84-109
| @@ -562,111 +562,95 @@ class TestProfilerTree(TestCase): | |||
| 562 | aten::empty | 562 | aten::empty |
| 563 | aten::fill_ | 563 | aten::fill_ |
| 564 | nn.Module: MyModule_0 | 564 | nn.Module: MyModule_0 |
| 565 | - torch_npu/npu/__init__.py(...): is_initialized | 565 | + torch/nn/modules/module.py(...): _call_impl |
| 566 | - torch/nn/modules/module.py(...): _wrapped_call_impl | 566 | + <built-in method _get_tracing_state of PyCapsule object at 0xXXXXXXXXXXXX> |
| 567 | - torch/nn/modules/module.py(...): _call_impl | 567 | + test_profiler_tree.py(...): forward |
| 568 | - <built-in method _get_tracing_state of PyCapsule object at 0xXXXXXXXXXXXX> | 568 | + nn.Module: ReLU_0 |
| 569 | - test_profiler_tree.py(...): forward | 569 | + torch/nn/modules/module.py(...): _call_impl |
| 570 | - nn.Module: ReLU_0 | 570 | + <built-in method _get_tracing_state of PyCapsule object at 0xXXXXXXXXXXXX> |
| 571 | - torch_npu/npu/__init__.py(...): is_initialized | 571 | + torch/nn/modules/activation.py(...): forward |
| 572 | - torch/nn/modules/module.py(...): _wrapped_call_impl | 572 | + torch/nn/functional.py(...): relu |
| 573 | - torch/nn/modules/module.py(...): _call_impl | 573 | + <built-in function _has_torch_function_unary> |
| 574 | - <built-in method _get_tracing_state of PyCapsule object at 0xXXXXXXXXXXXX> | 574 | + <built-in method relu of type object at 0xXXXXXXXXXXXX> |
| 575 | - torch/nn/modules/activation.py(...): forward | 575 | + aten::relu |
| 576 | - torch/nn/functional.py(...): relu | 576 | + aten::clamp_min |
| 577 | - <built-in function _has_torch_function_unary> | 577 | + nn.Module: Linear_0 |
| 578 | - <built-in method relu of type object at 0xXXXXXXXXXXXX> | 578 | + torch/nn/modules/module.py(...): _call_impl |
| 579 | - aten::relu | 579 | + <built-in method _get_tracing_state of PyCapsule object at 0xXXXXXXXXXXXX> |
| 580 | - aten::clamp_min | 580 | + torch/nn/modules/linear.py(...): forward |
| 581 | - nn.Module: Linear_0 | 581 | + torch/nn/modules/module.py(...): __getattr__ |
| 582 | - torch_npu/npu/__init__.py(...): is_initialized | 582 | + torch/nn/modules/module.py(...): __getattr__ |
| 583 | - torch/nn/modules/module.py(...): _wrapped_call_impl | 583 | + <built-in function linear> |
| 584 | - torch/nn/modules/module.py(...): _call_impl | 584 | + aten::linear |
| 585 | - <built-in method _get_tracing_state of PyCapsule object at 0xXXXXXXXXXXXX> | 585 | + aten::reshape |
| 586 | - torch/nn/modules/linear.py(...): forward | 586 | + aten::view |
| 587 | - torch/nn/modules/module.py(...): __getattr__ | 587 | + aten::t |
| 588 | - torch/nn/modules/module.py(...): __getattr__ | 588 | + aten::transpose |
| 589 | - <built-in function linear> | 589 | + aten::as_strided |
| 590 | - aten::linear | 590 | + aten::addmm |
| 591 | - aten::reshape | 591 | + aten::expand |
| 592 | - aten::view | 592 | + aten::as_strided |
| 593 | - aten::t | 593 | + aten::copy_ |
| 594 | - aten::transpose | 594 | + aten::resolve_conj |
| 595 | - aten::as_strided | 595 | + aten::resolve_conj |
| 596 | - aten::addmm | 596 | + aten::resolve_conj |
| 597 | - aten::expand | 597 | + aten::view |
| 598 | - aten::as_strided | 598 | + nn.Module: ReLU_1 |
| 599 | - aten::copy_ | 599 | + torch/nn/modules/module.py(...): _call_impl |
| 600 | - aten::resolve_conj | 600 | + <built-in method _get_tracing_state of PyCapsule object at 0xXXXXXXXXXXXX> |
| 601 | - aten::resolve_conj | 601 | + torch/nn/modules/activation.py(...): forward |
| 602 | - aten::resolve_conj | 602 | + torch/nn/functional.py(...): relu |
| 603 | - aten::view | 603 | + <built-in function _has_torch_function_unary> |
| 604 | - nn.Module: ReLU_1 | 604 | + <built-in method relu of type object at 0xXXXXXXXXXXXX> |
| 605 | - torch_npu/npu/__init__.py(...): is_initialized | 605 | + aten::relu |
| 606 | - torch/nn/modules/module.py(...): _wrapped_call_impl | 606 | + aten::clamp_min |
| 607 | - torch/nn/modules/module.py(...): _call_impl | ||
| 608 | - <built-in method _get_tracing_state of PyCapsule object at 0xXXXXXXXXXXXX> | ||
| 609 | - torch/nn/modules/activation.py(...): forward | ||
| 610 | - torch/nn/functional.py(...): relu | ||
| 611 | - <built-in function _has_torch_function_unary> | ||
| 612 | - <built-in method relu of type object at 0xXXXXXXXXXXXX> | ||
| 613 | - aten::relu | ||
| 614 | - aten::clamp_min | ||
| 615 | <built-in method ones of type object at 0xXXXXXXXXXXXX> | 607 | <built-in method ones of type object at 0xXXXXXXXXXXXX> |
| 616 | aten::ones | 608 | aten::ones |
| 617 | aten::empty | 609 | aten::empty |
| 618 | aten::fill_ | 610 | aten::fill_ |
| 619 | nn.Module: MyModule_0 | 611 | nn.Module: MyModule_0 |
| 620 | - torch_npu/npu/__init__.py(...): is_initialized | 612 | + torch/nn/modules/module.py(...): _call_impl |
| 621 | - torch/nn/modules/module.py(...): _wrapped_call_impl | 613 | + <built-in method _get_tracing_state of PyCapsule object at 0xXXXXXXXXXXXX> |
| 622 | - torch/nn/modules/module.py(...): _call_impl | 614 | + test_profiler_tree.py(...): forward |
| 623 | - <built-in method _get_tracing_state of PyCapsule object at 0xXXXXXXXXXXXX> | 615 | + nn.Module: ReLU_0 |
| 624 | - test_profiler_tree.py(...): forward | 616 | + torch/nn/modules/module.py(...): _call_impl |
| 625 | - nn.Module: ReLU_0 | 617 | + <built-in method _get_tracing_state of PyCapsule object at 0xXXXXXXXXXXXX> |
| 626 | - torch_npu/npu/__init__.py(...): is_initialized | 618 | + torch/nn/modules/activation.py(...): forward |
| 627 | - torch/nn/modules/module.py(...): _wrapped_call_impl | 619 | + torch/nn/functional.py(...): relu |
| 628 | - torch/nn/modules/module.py(...): _call_impl | 620 | + <built-in function _has_torch_function_unary> |
| 629 | - <built-in method _get_tracing_state of PyCapsule object at 0xXXXXXXXXXXXX> | 621 | + <built-in method relu of type object at 0xXXXXXXXXXXXX> |
| 630 | - torch/nn/modules/activation.py(...): forward | 622 | + aten::relu |
| 631 | - torch/nn/functional.py(...): relu | 623 | + aten::clamp_min |
| 632 | - <built-in function _has_torch_function_unary> | 624 | + nn.Module: Linear_0 |
| 633 | - <built-in method relu of type object at 0xXXXXXXXXXXXX> | 625 | + torch/nn/modules/module.py(...): _call_impl |
| 634 | - aten::relu | 626 | + <built-in method _get_tracing_state of PyCapsule object at 0xXXXXXXXXXXXX> |
| 635 | - aten::clamp_min | 627 | + torch/nn/modules/linear.py(...): forward |
| 636 | - nn.Module: Linear_0 | 628 | + torch/nn/modules/module.py(...): __getattr__ |
| 637 | - torch_npu/npu/__init__.py(...): is_initialized | 629 | + torch/nn/modules/module.py(...): __getattr__ |
| 638 | - torch/nn/modules/module.py(...): _wrapped_call_impl | 630 | + <built-in function linear> |
| 639 | - torch/nn/modules/module.py(...): _call_impl | 631 | + aten::linear |
| 640 | - <built-in method _get_tracing_state of PyCapsule object at 0xXXXXXXXXXXXX> | 632 | + aten::reshape |
| 641 | - torch/nn/modules/linear.py(...): forward | 633 | + aten::view |
| 642 | - torch/nn/modules/module.py(...): __getattr__ | 634 | + aten::t |
| 643 | - torch/nn/modules/module.py(...): __getattr__ | 635 | + aten::transpose |
| 644 | - <built-in function linear> | 636 | + aten::as_strided |
| 645 | - aten::linear | 637 | + aten::addmm |
| 646 | - aten::reshape | 638 | + aten::expand |
| 647 | - aten::view | 639 | + aten::as_strided |
| 648 | - aten::t | 640 | + aten::copy_ |
| 649 | - aten::transpose | 641 | + aten::resolve_conj |
| 650 | - aten::as_strided | 642 | + aten::resolve_conj |
| 651 | - aten::addmm | 643 | + aten::resolve_conj |
| 652 | - aten::expand | 644 | + aten::view |
| 653 | - aten::as_strided | 645 | + nn.Module: ReLU_1 |
| 654 | - aten::copy_ | 646 | + torch/nn/modules/module.py(...): _call_impl |
| 655 | - aten::resolve_conj | 647 | + <built-in method _get_tracing_state of PyCapsule object at 0xXXXXXXXXXXXX> |
| 656 | - aten::resolve_conj | 648 | + torch/nn/modules/activation.py(...): forward |
| 657 | - aten::resolve_conj | 649 | + torch/nn/functional.py(...): relu |
| 658 | - aten::view | 650 | + <built-in function _has_torch_function_unary> |
| 659 | - nn.Module: ReLU_1 | 651 | + <built-in method relu of type object at 0xXXXXXXXXXXXX> |
| 660 | - torch_npu/npu/__init__.py(...): is_initialized | 652 | + aten::relu |
| 661 | - torch/nn/modules/module.py(...): _wrapped_call_impl | 653 | + aten::clamp_min |
| 662 | - torch/nn/modules/module.py(...): _call_impl | ||
| 663 | - <built-in method _get_tracing_state of PyCapsule object at 0xXXXXXXXXXXXX> | ||
| 664 | - torch/nn/modules/activation.py(...): forward | ||
| 665 | - torch/nn/functional.py(...): relu | ||
| 666 | - <built-in function _has_torch_function_unary> | ||
| 667 | - <built-in method relu of type object at 0xXXXXXXXXXXXX> | ||
| 668 | - aten::relu | ||
| 669 | - aten::clamp_min | ||
| 670 | torch/profiler/profiler.py(...): __exit__ | 654 | torch/profiler/profiler.py(...): __exit__ |
| 671 | torch/profiler/profiler.py(...): stop | 655 | torch/profiler/profiler.py(...): stop |
| 672 | ...""", | 656 | ...""", |
| @@ -3,10 +3,6 @@ import torch | |||
| 3 | from torch.nn import Module | 3 | from torch.nn import Module |
| 4 | from torch.utils.data import DataLoader | 4 | from torch.utils.data import DataLoader |
| 5 | 5 | ||
| 6 | -import torch_npu | ||
| 7 | -from torch_npu.utils._step import _custom_call | ||
| 8 | - | ||
| 9 | -original_tx_call = Module.__call__ | ||
| 10 | original_iter = DataLoader.__iter__ | 6 | original_iter = DataLoader.__iter__ |
| 11 | original_save = torch.serialization.save | 7 | original_save = torch.serialization.save |
| 12 | original_singlenext = torch.utils.data.dataloader._SingleProcessDataLoaderIter.__next__ | 8 | original_singlenext = torch.utils.data.dataloader._SingleProcessDataLoaderIter.__next__ |
| @@ -106,10 +102,5 @@ def _custom_save(func): | |||
| 106 | 102 | ||
| 107 | 103 | ||
| 108 | def apply_mstx_patch(): | 104 | def apply_mstx_patch(): |
| 109 | - global original_tx_call | ||
| 110 | - | ||
| 111 | - if Module.__call__.__name__ == "_custom_call": | ||
| 112 | - original_tx_call = _custom_call | ||
| 113 | - Module.__call__ = _custom_tx_call | ||
| 114 | DataLoader.__iter__ = _custom_dataloader_iter | 105 | DataLoader.__iter__ = _custom_dataloader_iter |
| 115 | torch.serialization.save = _custom_save(original_save) | 106 | torch.serialization.save = _custom_save(original_save) |