PhilippvK opened a new issue #10270:
URL: https://github.com/apache/tvm/issues/10270


   ### Expected behavior
   
   In the `microtvm_api_server.py` for various MicroTVM project API templates 
options are defined in the following way:
   
   ```
   server.ProjectOption(
       "warning_as_error",
       optional=["generate_project"],
       type="bool",
       help="Treat warnings as errors and raise an Exception.",
   ),
   ```
   
   As every of these options gets a certain `type` it may be assumed that these 
type hints are actually used by TVM and not only for documentation.
   
   ### Actual behavior
   
   However the only purpose of the `type` field in this option is restricting 
the allowed value of these options passed as `--project-option ` command line 
arguments:
   
   
https://github.com/apache/tvm/blob/64e94abcbb9578bf2ace2e6e1e1e618bd09d2605/python/tvm/driver/tvmc/project.py#L74-L75
   
   The following is a consequence of the described problem:
   
   Using `--project-option warning_as_error=false` vs. `--project-option 
warning_as_error=true` on the TVMC command line (e.g. with `tvmc micro create 
project mlf.tar [zephyr|arduino]`) both results in warnings being turned into 
errors.
   
   The reason behind this that the true/false targuments are still strings when 
beeing interpreted as a bool here: `options["warning_as_error"]`. However 
`bool("false")  == bool("true") == True`. Instead either 
`bool(distutils.util.strtobool(options["warning_as_error"]))` or a custom map 
similar to
   
   
https://github.com/apache/tvm/blob/64e94abcbb9578bf2ace2e6e1e1e618bd09d2605/python/tvm/driver/tvmc/pass_config.py#L80-L83
   
   needs to be applied at some stage. (Implicitly during the command line 
parsing (!project.py) or explicitly `microtvm_api_server.py`)
   
   The missing type conversions would also affect every `ProjectOption` with 
`type="int"`, however currently those values (e.g. for `gdbserver_port`) are 
converted to a string anyway aka. it accedentially works as expected.
   
   ### Environment
   
   TVM commit (`55849e651e3dff6cffeb7fd14aa89699e9575d10`) using 
`./docker/bash.sh tlcpack/ci-qemu:v0.10 for Zephyr and Arduino support`
   
   ### Steps to reproduce
   
   - Build TVM as usual with MicroTVM support
   - Download model and generate MLF:
   
     ```
     wget 
https://github.com/tensorflow/tflite-micro/raw/main/tensorflow/lite/micro/examples/magic_wand/magic_wand.tflite
     tvmc compile magic_wand.tflite \
         --target='c -keys=cpu -link-params=0 -model=host' \
         --runtime=crt \
         --runtime-crt-system-lib 1 \
         --executor='graph' \
         --executor-graph-link-params 0 \
         --output model.tar \
         --output-format mlf \
         --pass-config tir.disable_vectorize=1 \
         --disabled-pass=AlterOpLayout
     ```
   
   - Apply a small patch to the Zephy version number to trigger a warning being 
printed:
   
     ```
     diff --git a/opt/zephyrproject/zephyr/VERSION.old 
b/opt/zephyrproject/zephyr/VERSION
     index 1e4d35466..a934c886c 100644
     --- a/opt/zephyrproject/zephyr/VERSION.old
     +++ b/opt/zephyrproject/zephyr/VERSION
     @@ -1,4 +1,4 @@
     -VERSION_MAJOR = 2
     +VERSION_MAJOR = 3
      VERSION_MINOR = 7
      PATCHLEVEL = 1
      VERSION_TWEAK = 0
     ```
   
   - Relevant command:
   
     ```
     python -m tvm.driver.tvmc micro create -f project model.tar zephyr 
--project-option project_type=host_driven zephyr_board=qemu_x86 ; python -m 
tvm.driver.tvmc micro create -f project model.tar zephyr --project-option 
project_type=host_driven zephyr_board=qemu_x86 --project-option 
warning_as_error=false ; python -m tvm.driver.tvmc micro create -f project 
model.tar zephyr --project-option project_type=host_driven 
zephyr_board=qemu_x86 --project-option warning_as_error=true
     ```
   
   - Resulting output:
   
     ```
     WARNING:__main__:Zephyr version found is not supported: found 3.7, 
expected 2.7.
     Error: Option 'project_type' is required but was not specified. Use 
--list-options to see all required options.
     Error: Option 'project_type' is required but was not specified. Use 
--list-options to see all required options.
     ```
   
   - Expected output:
   
     ```
     WARNING:__main__:Zephyr version found is not supported: found 3.7, 
expected 2.7.
     WARNING:__main__:Zephyr version found is not supported: found 3.7, 
expected 2.7.
     Error: Option 'project_type' is required but was not specified. Use 
--list-options to see all required options.
     ```
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to