From 5f7d39337c4b43a37e31c8a62f3a79aec50fcfda Mon Sep 17 00:00:00 2001 From: Samuel Audet Date: Sat, 1 Aug 2015 20:03:15 +0900 Subject: [PATCH] * Let users choose the runtime type of `layer_by_name()` from `FloatNet` or `DoubleNet` in `caffe` (issue bytedeco/javacpp#25) --- CHANGELOG.md | 1 + caffe/src/main/java/org/bytedeco/javacpp/caffe.java | 12 ++++++++---- .../java/org/bytedeco/javacpp/presets/caffe.java | 13 ++++++++++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6f4a2cf0fa..18a4ffa9fbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ + * Let users choose the runtime type of `layer_by_name()` from `FloatNet` or `DoubleNet` in `caffe` ([issue bytedeco/javacpp#25](https://github.com/bytedeco/javacpp/issues/25)) * Add presets for the `face` and `xfeatures2d` modules of OpenCV 3.0 ([issue #54](https://github.com/bytedeco/javacpp-presets/issues/54)) * Switch to GCC 4.9 by default on Android, probably dropping support for Android 2.2, because GCC 4.6 has issues with OpenMP ([issue bytedeco/javacv#179](https://github.com/bytedeco/javacv/issues/179)) * Resolve missing dependency for GSL on `windows-x86` by linking statically whatever it needs from `libgcc_s_dw2-1.dll` diff --git a/caffe/src/main/java/org/bytedeco/javacpp/caffe.java b/caffe/src/main/java/org/bytedeco/javacpp/caffe.java index a55e20c44fc..bfee9bcc4ae 100644 --- a/caffe/src/main/java/org/bytedeco/javacpp/caffe.java +++ b/caffe/src/main/java/org/bytedeco/javacpp/caffe.java @@ -16124,8 +16124,10 @@ public FloatNet() { } public native @Const @SharedPtr @ByVal FloatBlob blob_by_name(@StdString String blob_name); public native @Cast("bool") boolean has_layer(@StdString BytePointer layer_name); public native @Cast("bool") boolean has_layer(@StdString String layer_name); - public native @Const @Cast({"", "boost::shared_ptr >"}) @SharedPtr @ByVal FloatLayer layer_by_name(@StdString BytePointer layer_name); - public native @Const @Cast({"", "boost::shared_ptr >"}) @SharedPtr @ByVal FloatLayer layer_by_name(@StdString String layer_name); + public FloatLayer layer_by_name(BytePointer layer_name) { return layer_by_name(FloatLayer.class, layer_name); } + public FloatLayer layer_by_name(String layer_name) { return layer_by_name(FloatLayer.class, layer_name); }; + public native @Const @Cast({"", "boost::shared_ptr >"}) @SharedPtr @ByVal L layer_by_name(Class cls, @StdString BytePointer layer_name); + public native @Const @Cast({"", "boost::shared_ptr >"}) @SharedPtr @ByVal L layer_by_name(Class cls, @StdString String layer_name); public native void set_debug_info(@Cast("const bool") boolean value); @@ -16287,8 +16289,10 @@ public DoubleNet() { } public native @Const @SharedPtr @ByVal DoubleBlob blob_by_name(@StdString String blob_name); public native @Cast("bool") boolean has_layer(@StdString BytePointer layer_name); public native @Cast("bool") boolean has_layer(@StdString String layer_name); - public native @Const @Cast({"", "boost::shared_ptr >"}) @SharedPtr @ByVal DoubleLayer layer_by_name(@StdString BytePointer layer_name); - public native @Const @Cast({"", "boost::shared_ptr >"}) @SharedPtr @ByVal DoubleLayer layer_by_name(@StdString String layer_name); + public DoubleLayer layer_by_name(BytePointer layer_name) { return layer_by_name(DoubleLayer.class, layer_name); } + public DoubleLayer layer_by_name(String layer_name) { return layer_by_name(DoubleLayer.class, layer_name); }; + public native @Const @Cast({"", "boost::shared_ptr >"}) @SharedPtr @ByVal L layer_by_name(Class cls, @StdString BytePointer layer_name); + public native @Const @Cast({"", "boost::shared_ptr >"}) @SharedPtr @ByVal L layer_by_name(Class cls, @StdString String layer_name); public native void set_debug_info(@Cast("const bool") boolean value); diff --git a/caffe/src/main/java/org/bytedeco/javacpp/presets/caffe.java b/caffe/src/main/java/org/bytedeco/javacpp/presets/caffe.java index 897b608fdf7..3a0ac894775 100644 --- a/caffe/src/main/java/org/bytedeco/javacpp/presets/caffe.java +++ b/caffe/src/main/java/org/bytedeco/javacpp/presets/caffe.java @@ -122,6 +122,17 @@ public void map(InfoMap infoMap) { .put(new Info("std::vector").pointerTypes("BoolVector").define()) .put(new Info("std::vector >").pointerTypes("BoolVectorVector").define()) - .put(new Info("std::map").pointerTypes("StringIntMap").define()); + .put(new Info("std::map").pointerTypes("StringIntMap").define()) + + .put(new Info("caffe::Net::layer_by_name").javaText( + "public FloatLayer layer_by_name(BytePointer layer_name) { return layer_by_name(FloatLayer.class, layer_name); }\n" + + "public FloatLayer layer_by_name(String layer_name) { return layer_by_name(FloatLayer.class, layer_name); };\n" + + "public native @Const @Cast({\"\", \"boost::shared_ptr >\"}) @SharedPtr @ByVal L layer_by_name(Class cls, @StdString BytePointer layer_name);\n" + + "public native @Const @Cast({\"\", \"boost::shared_ptr >\"}) @SharedPtr @ByVal L layer_by_name(Class cls, @StdString String layer_name);\n")) + .put(new Info("caffe::Net::layer_by_name").javaText( + "public DoubleLayer layer_by_name(BytePointer layer_name) { return layer_by_name(DoubleLayer.class, layer_name); }\n" + + "public DoubleLayer layer_by_name(String layer_name) { return layer_by_name(DoubleLayer.class, layer_name); };\n" + + "public native @Const @Cast({\"\", \"boost::shared_ptr >\"}) @SharedPtr @ByVal L layer_by_name(Class cls, @StdString BytePointer layer_name);\n" + + "public native @Const @Cast({\"\", \"boost::shared_ptr >\"}) @SharedPtr @ByVal L layer_by_name(Class cls, @StdString String layer_name);\n")); } }