Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tvmc] command line driver 'compile' (part 2/4) #6302

Merged
merged 10 commits into from
Sep 18, 2020
Merged

[tvmc] command line driver 'compile' (part 2/4) #6302

merged 10 commits into from
Sep 18, 2020

Conversation

leandron
Copy link
Contributor

@leandron leandron commented Aug 19, 2020

This is a follow-up PR on top of #6112, introducing compile subcommand on tvmc or python -m tvm.driver.tvmc

  • Add 'compile' subcommand into tvmc (tvm.driver.tvmc)
  • Add frontends: Keras, ONNX, TensorFlow, tflite, PyTorch
  • Add tests for the 'compile' subcommand
  • Add frontend dependencies on setup.py to make TVM python package ready-to-use on install

Known limitations:

  • It covers a subset of TVM supported frontends: Keras, ONNX, tflite, TensorFlow and PyTorch
  • It assumes graph runtime only

There are still 2 patches to be submitted: tvmc tune and tvmc run, both depending on this.

In case you want to have a look and test compile, you can use the --dump-codegen ll or --dump-codegen asm or --dump-codegen relay to check the output module as source.

A sample usage would look like (assumes TVM is built and working):

wget https://storage.googleapis.com/download.tensorflow.org/models/mobilenet_v1_2018_08_02/mobilenet_v1_1.0_224_quant.tgz

tar xvvzf mobilenet_v1_1.0_224_quant.tgz

python -m tvm.driver.tvmc compile --target=llvm --output model.tar --dump-code relay  mobilenet_v1_1.0_224_quant.tflite

cat model.relay

# should output mobilenet as relay

@tqchen @comaniac @jroesch, can you have a look?

@leandron
Copy link
Contributor Author

Also cc @tom-gall who sent a patch on top of my previous PR adding supporting AArch32. Can you send that one again, once this one is merged?

@tom-gall
Copy link
Contributor

Also cc @tom-gall who sent a patch on top of my previous PR adding supporting AArch32. Can you send that one again, once this one is merged?

Sure happy to.

Copy link
Contributor

@comaniac comaniac left a comment

Choose a reason for hiding this comment

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

Reviewed the argument interface only and have some comments. I'd prefer to have consents on the interface before diving into the implementations.

python/tvm/driver/tvmc/__init__.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/compiler.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/compiler.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/compiler.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/compiler.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/compiler.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/compiler.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/compiler.py Show resolved Hide resolved
python/tvm/driver/tvmc/compiler.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/compiler.py Outdated Show resolved Hide resolved
@tqchen
Copy link
Member

tqchen commented Aug 20, 2020

One thing to note is that given we are updating the target convention to use the json as an input, it might be helpful to think about what is the target that can be accepted from the command line. cc @comaniac @junrushao1994

@junrushao
Copy link
Member

@tqchen I am thinking about unifying target creation from legacy string, JSON file and tags.

@comaniac
Copy link
Contributor

One thing to note is that given we are updating the target convention to use the json as an input, it might be helpful to think about what is the target that can be accepted from the command line. cc @comaniac @junrushao1994

Zhi and I had a discussion with ARM folks today and here is a rough proposal:

  • --target could accept either a target or a JSON file path.
  • In the case of target string, it should match either a predefined tag (e.g., rasp4b), or it has to be a valid target string that can be parsed by target.create().
  • In the case of JSON file, it must be valid to be parsed by target JSON parser.

As a result, the users that know nothing about the target can simply provide a tag. On ther other hand, advance users can still specify targets in any supported formats.

python/tvm/driver/tvmc/common.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/compiler.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/compiler.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/compiler.py Show resolved Hide resolved
python/tvm/driver/tvmc/compiler.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/frontends.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/frontends.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/frontends.py Show resolved Hide resolved
tests/python/driver/tvmc/test_frontends.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/common.py Show resolved Hide resolved
@leandron
Copy link
Contributor Author

leandron commented Sep 9, 2020

I updated it removing a skipped test due to #6410, which is now fixed.

@leandron
Copy link
Contributor Author

leandron commented Sep 10, 2020

There was an issue we discovered with ConvertLayout when running the new tests introduced here, once #6442 is merged, all the tests should pass.

@comaniac would you mind having another look into this PR?

Copy link
Contributor

@comaniac comaniac left a comment

Choose a reason for hiding this comment

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

Thanks for the changes. It looks much better now.

python/setup.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/compiler.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/compiler.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/compiler.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/compiler.py Outdated Show resolved Hide resolved
python/tvm/driver/tvmc/frontends.py Outdated Show resolved Hide resolved
tests/python/driver/tvmc/test_frontends.py Outdated Show resolved Hide resolved
tests/python/driver/tvmc/test_frontends.py Outdated Show resolved Hide resolved
tests/python/driver/tvmc/test_frontends.py Outdated Show resolved Hide resolved
tests/python/driver/tvmc/test_frontends.py Outdated Show resolved Hide resolved
@comaniac
Copy link
Contributor

cc @masahi @junrushao1994 @tqchen for a final review.

@leandron
Copy link
Contributor Author

leandron commented Sep 11, 2020

Thanks @comaniac - I submitted a new version incorporating pretty much all the feedback (apart from the Target one, details in the comment).

One test is still expected to fail due to #6442, which is blocked by the Python linting massive refactoring #6448 to come.

@leandron
Copy link
Contributor Author

leandron commented Sep 16, 2020

I recently rebased with the latest changes and un-skipped the test fixed by #6442

@tqchen @comaniac @junrushao1994 would you mind having another look into this PR?

Copy link
Contributor

@comaniac comaniac left a comment

Choose a reason for hiding this comment

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

LGTM. We can merge it after passing the CI.
Thanks for the efforts :)

python/setup.py Outdated Show resolved Hide resolved
leandron and others added 6 commits September 17, 2020 11:25
 * Add 'compile' subcommand into tvmc (tvm.driver.tvmc)
 * Add frontends: Keras, ONNX, TensorFlow, tflite, PyTorch
 * Add tests for the 'compile' subcommand
 * Enable command line driver tests as part of integration tests
 * Skip tests if the cross-compilation toolchain is not installed


Co-authored-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
Co-authored-by: Matthew Barrett <Matthew.Barrett@arm.com>
Co-authored-by: Dmitriy Smirnov <dmitriy.smirnov@arm.com>
Co-authored-by: Luke Hutton <luke.hutton@arm.com>
Co-authored-by: Giuseppe Rossini <giuseppe.rossini@arm.com>
Co-authored-by: Matthew Barrett <matthew.barrett@arm.com>
Co-authored-by: Elen Kalda <elen.kalda@arm.com>
Co-authored-by: Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
Co-authored-by: Jeremy Johnson <jeremy.johnson@arm.com>
Co-authored-by: Ina Dobreva <Ina.Dobreva@arm.com>
python/setup.py Outdated Show resolved Hide resolved
@tqchen tqchen merged commit 292b640 into apache:master Sep 18, 2020
@tqchen
Copy link
Member

tqchen commented Sep 18, 2020

Thanks @leandron @comaniac @masahi !

@leandron leandron deleted the tvmc_compile_feature branch October 1, 2020 13:55
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 13, 2020
* [tvmc] command line driver 'compile' (part 2/4)

 * Add 'compile' subcommand into tvmc (tvm.driver.tvmc)
 * Add frontends: Keras, ONNX, TensorFlow, tflite, PyTorch
 * Add tests for the 'compile' subcommand
 * Enable command line driver tests as part of integration tests
 * Skip tests if the cross-compilation toolchain is not installed


Co-authored-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
Co-authored-by: Matthew Barrett <Matthew.Barrett@arm.com>
Co-authored-by: Dmitriy Smirnov <dmitriy.smirnov@arm.com>
Co-authored-by: Luke Hutton <luke.hutton@arm.com>
Co-authored-by: Giuseppe Rossini <giuseppe.rossini@arm.com>
Co-authored-by: Matthew Barrett <matthew.barrett@arm.com>
Co-authored-by: Elen Kalda <elen.kalda@arm.com>
Co-authored-by: Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
Co-authored-by: Jeremy Johnson <jeremy.johnson@arm.com>
Co-authored-by: Ina Dobreva <Ina.Dobreva@arm.com>

* tvmc: adjust TODOs

* tvmc: fix linting errors

* Address code-review comments

* Adjust pytest fixture to not break when there is no tensorflow

* Fix frontend tests, to cope with different frameworks in different images

* Apply suggestions from code review

Co-authored-by: Cody Yu <comaniac0422@gmail.com>

* Fix lint and code-review issues

* Re-format with black.

* tvmc: Move dependencies to extras_requires

Co-authored-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
Co-authored-by: Matthew Barrett <Matthew.Barrett@arm.com>
Co-authored-by: Dmitriy Smirnov <dmitriy.smirnov@arm.com>
Co-authored-by: Luke Hutton <luke.hutton@arm.com>
Co-authored-by: Giuseppe Rossini <giuseppe.rossini@arm.com>
Co-authored-by: Elen Kalda <elen.kalda@arm.com>
Co-authored-by: Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
Co-authored-by: Jeremy Johnson <jeremy.johnson@arm.com>
Co-authored-by: Ina Dobreva <Ina.Dobreva@arm.com>
Co-authored-by: Cody Yu <comaniac0422@gmail.com>
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 14, 2020
* [tvmc] command line driver 'compile' (part 2/4)

 * Add 'compile' subcommand into tvmc (tvm.driver.tvmc)
 * Add frontends: Keras, ONNX, TensorFlow, tflite, PyTorch
 * Add tests for the 'compile' subcommand
 * Enable command line driver tests as part of integration tests
 * Skip tests if the cross-compilation toolchain is not installed


Co-authored-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
Co-authored-by: Matthew Barrett <Matthew.Barrett@arm.com>
Co-authored-by: Dmitriy Smirnov <dmitriy.smirnov@arm.com>
Co-authored-by: Luke Hutton <luke.hutton@arm.com>
Co-authored-by: Giuseppe Rossini <giuseppe.rossini@arm.com>
Co-authored-by: Matthew Barrett <matthew.barrett@arm.com>
Co-authored-by: Elen Kalda <elen.kalda@arm.com>
Co-authored-by: Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
Co-authored-by: Jeremy Johnson <jeremy.johnson@arm.com>
Co-authored-by: Ina Dobreva <Ina.Dobreva@arm.com>

* tvmc: adjust TODOs

* tvmc: fix linting errors

* Address code-review comments

* Adjust pytest fixture to not break when there is no tensorflow

* Fix frontend tests, to cope with different frameworks in different images

* Apply suggestions from code review

Co-authored-by: Cody Yu <comaniac0422@gmail.com>

* Fix lint and code-review issues

* Re-format with black.

* tvmc: Move dependencies to extras_requires

Co-authored-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
Co-authored-by: Matthew Barrett <Matthew.Barrett@arm.com>
Co-authored-by: Dmitriy Smirnov <dmitriy.smirnov@arm.com>
Co-authored-by: Luke Hutton <luke.hutton@arm.com>
Co-authored-by: Giuseppe Rossini <giuseppe.rossini@arm.com>
Co-authored-by: Elen Kalda <elen.kalda@arm.com>
Co-authored-by: Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
Co-authored-by: Jeremy Johnson <jeremy.johnson@arm.com>
Co-authored-by: Ina Dobreva <Ina.Dobreva@arm.com>
Co-authored-by: Cody Yu <comaniac0422@gmail.com>
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 15, 2020
* [tvmc] command line driver 'compile' (part 2/4)

 * Add 'compile' subcommand into tvmc (tvm.driver.tvmc)
 * Add frontends: Keras, ONNX, TensorFlow, tflite, PyTorch
 * Add tests for the 'compile' subcommand
 * Enable command line driver tests as part of integration tests
 * Skip tests if the cross-compilation toolchain is not installed


Co-authored-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
Co-authored-by: Matthew Barrett <Matthew.Barrett@arm.com>
Co-authored-by: Dmitriy Smirnov <dmitriy.smirnov@arm.com>
Co-authored-by: Luke Hutton <luke.hutton@arm.com>
Co-authored-by: Giuseppe Rossini <giuseppe.rossini@arm.com>
Co-authored-by: Matthew Barrett <matthew.barrett@arm.com>
Co-authored-by: Elen Kalda <elen.kalda@arm.com>
Co-authored-by: Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
Co-authored-by: Jeremy Johnson <jeremy.johnson@arm.com>
Co-authored-by: Ina Dobreva <Ina.Dobreva@arm.com>

* tvmc: adjust TODOs

* tvmc: fix linting errors

* Address code-review comments

* Adjust pytest fixture to not break when there is no tensorflow

* Fix frontend tests, to cope with different frameworks in different images

* Apply suggestions from code review

Co-authored-by: Cody Yu <comaniac0422@gmail.com>

* Fix lint and code-review issues

* Re-format with black.

* tvmc: Move dependencies to extras_requires

Co-authored-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
Co-authored-by: Matthew Barrett <Matthew.Barrett@arm.com>
Co-authored-by: Dmitriy Smirnov <dmitriy.smirnov@arm.com>
Co-authored-by: Luke Hutton <luke.hutton@arm.com>
Co-authored-by: Giuseppe Rossini <giuseppe.rossini@arm.com>
Co-authored-by: Elen Kalda <elen.kalda@arm.com>
Co-authored-by: Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
Co-authored-by: Jeremy Johnson <jeremy.johnson@arm.com>
Co-authored-by: Ina Dobreva <Ina.Dobreva@arm.com>
Co-authored-by: Cody Yu <comaniac0422@gmail.com>
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 15, 2020
* [tvmc] command line driver 'compile' (part 2/4)

 * Add 'compile' subcommand into tvmc (tvm.driver.tvmc)
 * Add frontends: Keras, ONNX, TensorFlow, tflite, PyTorch
 * Add tests for the 'compile' subcommand
 * Enable command line driver tests as part of integration tests
 * Skip tests if the cross-compilation toolchain is not installed


Co-authored-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
Co-authored-by: Matthew Barrett <Matthew.Barrett@arm.com>
Co-authored-by: Dmitriy Smirnov <dmitriy.smirnov@arm.com>
Co-authored-by: Luke Hutton <luke.hutton@arm.com>
Co-authored-by: Giuseppe Rossini <giuseppe.rossini@arm.com>
Co-authored-by: Matthew Barrett <matthew.barrett@arm.com>
Co-authored-by: Elen Kalda <elen.kalda@arm.com>
Co-authored-by: Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
Co-authored-by: Jeremy Johnson <jeremy.johnson@arm.com>
Co-authored-by: Ina Dobreva <Ina.Dobreva@arm.com>

* tvmc: adjust TODOs

* tvmc: fix linting errors

* Address code-review comments

* Adjust pytest fixture to not break when there is no tensorflow

* Fix frontend tests, to cope with different frameworks in different images

* Apply suggestions from code review

Co-authored-by: Cody Yu <comaniac0422@gmail.com>

* Fix lint and code-review issues

* Re-format with black.

* tvmc: Move dependencies to extras_requires

Co-authored-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
Co-authored-by: Matthew Barrett <Matthew.Barrett@arm.com>
Co-authored-by: Dmitriy Smirnov <dmitriy.smirnov@arm.com>
Co-authored-by: Luke Hutton <luke.hutton@arm.com>
Co-authored-by: Giuseppe Rossini <giuseppe.rossini@arm.com>
Co-authored-by: Elen Kalda <elen.kalda@arm.com>
Co-authored-by: Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
Co-authored-by: Jeremy Johnson <jeremy.johnson@arm.com>
Co-authored-by: Ina Dobreva <Ina.Dobreva@arm.com>
Co-authored-by: Cody Yu <comaniac0422@gmail.com>
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 16, 2020
* [tvmc] command line driver 'compile' (part 2/4)

 * Add 'compile' subcommand into tvmc (tvm.driver.tvmc)
 * Add frontends: Keras, ONNX, TensorFlow, tflite, PyTorch
 * Add tests for the 'compile' subcommand
 * Enable command line driver tests as part of integration tests
 * Skip tests if the cross-compilation toolchain is not installed


Co-authored-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
Co-authored-by: Matthew Barrett <Matthew.Barrett@arm.com>
Co-authored-by: Dmitriy Smirnov <dmitriy.smirnov@arm.com>
Co-authored-by: Luke Hutton <luke.hutton@arm.com>
Co-authored-by: Giuseppe Rossini <giuseppe.rossini@arm.com>
Co-authored-by: Matthew Barrett <matthew.barrett@arm.com>
Co-authored-by: Elen Kalda <elen.kalda@arm.com>
Co-authored-by: Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
Co-authored-by: Jeremy Johnson <jeremy.johnson@arm.com>
Co-authored-by: Ina Dobreva <Ina.Dobreva@arm.com>

* tvmc: adjust TODOs

* tvmc: fix linting errors

* Address code-review comments

* Adjust pytest fixture to not break when there is no tensorflow

* Fix frontend tests, to cope with different frameworks in different images

* Apply suggestions from code review

Co-authored-by: Cody Yu <comaniac0422@gmail.com>

* Fix lint and code-review issues

* Re-format with black.

* tvmc: Move dependencies to extras_requires

Co-authored-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
Co-authored-by: Matthew Barrett <Matthew.Barrett@arm.com>
Co-authored-by: Dmitriy Smirnov <dmitriy.smirnov@arm.com>
Co-authored-by: Luke Hutton <luke.hutton@arm.com>
Co-authored-by: Giuseppe Rossini <giuseppe.rossini@arm.com>
Co-authored-by: Elen Kalda <elen.kalda@arm.com>
Co-authored-by: Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
Co-authored-by: Jeremy Johnson <jeremy.johnson@arm.com>
Co-authored-by: Ina Dobreva <Ina.Dobreva@arm.com>
Co-authored-by: Cody Yu <comaniac0422@gmail.com>
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Oct 19, 2020
* [tvmc] command line driver 'compile' (part 2/4)

 * Add 'compile' subcommand into tvmc (tvm.driver.tvmc)
 * Add frontends: Keras, ONNX, TensorFlow, tflite, PyTorch
 * Add tests for the 'compile' subcommand
 * Enable command line driver tests as part of integration tests
 * Skip tests if the cross-compilation toolchain is not installed


Co-authored-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
Co-authored-by: Matthew Barrett <Matthew.Barrett@arm.com>
Co-authored-by: Dmitriy Smirnov <dmitriy.smirnov@arm.com>
Co-authored-by: Luke Hutton <luke.hutton@arm.com>
Co-authored-by: Giuseppe Rossini <giuseppe.rossini@arm.com>
Co-authored-by: Matthew Barrett <matthew.barrett@arm.com>
Co-authored-by: Elen Kalda <elen.kalda@arm.com>
Co-authored-by: Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
Co-authored-by: Jeremy Johnson <jeremy.johnson@arm.com>
Co-authored-by: Ina Dobreva <Ina.Dobreva@arm.com>

* tvmc: adjust TODOs

* tvmc: fix linting errors

* Address code-review comments

* Adjust pytest fixture to not break when there is no tensorflow

* Fix frontend tests, to cope with different frameworks in different images

* Apply suggestions from code review

Co-authored-by: Cody Yu <comaniac0422@gmail.com>

* Fix lint and code-review issues

* Re-format with black.

* tvmc: Move dependencies to extras_requires

Co-authored-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
Co-authored-by: Matthew Barrett <Matthew.Barrett@arm.com>
Co-authored-by: Dmitriy Smirnov <dmitriy.smirnov@arm.com>
Co-authored-by: Luke Hutton <luke.hutton@arm.com>
Co-authored-by: Giuseppe Rossini <giuseppe.rossini@arm.com>
Co-authored-by: Elen Kalda <elen.kalda@arm.com>
Co-authored-by: Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
Co-authored-by: Jeremy Johnson <jeremy.johnson@arm.com>
Co-authored-by: Ina Dobreva <Ina.Dobreva@arm.com>
Co-authored-by: Cody Yu <comaniac0422@gmail.com>
@OneIsAll-w
Copy link

tvmc first-run with 'compile' problem
I’m attempting to compile the resnet-50-v2.7.onnx model using the command :
python -m tvm.driver.tvmc compile --target "llvm" --output compiled_module.tar resnet50-v2-7.onnx
and I’m running into an error:
WARNING:root:Attribute momentum is ignored in relay.sym.batch_norm
WARNING:root:Attribute spatial is ignored in relay.sym.batch_norm
Traceback (most recent call last):
File "/home/tw/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/home/tw/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/tw/tvm/python/tvm/driver/tvmc/main.py", line 24, in
tvmc.main.main()
File "/home/tw/tvm/python/tvm/driver/tvmc/main.py", line 92, in main
sys.exit(_main(sys.argv[1:]))
File "/home/tw/tvm/python/tvm/driver/tvmc/main.py", line 85, in _main
return args.func(args)
File "/home/tw/tvm/python/tvm/driver/tvmc/compiler.py", line 114, in drive_compile
args.desired_layout,
File "/home/tw/tvm/python/tvm/driver/tvmc/compiler.py", line 182, in compile_model
with open(target) as target_file:
IsADirectoryError: [Errno 21] Is a directory: 'llvm'
Therefore,I want to ask you this problem,Where might I be going wrong?

@leandron
Copy link
Contributor Author

tvmc first-run with 'compile' problem
I’m attempting to compile the resnet-50-v2.7.onnx model using the command :
python -m tvm.driver.tvmc compile --target "llvm" --output compiled_module.tar resnet50-v2-7.onnx
and I’m running into an error:
WARNING:root:Attribute momentum is ignored in relay.sym.batch_norm
WARNING:root:Attribute spatial is ignored in relay.sym.batch_norm
Traceback (most recent call last):
File "/home/tw/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/home/tw/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/tw/tvm/python/tvm/driver/tvmc/main.py", line 24, in
tvmc.main.main()
File "/home/tw/tvm/python/tvm/driver/tvmc/main.py", line 92, in main
sys.exit(_main(sys.argv[1:]))
File "/home/tw/tvm/python/tvm/driver/tvmc/main.py", line 85, in _main
return args.func(args)
File "/home/tw/tvm/python/tvm/driver/tvmc/compiler.py", line 114, in drive_compile
args.desired_layout,
File "/home/tw/tvm/python/tvm/driver/tvmc/compiler.py", line 182, in compile_model
with open(target) as target_file:
IsADirectoryError: [Errno 21] Is a directory: 'llvm'
Therefore,I want to ask you this problem,Where might I be going wrong?

This is a small issue, that only reproduce because you probably have an llvm directory in your current directory. I just submitted a fix to it in #7663. Thanks for reporting.

@OneIsAll-w
Copy link

Thanks a lot @leandron
but I still have some problems in compiling the resnet-50-v2.7.onnx model using the command :
python -m tvm.driver.tvmc compile --target "llvm" --output compiled_module.tar resnet50-v2-7.onnx
and I’m running into an error:
WARNING:root:Attribute momentum is ignored in relay.sym.batch_norm
WARNING:root:Attribute spatial is ignored in relay.sym.batch_norm
Traceback (most recent call last):
File "/home/tw/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/home/tw/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/tw/tvm/python/tvm/driver/tvmc/main.py", line 24, in
tvmc.main.main()
File "/home/tw/tvm/python/tvm/driver/tvmc/main.py", line 92, in main
sys.exit(_main(sys.argv[1:]))
File "/home/tw/tvm/python/tvm/driver/tvmc/main.py", line 85, in _main
return args.func(args)
File "/home/tw/tvm/python/tvm/driver/tvmc/compiler.py", line 114, in drive_compile
args.desired_layout,
File "/home/tw/tvm/python/tvm/driver/tvmc/compiler.py", line 189, in compile_model
tvm_target = tvm.target.Target(target)
File "/home/tw/tvm/python/tvm/target/target.py", line 92, in init
self.init_handle_by_constructor(_ffi_api.Target, tag_or_str_or_dict)
File "/home/tw/tvm/python/tvm/_ffi/_ctypes/object.py", line 131, in init_handle_by_constructor
handle = init_by_constructor(fconstructor, args)
File "/home/tw/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 246, in init_handle_by_constructor
values, tcodes, num_args = _make_tvm_args(args, temp_args)
File "/home/tw/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 163, in _make_tvm_args
values[i].v_str = c_str(arg)
File "/home/tw/tvm/python/tvm/_ffi/base.py", line 88, in c_str
return ctypes.c_char_p(string.encode("utf-8"))
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 0-1: surrogates not allowed
Sorry,I still cannot solve this problem

@leandron
Copy link
Contributor Author

Thanks a lot @leandron
but I still have some problems in compiling the resnet-50-v2.7.onnx model using the command :
python -m tvm.driver.tvmc compile --target "llvm" --output compiled_module.tar resnet50-v2-7.onnx
and I’m running into an error:
WARNING:root:Attribute momentum is ignored in relay.sym.batch_norm
WARNING:root:Attribute spatial is ignored in relay.sym.batch_norm
Traceback (most recent call last):
File "/home/tw/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/home/tw/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/tw/tvm/python/tvm/driver/tvmc/main.py", line 24, in
tvmc.main.main()
File "/home/tw/tvm/python/tvm/driver/tvmc/main.py", line 92, in main
sys.exit(_main(sys.argv[1:]))
File "/home/tw/tvm/python/tvm/driver/tvmc/main.py", line 85, in _main
return args.func(args)
File "/home/tw/tvm/python/tvm/driver/tvmc/compiler.py", line 114, in drive_compile
args.desired_layout,
File "/home/tw/tvm/python/tvm/driver/tvmc/compiler.py", line 189, in compile_model
tvm_target = tvm.target.Target(target)
File "/home/tw/tvm/python/tvm/target/target.py", line 92, in init
self.init_handle_by_constructor(_ffi_api.Target, tag_or_str_or_dict)
File "/home/tw/tvm/python/tvm/_ffi/_ctypes/object.py", line 131, in init_handle_by_constructor
handle = init_by_constructor(fconstructor, args)
File "/home/tw/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 246, in init_handle_by_constructor
values, tcodes, num_args = _make_tvm_args(args, temp_args)
File "/home/tw/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 163, in _make_tvm_args
values[i].v_str = c_str(arg)
File "/home/tw/tvm/python/tvm/_ffi/base.py", line 88, in c_str
return ctypes.c_char_p(string.encode("utf-8"))
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 0-1: surrogates not allowed
Sorry,I still cannot solve this problem

It seems it has something to do with the actual string you're sending on the command line. It is not strictly a bug in tvmc at this point. Can you please file an issue so that we can investigate that?

@OneIsAll-w
Copy link

Thanks a lot @leandron
but I still have some problems in compiling the resnet-50-v2.7.onnx model using the command :
python -m tvm.driver.tvmc compile --target "llvm" --output compiled_module.tar resnet50-v2-7.onnx
and I’m running into an error:
WARNING:root:Attribute momentum is ignored in relay.sym.batch_norm
WARNING:root:Attribute spatial is ignored in relay.sym.batch_norm
Traceback (most recent call last):
File "/home/tw/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/home/tw/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/tw/tvm/python/tvm/driver/tvmc/main.py", line 24, in
tvmc.main.main()
File "/home/tw/tvm/python/tvm/driver/tvmc/main.py", line 92, in main
sys.exit(_main(sys.argv[1:]))
File "/home/tw/tvm/python/tvm/driver/tvmc/main.py", line 85, in _main
return args.func(args)
File "/home/tw/tvm/python/tvm/driver/tvmc/compiler.py", line 114, in drive_compile
args.desired_layout,
File "/home/tw/tvm/python/tvm/driver/tvmc/compiler.py", line 189, in compile_model
tvm_target = tvm.target.Target(target)
File "/home/tw/tvm/python/tvm/target/target.py", line 92, in init
self.init_handle_by_constructor(_ffi_api.Target, tag_or_str_or_dict)
File "/home/tw/tvm/python/tvm/_ffi/_ctypes/object.py", line 131, in init_handle_by_constructor
handle = init_by_constructor(fconstructor, args)
File "/home/tw/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 246, in init_handle_by_constructor
values, tcodes, num_args = _make_tvm_args(args, temp_args)
File "/home/tw/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 163, in _make_tvm_args
values[i].v_str = c_str(arg)
File "/home/tw/tvm/python/tvm/_ffi/base.py", line 88, in c_str
return ctypes.c_char_p(string.encode("utf-8"))
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 0-1: surrogates not allowed
Sorry,I still cannot solve this problem

It seems it has something to do with the actual string you're sending on the command line. It is not strictly a bug in tvmc at this point. Can you please file an issue so that we can investigate that?

I didn't change anything, I still used the command:
python -m tvm.driver.tvmc compile --target "llvm" --output compiled_module.tar resnet50-v2-7.onnx

@comaniac
Copy link
Contributor

@OneIsAll-w please do not use the closed PR for bug reporting and discussion. It would be better to create a post in https://discuss.tvm.apache.org/ and point to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants