From f9b89be832649ceac42bf372947b717c0e403817 Mon Sep 17 00:00:00 2001 From: Zhang Qinghua Date: Sun, 3 Jan 2021 09:54:48 +0800 Subject: [PATCH] Add compile profiling for PyNative mode. --- mindspore/ccsrc/pipeline/jit/action.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mindspore/ccsrc/pipeline/jit/action.cc b/mindspore/ccsrc/pipeline/jit/action.cc index 8ad6642e4df..88ce65b3cb9 100644 --- a/mindspore/ccsrc/pipeline/jit/action.cc +++ b/mindspore/ccsrc/pipeline/jit/action.cc @@ -315,7 +315,14 @@ bool GeOptimizeAction(const ResourcePtr &res) { return OptimizeAction(res, kGePa bool VmOptimizeAction(const ResourcePtr &res) { return OptimizeAction(res, kVmPasses); } -bool PynativeOptimizeAction(const ResourcePtr &res) { return OptimizeAction(res, kPynativePasses); } +bool PynativeOptimizeAction(const ResourcePtr &resource) { + WITH(MsProfile::GetProfile())[&resource]() { (void)OptimizeAction(resource, kPynativePasses); }; +#ifdef ENABLE_PROFILE + MsProfile::Print(); + MsProfile::Reset(); +#endif + return true; +} bool PynativeElimOpt(const ResourcePtr &res) { if (res->manager() == nullptr) {