Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

wiki about how to port c++ code to Java

30 views
Skip to first unread message

Jack He CN

unread,
Sep 28, 2021, 5:41:10 AM9/28/21
to javacpp
Do we have any guide about porting C++ samples to JAVA, like the one about adding new presets: https://github.com/bytedeco/javacpp/wiki/Mapping-Recipes?

Samuel Audet

unread,
Sep 28, 2021, 6:52:27 AM9/28/21
to javacpp
That's meant to be pretty straightforward. The API docs should be enough to get you started, but let me know if you have any specific questions!

On Tue, Sep 28, 2021, 18:41 'Jack He CN' via javacpp <javacpp...@googlegroups.com> wrote:
Do we have any guide about porting C++ samples to JAVA, like the one about adding new presets: https://github.com/bytedeco/javacpp/wiki/Mapping-Recipes?

--
You received this message because you are subscribed to the Google Groups "javacpp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javacpp-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/javacpp-project/a3d9c2b9-a8cf-4411-a572-494f36d0ded8n%40googlegroups.com.

Jack He CN

unread,
Sep 28, 2021, 8:29:01 AM9/28/21
to javacpp
OK, seems you mean this: http://bytedeco.org/javacpp/apidocs/. Yes, will you let you know if any specific questions there.

Samuel Audet

unread,
Sep 28, 2021, 8:55:17 AM9/28/21
to javacpp
Yes, but the one, for example, for TensorRT is here: http://bytedeco.org/javacpp-presets/tensorrt/apidocs/

There are generated at build time on `mvn install` and listed on the main page for convenience: http://bytedeco.org/

Jack He CN

unread,
Sep 28, 2021, 10:26:53 AM9/28/21
to javacpp
how to do with shared_ptr in C++, such as:

std::shared_ptr<TRITONSERVER_Server> server(
      server_ptr, TRITONSERVER_ServerDelete);

Any typical example in javacpp samples?

Samuel Audet

unread,
Sep 28, 2021, 7:57:15 PM9/28/21
to javacpp...@googlegroups.com
This sort of "container" is typically managed by the Pointer class
itself, so we don't usually need to do anything special. For example,
torch::nn::Module::register_module() returns a new instance of
std::shared_ptr:
http://bytedeco.org/javacpp-presets/pytorch/apidocs/org/bytedeco/pytorch/Module.html#register_module-org.bytedeco.javacpp.BytePointer-org.bytedeco.pytorch.Module-

However, we don't need to do anything complicated from Java, we just
need to keep the instance around:
https://github.com/bytedeco/javacpp-presets/blob/master/pytorch/samples/SimpleMNIST.java#L14
Reply all
Reply to author
Forward
0 new messages