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

Deprecate the C++ vision::models namespace #4375

Merged
merged 6 commits into from
Sep 10, 2021

Conversation

datumbox
Copy link
Contributor

@datumbox datumbox commented Sep 6, 2021

We should consider dropping the C++ vision::models namespace for the following reasons:

  1. They are not currently being maintained.
  2. They represent an old attempt to support Vision models in C++. This was superseded by JIT. All of the models we propose to remove are fully jit-traceable and jit-scriptable.
  3. Several of the new classification models are missing (MobileNetV3, EfficientNets etc). Segmentation and Detection models are not implemented.

This PR deprecates the entire namespace by adding warnings. It also updates the code examples to show how to integrate models using JIT.

@datumbox datumbox requested a review from fmassa September 6, 2021 20:20
@datumbox datumbox force-pushed the deprecate_vision_models branch 2 times, most recently from 73154eb to f5a8c54 Compare September 6, 2021 20:45
@datumbox datumbox force-pushed the deprecate_vision_models branch from f5a8c54 to f6c9a95 Compare September 6, 2021 20:51
@datumbox datumbox changed the title Add deprecation warnings on vision::models Deprecate the C++ vision::models namespace Sep 6, 2021
Copy link
Member

@NicolasHug NicolasHug 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 PR @datumbox , I have a few remarks / questions

They are not currently being maintained.

Somewhat related is #3992. It shouldn't take too much effort to put it back on track but it might not be needed after all

They represent an old attempt to support Vision models in C++. This was superseded by JIT. All of the models we propose to remove are fully jit-traceable and jit-scriptable.

It seems however that relying on jit for this involves a slightly more cumbersome workflow: namely, one has to first export a model from Python so that it can then be used in C++. This means that you can the exported models also needs to be shipped as part of the binaries I guess. What do we think about this?

Also, is there a similar effort on the pytorch side? Quoting @fmassa 's #3992 (comment)

it would be good to know who is the current maintainer of the C++ API of PyTorch

Finally, with torchscript being currently unbundled to different other packages, will there be a different alternative for this in the future? (say torch::deploy or something else)

examples/cpp/hello_world/main.cpp Show resolved Hide resolved
@datumbox
Copy link
Contributor Author

datumbox commented Sep 7, 2021

@NicolasHug Thanks for the comments.

Unfortunately, maintaining the namespace requires significant more effort than one would think. The reason, most of the newer models are missing is because they rely on operators that are only available in Python. Moreover offering a C++ API for only the old classification models makes very little sense (segmentation and detection models are all missing). Please note that this initiative is coordinated with Francisco and discussed with Greg and Brian. If you have more concerns about this, let's chat offline.

@NicolasHug
Copy link
Member

Thanks @datumbox ,

I would still be interested in having my questions above answered. Perhaps there is a document that I could read?
If I were a user relying on the current C++ API, I think these questions would be relevant to me, so maybe there's value in having them publicly as well?

@datumbox
Copy link
Contributor Author

datumbox commented Sep 7, 2021

@NicolasHug Sounds good. We can gather references related. to the above and you are welcome to lead the efforts to make them presentable publicly so that the community can benefit.

@NicolasHug
Copy link
Member

Thanks for the proposal @datumbox but since I'm not involved in this work, I don't think it should be up to me

@fmassa
Copy link
Member

fmassa commented Sep 10, 2021

Hi,

To address some points brought up by @NicolasHug comments:

They represent an old attempt to support Vision models in C++. This was superseded by JIT. All of the models we propose to remove are fully jit-traceable and jit-scriptable.

The torchscript and C++ APIs are two different ways of getting your model into C++, and they target different users.
There are use-cases where having your full training / evaluation script in C++ is preferable (i.e., in very low-latency cases for RL), so the C++ API might be a better fit in there (and this is why we added the C++ models to begin with).

This means that you can the exported models also needs to be shipped as part of the binaries I guess. What do we think about this?

I believe this is fine and what is done by the rest of the community. If you imagine that you have your binary that runs your application, and that this binary takes a serialized model as an argument, then shipping this extra file is very reasonable (and we don't need to recompile the app if we switch models).

Finally, with torchscript being currently unbundled to different other packages, will there be a different alternative for this in the future? (say torch::deploy or something else)

Yes, I would expect that we will have a 3rd option to enable models to run in C++, which is similar to the torchscript solution but running entirely with Python.

Copy link
Member

@fmassa fmassa 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 PR @datumbox !

After discussing with Vasilis, we decided to change the message to indicate that we are not actively maintaining the C++ models, but we will keep them around.

@NicolasHug
Copy link
Member

NicolasHug commented Sep 10, 2021

Thank you for addressing my questions @fmassa

@datumbox datumbox merged commit c359d8d into pytorch:main Sep 10, 2021
@datumbox datumbox deleted the deprecate_vision_models branch September 10, 2021 15:27
facebook-github-bot pushed a commit that referenced this pull request Sep 13, 2021
Summary:
* Add deprecation warnings on vision::models

* Change the C++ example.

* Chage readme.

* Update deprecation warning.

Reviewed By: kazhang

Differential Revision: D30898331

fbshipit-source-id: 64edd30d726469111dd33821b4d0befc25c9b4dd
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