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

[Relay][Frontend] Caffe2 Support #2507

Merged
merged 17 commits into from
Feb 2, 2019
Merged

Conversation

makihiro
Copy link
Contributor

@hlu1 @tqchen @zhreshold @kazum Please help to review.

@yzhliu
Copy link
Member

yzhliu commented Jan 27, 2019

Please satisfy the CI

from model_zoo import c2_squeezenet, c2_resnet50, c2_vgg19

  File "/workspace/tests/python/frontend/caffe2/model_zoo/__init__.py", line 19, in <module>

    locals()['c2_' + model] = importlib.import_module('caffe2.python.models.' + model)

  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module

    return _bootstrap._gcd_import(name[level:], package, level)

ModuleNotFoundError: No module named 'caffe2.python.models.squeezenet'

with relay.build_config(opt_level=3):
graph, lib, params = relay.build(func, target, params=params)

ctx = tvm.cpu(0)
Copy link
Member

Choose a reason for hiding this comment

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

can we use tvm.relay.testing.config.ctx_list to test it on all supported targets?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ctx comes from ctx_list and I'm going to remove ctx = tvm.cpu(0)

if __name__ == '__main__':
verify_squeezenet1_1()
verify_resnet50()
verify_vgg19()
Copy link
Contributor

Choose a reason for hiding this comment

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

Test methods should start with "test_" so that nosetests can execute them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the review. I fixed them.

@yzhliu yzhliu mentioned this pull request Jan 28, 2019
@yzhliu
Copy link
Member

yzhliu commented Jan 28, 2019

@makihiro could you act on the comments?

@makihiro
Copy link
Contributor Author

makihiro commented Jan 29, 2019

@makihiro could you act on the comments?

Thank you for the comments, and sorry for the late reply.
Module import error occurred due to no caffe2 models installed on CI environment.
The test code tries to download models and install into caffe2 path, however there is permission error for this operation.
The best solution is caffe2 models are pre-installed on CI environment because total model size is several hundreds of megabytes.
To fix this, I'm going to modify to download models into temporary directory (eg. /tmp) and load / or modify dockerfile to install models for CI container.

locals()['c2_' + model] = importlib.import_module('caffe2.python.models.' + model)
except ImportError:
try:
os.system("python3 -m caffe2.python.models.download -i -f " + model)
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't work with python2.

I think no need to write download code. You can use the caffe2 downloader module instead, which downloads models to "~/.caffe2" by default.

from caffe2.python.models.download import ModelDownloader
mf = ModelDownloader()
mf.get_c2_model(model)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the review. I fixed code to use ModelDownloader

if __name__ == '__main__':
test_verify_squeezenet1_1()
test_verify_resnet50()
test_verify_vgg19()
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace 'test_verify' with 'test_forward' to be consistent with other frontend tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I renamed functions in a manner similar to other frontend tests.

Copy link
Contributor

@kazum kazum left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@tqchen
Copy link
Member

tqchen commented Jan 31, 2019

@hlu1 can you also take a quick look?

@makihiro
Copy link
Contributor Author

makihiro commented Feb 1, 2019

I would like to add the tutorial. Please help to review.

Copy link
Member

@yzhliu yzhliu left a comment

Choose a reason for hiding this comment

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

good to me

@yzhliu yzhliu merged commit b3b3d28 into apache:master Feb 2, 2019
libing4752 pushed a commit to libing4752/tvm that referenced this pull request Feb 18, 2019
* [Relay][Frontend] Add Caffe2 Support

* [Relay][Frontend] Add Caffe2 Support (fix unsed import)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Relay][Frontend] Add Caffe2 Support (fix model install and reflect code reviews)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 frontend import)

* [Relay][Frontend] Add Caffe2 Support (rename function name in test_forward)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Doc] Caffe2 frontend tutorial

* [Doc] Caffe2 frontend tutorial

* [Doc] Caffe2 frontend tutorial

* [Relay][Frontend] Add Caffe2 Support (remove unsed file)
merrymercy pushed a commit to merrymercy/tvm that referenced this pull request Feb 18, 2019
* [Relay][Frontend] Add Caffe2 Support

* [Relay][Frontend] Add Caffe2 Support (fix unsed import)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Relay][Frontend] Add Caffe2 Support (fix model install and reflect code reviews)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 frontend import)

* [Relay][Frontend] Add Caffe2 Support (rename function name in test_forward)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Doc] Caffe2 frontend tutorial

* [Doc] Caffe2 frontend tutorial

* [Doc] Caffe2 frontend tutorial

* [Relay][Frontend] Add Caffe2 Support (remove unsed file)
wweic pushed a commit to neo-ai/tvm that referenced this pull request Feb 20, 2019
* [Relay][Frontend] Add Caffe2 Support

* [Relay][Frontend] Add Caffe2 Support (fix unsed import)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Relay][Frontend] Add Caffe2 Support (fix model install and reflect code reviews)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 frontend import)

* [Relay][Frontend] Add Caffe2 Support (rename function name in test_forward)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Doc] Caffe2 frontend tutorial

* [Doc] Caffe2 frontend tutorial

* [Doc] Caffe2 frontend tutorial

* [Relay][Frontend] Add Caffe2 Support (remove unsed file)
wweic pushed a commit to neo-ai/tvm that referenced this pull request Feb 20, 2019
* [Relay][Frontend] Add Caffe2 Support

* [Relay][Frontend] Add Caffe2 Support (fix unsed import)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Relay][Frontend] Add Caffe2 Support (fix model install and reflect code reviews)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 frontend import)

* [Relay][Frontend] Add Caffe2 Support (rename function name in test_forward)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Relay][Frontend] Add Caffe2 Support (fix caffe2 model import)

* [Doc] Caffe2 frontend tutorial

* [Doc] Caffe2 frontend tutorial

* [Doc] Caffe2 frontend tutorial

* [Relay][Frontend] Add Caffe2 Support (remove unsed file)
@yzhliu yzhliu mentioned this pull request Mar 2, 2019
28 tasks
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.

4 participants