Skip to content

Conversation

@wweic
Copy link
Contributor

@wweic wweic commented Aug 7, 2019

Basic profiler functionality to get operator execution time.

Example output:

#OpName                       	#InvokeCount	#Duration(us): Sum/Mean/Min/Max
fused_nn_softmax              	1         	12.035/12.035/12.035/12.035
fused_nn_bias_add             	1         	1.149/1.149/1.149/1.149
fused_nn_dense                	1         	119.539/119.539/119.539/119.539
fused_nn_batch_flatten        	1         	5.081/5.081/5.081/5.081
fused_nn_global_avg_pool2d    	1         	11.423/11.423/11.423/11.423
fused_add_19                  	2         	73.225/36.6125/36.438/36.787
fused_nn_conv2d_11            	1         	391.84/391.84/391.84/391.84
fused_nn_conv2d_10            	3         	19419.7/6473.22/5625.45/8143.65
fused_nn_relu_4               	4         	217.312/54.328/30.015/102.374
fused_add_18                  	4         	164.761/41.1903/32.124/66.364
Total Duration 107960 us

cc @zhiics @icemelon9 @jroesch

@kevinthesun kevinthesun requested a review from icemelon August 7, 2019 20:02
@wweic wweic force-pushed the vm-debugger branch 4 times, most recently from be94c95 to 04e33e8 Compare August 7, 2019 20:29
@icemelon icemelon self-assigned this Aug 7, 2019
Copy link
Member

@zhiics zhiics left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add an example output of how it looks in the description? probably in the unit test as well?

May be it could be a table shows number of trials, min, max, mean, stdev etc. We can discuss how it should look like.

@u99127
Copy link

u99127 commented Aug 8, 2019

A higher level comment is that such functionality is usually referred to as profiling rather than debugging. What do others think ?

@wweic
Copy link
Contributor Author

wweic commented Aug 8, 2019

A higher level comment is that such functionality is usually referred to as profiling rather than debugging. What do others think ?

Agree what I added lies more in profiling. I'm following the name for current graph runtime debugger(https://docs.tvm.ai/dev/debugger.html), which supports inspecting intermediate tensors and operator execution metrics. I'm basically replicating the behavior for Relay VM hence the name. I expect eventually it will be more like a debugger than a profiler.

@u99127
Copy link

u99127 commented Aug 8, 2019

A higher level comment is that such functionality is usually referred to as profiling rather than debugging. What do others think ?

Agree what I added lies more in profiling. I'm following the name for current graph runtime debugger(https://docs.tvm.ai/dev/debugger.html), which supports inspecting intermediate tensors and operator execution metrics. I'm basically replicating the behavior for Relay VM hence the name. I expect eventually it will be more like a debugger than a profiler.

Ok, makes sense now. Thanks.

@wweic wweic force-pushed the vm-debugger branch 2 times, most recently from ef73e3f to 2a9adae Compare August 11, 2019 22:24
@icemelon
Copy link
Member

You should also set USE_VM_DEBUG to OFF by default in the config.cmake.

@jroesch
Copy link
Member

jroesch commented Aug 13, 2019

I also agree with @u99127 I don't know why the TVM runtime calls this a debugger, this is way more in profiling land then debugger land.

I would imagine a VM debugger to be a typical step debugger instead of just profiling info.

"{}".format(type(target)))
return tgts

class VMCompilerDebug(vm.VMCompiler):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need a different entry point for the debugging the VM? can't we just pass an option into the normal build target?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to pass in an option, then VMCompiler will need to switch between VirtualMachine and VirtualMachineDebug based on the config, which means we have to build VirtualMachineDebug all the time. I think we need the option to not build the VirtualMachineDebug source, does it make sense?

@zhiics
Copy link
Member

zhiics commented Aug 13, 2019

Yeah, we probably can rename it to profiler since debugger is different than what we are doing.

A side note, we can probably have a follow-up pr to add memory stats for each op as well through memory_manager.

@yongwww
Copy link
Member

yongwww commented Aug 13, 2019

+1 to call this a profiler. debugger makes no sense to me

@wweic wweic changed the title [Relay][VM]VM debugger [Relay][VM]VM Profiler Aug 13, 2019
@wweic
Copy link
Contributor Author

wweic commented Aug 13, 2019

Thanks. I renamed the PR to profiler. Luckily I don't think we need to change sources since I haven't used the term debugger in sources. But let me know if you have opinions about file naming.

@zhiics
Copy link
Member

zhiics commented Aug 13, 2019

Do we need to change the file name and class name as well?

@jroesch jroesch merged commit 95f12e3 into apache:master Aug 21, 2019
wweic added a commit to wweic/tvm that referenced this pull request Sep 16, 2019
* [Relay][VM]VM debugger

* Report mean/min/max for op duration

* Typos

* Lint

* Lint

* Lint

* Support build debug VM in CMake

* Lint

* Enable VM debug in unit test

* Disable debug vm test until new docker image is built

* Add device sync code

* Fix qnn unit test

* Disable vm debug by default

* Rename files

* Rename classes

* Fix comment

* Fix comment
wweic added a commit to wweic/tvm that referenced this pull request Sep 16, 2019
* [Relay][VM]VM debugger

* Report mean/min/max for op duration

* Typos

* Lint

* Lint

* Lint

* Support build debug VM in CMake

* Lint

* Enable VM debug in unit test

* Disable debug vm test until new docker image is built

* Add device sync code

* Fix qnn unit test

* Disable vm debug by default

* Rename files

* Rename classes

* Fix comment

* Fix comment
wweic added a commit to neo-ai/tvm that referenced this pull request Sep 16, 2019
* [Relay][VM]VM debugger

* Report mean/min/max for op duration

* Typos

* Lint

* Lint

* Lint

* Support build debug VM in CMake

* Lint

* Enable VM debug in unit test

* Disable debug vm test until new docker image is built

* Add device sync code

* Fix qnn unit test

* Disable vm debug by default

* Rename files

* Rename classes

* Fix comment

* Fix comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants