You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/02/22 16:59:30 UTC

[GitHub] [tvm] tkonolige commented on a change in pull request #7495: [Relay VM] VM Profiler Supports Profiling Instruction Stats

tkonolige commented on a change in pull request #7495:
URL: https://github.com/apache/tvm/pull/7495#discussion_r580414040



##########
File path: src/runtime/vm/vm.cc
##########
@@ -360,11 +360,34 @@ void VirtualMachine::RunLoop() {
   ICHECK(this->code_);
   pc_ = 0;
   Index frame_start = frames_.size();
+
+#ifdef USE_VM_PROFILER
+  bool started = false;
+  Opcode last_inst;
+  auto inst_begin = std::chrono::high_resolution_clock::now();
+  auto inst_end = inst_begin;
+#endif
+
   while (true) {
   main_loop:
     auto const& instr = code_[this->pc_];
     DLOG(INFO) << "Executing(" << pc_ << "): " << instr;
 
+#ifdef USE_VM_PROFILER
+    if (started) {
+      inst_end = std::chrono::high_resolution_clock::now();
+      double inst_duration =
+        std::chrono::duration_cast<std::chrono::duration<double>>(inst_end - inst_begin)\
+        .count() * 1e6;

Review comment:
       ```suggestion
           std::chrono::duration<double, std::micro>(inst_end - inst_begin)\
           .count();
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org