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

IInt8EntropyCalibrator2 is difficult to use #902

Closed
lpaatero opened this issue Jun 30, 2020 · 5 comments
Closed

IInt8EntropyCalibrator2 is difficult to use #902

lpaatero opened this issue Jun 30, 2020 · 5 comments

Comments

@lpaatero
Copy link

lpaatero commented Jun 30, 2020

Tensorrt offers class IInt8EntropyCalibrator2 for providing scale calibration data (batches) for model conversion to 8-bit.
This class has 4 pure virtual methods getBatchSize, getBatch, readCalibrationCache and writeCalibrationCache; Purpose of class is to allow custom implementation of these methods.

In order to be useful, class org.bytedeco.tensorrt.nvinfer.IInt8EntropyCalibrator2 should be possible to extend and implement above methods in Java.
To me it seems doing this is quite difficult. The constructor public IInt8EntropyCalibrator2(Pointer p) expects native object, so extending still requires use of javacpp (not just pure java).

Would it be possible to have org.bytedeco.tensorrt.nvinfer.IInt8EntropyCalibrator2 in such way that it has contructor public IInt8EntropyCalibrator2() and abstract java methods getBatchSize and getBatch; and native code would route any c++ calls to these methods into Java?

@lpaatero lpaatero changed the title IInt8EntropyCalibrator2 is d IInt8EntropyCalibrator2 is difficult to use Jun 30, 2020
@saudet
Copy link
Member

saudet commented Jun 30, 2020

That would happen if it were "virtualized", but it's currently not tagged that way. While we're at it, could you give me a list of classes that are meant to be subclassed by users this way? Thanks!

@lpaatero
Copy link
Author

lpaatero commented Jul 1, 2020

Good question, there seems to be quite many of those. Reading the .h file, I think below is quite complete set of classes that application is likely to subclass.

IInt8Calibrator related classes:
IInt8EntropyCalibrator IInt8EntropyCalibrator2 IInt8MinMaxCalibrator IInt8LegacyCalibrator

In case someone wants to implement pure java custom layer:
IPluginLayer IPluginV2Layer
IPluginV2 IPluginV2Ext IPluginV2IOExt
IPluginCreator

and some classes I have not yet used, but seems relevant:
IOutputDimensionsFormula IAlgorithmIOInfo IAlgorithmVariant IAlgorithmContext IAlgorithm IAlgorithmSelector
IGpuAllocator

saudet added a commit that referenced this issue Jul 2, 2020
@saudet
Copy link
Member

saudet commented Jul 2, 2020

IInt8Calibrator related classes:
IInt8EntropyCalibrator IInt8EntropyCalibrator2 IInt8MinMaxCalibrator IInt8LegacyCalibrator

Ok, I've added those to the last commit. Please try it with the snapshots after the builds are done in a day or two:
http://bytedeco.org/builds/

In case someone wants to implement pure java custom layer:
IPluginLayer IPluginV2Layer
IPluginV2 IPluginV2Ext IPluginV2IOExt
IPluginCreator

and some classes I have not yet used, but seems relevant:
IOutputDimensionsFormula IAlgorithmIOInfo IAlgorithmVariant IAlgorithmContext IAlgorithm IAlgorithmSelector
IGpuAllocator

Everything from that list, expect maybe IPluginCreator, seems to be either deprecated or mentions the following in comment:

//! \warning Do not inherit from this class, as doing so will break forward-compatibility of the API and ABI.

It looks like the only other classes that should be implemented are things related to plugins like IPlugin. I'm not sure if it makes sense to implement plugins in Java...? Let's come back to that later if it turns out to be useful for something...

@lpaatero
Copy link
Author

lpaatero commented Jul 2, 2020

Oops, the overriding warning was not in the h files.

Non-deprecated classes for custom plugin are then only IPluginV2Ext, IPluginV2IOExt and IPluginCreator.
Other non-deprecated are IAlgorithmSelector and IGpuAllocator.

@saudet
Copy link
Member

saudet commented Sep 10, 2020

Changes released with version 1.5.4. Thanks for reporting and please let me know if you need anything else fixed!

@saudet saudet closed this as completed Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants