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/11 23:55:24 UTC
[GitHub] [tvm] gromero opened a new pull request #7449: [µTVM] Print .elf statistics for a model runtime built with Zephyr
gromero opened a new pull request #7449:
URL: https://github.com/apache/tvm/pull/7449
Hi,
Could the following simple change be reviewed please?
Currently there isn't any statistics about the used resources by a model
runtime built with Zephyr, making it difficult to have any idea about, for
instance, the amount of memory taken by the operations necessary to run the
model.
Since Zephyr's SDK already exposes the statistics about various memory
regions on linking by passing '--print-memory-usage' to the linker, it's
possible to use it to have an idea about the amount of memory used by the
model and how much memory is left on the device.
That commit adds a simple method to extract the memory region information
out of the build output and then uses it to show memory usage statistics
for various memory regions when Zephyr finishes building the image to be
flashed to the target device.
Output example follows:
```
gromero@gromero0:~/git/tvm/tutorials/micro$ python3 ./micro_tflite.py
File /home/gromero/.tvm_test_data/data/sine_model.tflite exists, skip.
Model Version: 3
<snip>
Including boilerplate (Zephyr base): /home/gromero/zephyrproject/zephyr/cmake/app/boilerplate.cmake
Including boilerplate (Zephyr base): /home/gromero/zephyrproject/zephyr/cmake/app/boilerplate.cmake
Including boilerplate (Zephyr base): /home/gromero/zephyrproject/zephyr/cmake/app/boilerplate.cmake
Including boilerplate (Zephyr base): /home/gromero/zephyrproject/zephyr/cmake/app/boilerplate.cmake
Including boilerplate (Zephyr base): /home/gromero/zephyrproject/zephyr/cmake/app/boilerplate.cmake
Including boilerplate (Zephyr base): /home/gromero/zephyrproject/zephyr/cmake/app/boilerplate.cmake
Including boilerplate (Zephyr base): /home/gromero/zephyrproject/zephyr/cmake/app/boilerplate.cmake
==================
Memory region Used Size Region Size %age Used
FLASH: 35748 B 1 MB 3.41%
DTCM: 0 GB 64 KB 0.00%
SRAM: 146160 B 256 KB 55.76%
IDT_LIST: 232 B 2 KB 11.33%
make[2]: Leaving directory '/tmp/tmpcb9im44g/build/runtime'
Open On-Chip Debugger 0.10.0+dev-01341-g580d06d9d-dirty (2020-06-25-12:07)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
066CFF485153826687133653
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : clock speed 2000 kHz
Info : STLINK V2J25M14 (API v2) VID:PID 0483:374B
Info : Target voltage: 3.238421
Warn : Silicon bug: single stepping may enter pending exception handler!
Info : stm32f7x.cpu: hardware has 8 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
TargetName Type Endian TapName State
-- ------------------ ---------- ------ ------------------ ------------
0* stm32f7x.cpu hla_target little stm32f7x.cpu running
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08001e20 msp: 0x200331a8
Info : device id = 0x10016449
Info : flash size = 1024 kbytes
auto erase enabled
wrote 65536 bytes from file /tmp/tmpcb9im44g/build/runtime/zephyr/zephyr.hex in 2.129213s (30.058 KiB/s)
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08001e20 msp: 0x200331b0
verified 35748 bytes in 0.489722s (71.286 KiB/s)
shutdown command invoked
result is: [[0.4443792]]
```
Thanks & best regards,
Gustavo
----------------------------------------------------------------
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
[GitHub] [tvm] gromero commented on a change in pull request #7449: [µTVM] Print .elf statistics for a model runtime built with Zephyr
Posted by GitBox <gi...@apache.org>.
gromero commented on a change in pull request #7449:
URL: https://github.com/apache/tvm/pull/7449#discussion_r575381804
##########
File path: python/tvm/micro/contrib/zephyr.py
##########
@@ -204,6 +204,22 @@ def library(self, output, sources, options=None):
)
return tvm.micro.MicroLibrary(build_dir, [f"lib{project_name}.a"])
+ def _print_make_statistics(self, output):
+ print("==================")
+ output = output.splitlines()
+ lines = iter(output)
+ for line in lines:
+ if line.startswith("Memory region"):
+ # print statistics header
+ print(line)
Review comment:
done. @areusch Thanks a lot for the review.[
----------------------------------------------------------------
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
[GitHub] [tvm] gromero commented on a change in pull request #7449: [µTVM] Print .elf statistics for a model runtime built with Zephyr
Posted by GitBox <gi...@apache.org>.
gromero commented on a change in pull request #7449:
URL: https://github.com/apache/tvm/pull/7449#discussion_r575381414
##########
File path: python/tvm/micro/contrib/zephyr.py
##########
@@ -204,6 +204,22 @@ def library(self, output, sources, options=None):
)
return tvm.micro.MicroLibrary(build_dir, [f"lib{project_name}.a"])
+ def _print_make_statistics(self, output):
+ print("==================")
Review comment:
sure! Now the output looks like:
```
INFO:tvm.micro.contrib.zephyr:Memory region Used Size Region Size %age Used
INFO:tvm.micro.contrib.zephyr:--------------------- ---------- ------------ ---------
INFO:tvm.micro.contrib.zephyr: FLASH: 35748 B 1 MB 3.41%
INFO:tvm.micro.contrib.zephyr: DTCM: 0 GB 64 KB 0.00%
INFO:tvm.micro.contrib.zephyr: SRAM: 146160 B 256 KB 55.76%
INFO:tvm.micro.contrib.zephyr: IDT_LIST: 232 B 2 KB 11.33%
```
----------------------------------------------------------------
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
[GitHub] [tvm] gromero commented on pull request #7449: [µTVM] Print .elf statistics for a model runtime built with Zephyr
Posted by GitBox <gi...@apache.org>.
gromero commented on pull request #7449:
URL: https://github.com/apache/tvm/pull/7449#issuecomment-777874239
@tom-gall @areusch
----------------------------------------------------------------
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
[GitHub] [tvm] gromero commented on a change in pull request #7449: [µTVM] Print .elf statistics for a model runtime built with Zephyr
Posted by GitBox <gi...@apache.org>.
gromero commented on a change in pull request #7449:
URL: https://github.com/apache/tvm/pull/7449#discussion_r575381508
##########
File path: python/tvm/micro/contrib/zephyr.py
##########
@@ -204,6 +204,22 @@ def library(self, output, sources, options=None):
)
return tvm.micro.MicroLibrary(build_dir, [f"lib{project_name}.a"])
+ def _print_make_statistics(self, output):
+ print("==================")
+ output = output.splitlines()
+ lines = iter(output)
+ for line in lines:
Review comment:
done
----------------------------------------------------------------
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
[GitHub] [tvm] gromero commented on pull request #7449: [µTVM] Print .elf statistics for a model runtime built with Zephyr
Posted by GitBox <gi...@apache.org>.
gromero commented on pull request #7449:
URL: https://github.com/apache/tvm/pull/7449#issuecomment-779386840
@tmoreau89 thanks for the review and for merging it!
----------------------------------------------------------------
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
[GitHub] [tvm] areusch commented on a change in pull request #7449: [µTVM] Print .elf statistics for a model runtime built with Zephyr
Posted by GitBox <gi...@apache.org>.
areusch commented on a change in pull request #7449:
URL: https://github.com/apache/tvm/pull/7449#discussion_r574914911
##########
File path: python/tvm/micro/contrib/zephyr.py
##########
@@ -204,6 +204,22 @@ def library(self, output, sources, options=None):
)
return tvm.micro.MicroLibrary(build_dir, [f"lib{project_name}.a"])
+ def _print_make_statistics(self, output):
+ print("==================")
Review comment:
want to print this after you see "Memory region"?
##########
File path: python/tvm/micro/contrib/zephyr.py
##########
@@ -204,6 +204,22 @@ def library(self, output, sources, options=None):
)
return tvm.micro.MicroLibrary(build_dir, [f"lib{project_name}.a"])
+ def _print_make_statistics(self, output):
+ print("==================")
+ output = output.splitlines()
+ lines = iter(output)
+ for line in lines:
Review comment:
could you catch StopIteration somewhere so that in the event the output looks weird, this doesn't break the compilation flow?
##########
File path: python/tvm/micro/contrib/zephyr.py
##########
@@ -204,6 +204,22 @@ def library(self, output, sources, options=None):
)
return tvm.micro.MicroLibrary(build_dir, [f"lib{project_name}.a"])
+ def _print_make_statistics(self, output):
+ print("==================")
+ output = output.splitlines()
+ lines = iter(output)
+ for line in lines:
+ if line.startswith("Memory region"):
+ # print statistics header
+ print(line)
Review comment:
it might be better to use _LOG.info() rather than print, so it could be suppressed if needed
----------------------------------------------------------------
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
[GitHub] [tvm] tmoreau89 merged pull request #7449: [µTVM] Print .elf statistics for a model runtime built with Zephyr
Posted by GitBox <gi...@apache.org>.
tmoreau89 merged pull request #7449:
URL: https://github.com/apache/tvm/pull/7449
----------------------------------------------------------------
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
[GitHub] [tvm] gromero commented on pull request #7449: [µTVM] Print .elf statistics for a model runtime built with Zephyr
Posted by GitBox <gi...@apache.org>.
gromero commented on pull request #7449:
URL: https://github.com/apache/tvm/pull/7449#issuecomment-779143981
@tmoreau89 Hi. Could you please merge it?
----------------------------------------------------------------
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
[GitHub] [tvm] gromero commented on a change in pull request #7449: [µTVM] Print .elf statistics for a model runtime built with Zephyr
Posted by GitBox <gi...@apache.org>.
gromero commented on a change in pull request #7449:
URL: https://github.com/apache/tvm/pull/7449#discussion_r575381804
##########
File path: python/tvm/micro/contrib/zephyr.py
##########
@@ -204,6 +204,22 @@ def library(self, output, sources, options=None):
)
return tvm.micro.MicroLibrary(build_dir, [f"lib{project_name}.a"])
+ def _print_make_statistics(self, output):
+ print("==================")
+ output = output.splitlines()
+ lines = iter(output)
+ for line in lines:
+ if line.startswith("Memory region"):
+ # print statistics header
+ print(line)
Review comment:
done. @areusch Thanks a lot for the review.
----------------------------------------------------------------
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