Skip to content

Commit

Permalink
Fix presets for ONNX incorrectly mapping StringAttributeMap and Strin…
Browse files Browse the repository at this point in the history
…gPassMap (pull #686)
  • Loading branch information
EmergentOrder authored and saudet committed Feb 9, 2019
1 parent 6d294d2 commit 9b0b292
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
36 changes: 33 additions & 3 deletions onnx/src/main/java/org/bytedeco/javacpp/onnx.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,33 @@ public Iterator() { }
}
}

@Name("std::map<std::string,std::shared_ptr<onnx::optimization::Pass> >") public static class StringPassMap extends Pointer {
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public StringPassMap(Pointer p) { super(p); }
public StringPassMap() { allocate(); }
private native void allocate();
public native @Name("operator=") @ByRef StringPassMap put(@ByRef StringPassMap x);

public boolean empty() { return size() == 0; }
public native long size();

@Index public native @SharedPtr Pass get(@StdString BytePointer i);
public native StringPassMap put(@StdString BytePointer i, Pass value);

public native @ByVal Iterator begin();
public native @ByVal Iterator end();
@NoOffset @Name("iterator") public static class Iterator extends Pointer {
public Iterator(Pointer p) { super(p); }
public Iterator() { }

public native @Name("operator++") @ByRef Iterator increment();
public native @Name("operator==") boolean equals(@ByRef Iterator it);
public native @Name("operator*().first") @MemberGetter @StdString BytePointer first();
public native @Name("operator*().second") @MemberGetter @SharedPtr @Const Pass second();
}
}

@Name("std::set<int>") public static class IntSet extends Pointer {
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
Expand Down Expand Up @@ -1419,6 +1446,8 @@ private native void allocate(

public native @StdString BytePointer domain();

public native @Const @ByRef StringAttributeMap attributes();

// Get input formal parameters.
public native @Const @ByRef FormalParameterVector inputs();

Expand Down Expand Up @@ -13939,7 +13968,7 @@ public static class onnxReleaseGraphFunction extends FunctionPointer {
// #include <vector>

// Registry containing all passes available in ONNX.
@Namespace("onnx::optimization") public static class GlobalPassRegistry extends Pointer {
@Namespace("onnx::optimization") @NoOffset public static class GlobalPassRegistry extends Pointer {
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public GlobalPassRegistry(Pointer p) { super(p); }
Expand All @@ -13950,12 +13979,13 @@ public static class onnxReleaseGraphFunction extends FunctionPointer {
return (GlobalPassRegistry)super.position(position);
}

public native @ByRef StringPassMap passes(); public native GlobalPassRegistry passes(StringPassMap passes);

public GlobalPassRegistry() { super((Pointer)null); allocate(); }
private native void allocate();

public native @SharedPtr Pass find(@StdString BytePointer pass_name);
public native @SharedPtr Pass find(@StdString String pass_name);
public native @SharedPtr @ByVal Pass find(@StdString BytePointer pass_name);
public native @SharedPtr @ByVal Pass find(@StdString String pass_name);
public native @Const @ByVal StringVector GetAvailablePasses();
}
// namespace optimization
Expand Down
10 changes: 5 additions & 5 deletions onnx/src/main/java/org/bytedeco/javacpp/presets/onnx.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,21 @@ public void map(InfoMap infoMap) {
.put(new Info("std::vector<int64_t>").pointerTypes("LongVector").define())
.put(new Info("std::vector<std::string>").pointerTypes("StringVector").define())
.put(new Info("onnx::Dimension").pointerTypes("DimensionIR").define())
.put(new Info("std::initializer_list", "std::function<void(OpSchema&&)>", "generic_graph_node_list",
"generic_graph_node_list_iterator", "NodeKind", "graph_node_list",
"graph_node_list_iterator", "reverse_iterator", "std::vector<onnx::Tensor>::const_iterator",
.put(new Info("std::initializer_list", "std::function<void(OpSchema&&)>", "NodeKind", "graph_node_list",
"graph_node_list_iterator", "std::vector<onnx::Tensor>::const_iterator",
"onnx::Attributes<onnx::Node>", "Symbol", "std::reverse_iterator<onnx::ArrayRef<onnx::Node::Value*>::iterator>",
"const_graph_node_list_iterator", "const_graph_node_list", "onnx::toString", "onnx::ResourceGuard", "onnx::GraphInferencer",
"onnx::shape_inference::GraphInferenceContext", "onnx::optimization::FullGraphBasedPass",
"onnx::optimization::ImmutablePass", "PROTOBUF_INTERNAL_EXPORT_protobuf_onnx_2fonnx_2dml_2eproto",
"PROTOBUF_INTERNAL_EXPORT_protobuf_onnx_2fonnx_2doperators_2dml_2eproto", "google::protobuf::FindAllExtensions").skip())
.put(new Info("onnx::shape_inference::InferenceContextImpl").skip())
.put(new Info("std::set<int>").pointerTypes("IntSet").define())
.put(new Info("std::map<std::string,std::unique_ptr<onnx::optimization::OptimizePass> >", "std::unique_ptr<onnx::optimization::OptimizePass>").skip())
.put(new Info("onnx::optimization::Pass").purify(true))
.put(new Info("std::shared_ptr<onnx::optimization::Pass>").annotations("@SharedPtr").pointerTypes("Pass"))
.put(new Info("std::map<std::string,std::shared_ptr<onnx::optimization::Pass> >").pointerTypes("StringPassMap").define())
.put(new Info("std::unordered_set<std::string>").pointerTypes("UnorderedStringSet").define())
.put(new Info("std::multimap<std::string,const onnx::FunctionProto*>").skip())
.put(new Info("std::runtime_error").cast().pointerTypes("Pointer"))
.put(new Info("onnx::optimization::OptimizePass").purify())
.put(new Info("onnx::version_conversion::BaseVersionConverter::registerAdapter").skip())
// .put(new Info("onnx::Node::Value", "onnx::Graph::Value", "onnx::AttributeValue", "onnx::Value").skip())
.put(new Info("std::iterator_traits<onnx::generic_graph_node_list_iterator<T> >").skip())
Expand Down

0 comments on commit 9b0b292

Please sign in to comment.