From 0fbf4034e8c5c522e8370c3681fe4051b44da24a Mon Sep 17 00:00:00 2001 From: Samuel Audet Date: Sat, 11 Nov 2023 22:38:59 +0900 Subject: [PATCH] Fix builds for TVM on Windows --- .../org/bytedeco/tvm/WrappedPythonObject.java | 70 ------------------- .../org/bytedeco/tvm/global/tvm_runtime.java | 10 ++- .../org/bytedeco/tvm/presets/tvm_runtime.java | 4 +- 3 files changed, 10 insertions(+), 74 deletions(-) delete mode 100644 tvm/src/gen/java/org/bytedeco/tvm/WrappedPythonObject.java diff --git a/tvm/src/gen/java/org/bytedeco/tvm/WrappedPythonObject.java b/tvm/src/gen/java/org/bytedeco/tvm/WrappedPythonObject.java deleted file mode 100644 index 967e1281022..00000000000 --- a/tvm/src/gen/java/org/bytedeco/tvm/WrappedPythonObject.java +++ /dev/null @@ -1,70 +0,0 @@ -// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE - -package org.bytedeco.tvm; - -import org.bytedeco.tvm.Module; -import java.nio.*; -import org.bytedeco.javacpp.*; -import org.bytedeco.javacpp.annotation.*; - -import static org.bytedeco.javacpp.presets.javacpp.*; -import org.bytedeco.opencl.*; -import static org.bytedeco.opencl.global.OpenCL.*; -import org.bytedeco.dnnl.*; -import static org.bytedeco.dnnl.global.dnnl.*; -import org.bytedeco.llvm.LLVM.*; -import static org.bytedeco.llvm.global.LLVM.*; -import static org.bytedeco.mkl.global.mkl_rt.*; - -import static org.bytedeco.tvm.global.tvm_runtime.*; - - -/** \brief A class that wraps a Python object and preserves its ownership. -

- * This class is used to wrap a PyObject* from the Python API and preserve its ownership. - * Allows for the creation of strong references to Python objects, which prevent them from being - * garbage-collected as long as the wrapper object exists. - */ -@Namespace("tvm::runtime") @NoOffset @Properties(inherit = org.bytedeco.tvm.presets.tvm_runtime.class) -public class WrappedPythonObject extends Pointer { - static { Loader.load(); } - /** Native array allocator. Access with {@link Pointer#position(long)}. */ - public WrappedPythonObject(long size) { super((Pointer)null); allocateArray(size); } - private native void allocateArray(long size); - @Override public WrappedPythonObject position(long position) { - return (WrappedPythonObject)super.position(position); - } - @Override public WrappedPythonObject getPointer(long i) { - return new WrappedPythonObject((Pointer)this).offsetAddress(i); - } - - /** \brief Construct a wrapper that doesn't own anything */ - public WrappedPythonObject() { super((Pointer)null); allocate(); } - private native void allocate(); - - /** \brief Conversion constructor from nullptr */ - - /** \brief Take ownership of a python object - * - * A new strong reference is created for the underlying python - * object. - * - * @param python_obj A PyObject* from the Python.h API. A new - * strong reference is created using Py_IncRef. - */ - public WrappedPythonObject(Pointer python_obj) { super((Pointer)null); allocate(python_obj); } - private native void allocate(Pointer python_obj); - - /** \brief Drop ownership of a python object - * - * Removes the strong reference held by the wrapper. - */ - - public WrappedPythonObject(@ByRef(true) WrappedPythonObject arg0) { super((Pointer)null); allocate(arg0); } - private native void allocate(@ByRef(true) WrappedPythonObject arg0); - public native @ByRef @Name("operator =") WrappedPythonObject put(@ByRef(true) WrappedPythonObject arg0); - - public native @Cast("bool") @Name("operator bool") boolean asBoolean(); - - public native Pointer raw_pointer(); -} diff --git a/tvm/src/gen/java/org/bytedeco/tvm/global/tvm_runtime.java b/tvm/src/gen/java/org/bytedeco/tvm/global/tvm_runtime.java index 693334fce8f..26fa7ac6605 100644 --- a/tvm/src/gen/java/org/bytedeco/tvm/global/tvm_runtime.java +++ b/tvm/src/gen/java/org/bytedeco/tvm/global/tvm_runtime.java @@ -3003,7 +3003,7 @@ public static native int TVMObjectDerivedFrom(@Cast("uint32_t") int child_type_i */ @Namespace("tvm::runtime") public static native @Cast("const char*") BytePointer ArgTypeCode2Str(int type_code); -@Namespace("tvm::runtime") public static native @Cast("std::ostream*") @ByRef @Name("operator <<") Pointer shiftLeft(@Cast("std::ostream*") @ByRef Pointer os, @ByVal DLDevice dev); // NOLINT(*) + // NOLINT(*) // macro to check type code. // #define TVM_CHECK_TYPE_CODE(CODE, T) @@ -3341,9 +3341,13 @@ public static native int TVMObjectDerivedFrom(@Cast("uint32_t") int child_type_i * indicate an error happens, otherwise it returns normally. */ @Namespace("tvm::runtime") public static native void EnvCheckSignals(); -// Targeting ../WrappedPythonObject.java - +/** \brief A class that wraps a Python object and preserves its ownership. +

+ * This class is used to wrap a PyObject* from the Python API and preserve its ownership. + * Allows for the creation of strong references to Python objects, which prevent them from being + * garbage-collected as long as the wrapper object exists. + */ // Targeting ../Registry.java diff --git a/tvm/src/main/java/org/bytedeco/tvm/presets/tvm_runtime.java b/tvm/src/main/java/org/bytedeco/tvm/presets/tvm_runtime.java index 6e9067f84d9..eec329f6f42 100644 --- a/tvm/src/main/java/org/bytedeco/tvm/presets/tvm_runtime.java +++ b/tvm/src/main/java/org/bytedeco/tvm/presets/tvm_runtime.java @@ -166,7 +166,9 @@ public void map(InfoMap infoMap) { .put(new Info("tvm::runtime::ObjectPtr").pointerTypes("ObjectPtr")) .put(new Info("tvm::runtime::ObjAllocatorBase", "tvm::runtime::ObjAllocatorBase").pointerTypes("SimpleObjAllocatorBase")) - .put(new Info("tvm::runtime::ObjAllocatorBase::make_object").skip()) + .put(new Info("tvm::runtime::ObjAllocatorBase::make_object", + "tvm::runtime::WrappedPythonObject", + "tvm::runtime::operator <<(std::ostream&, DLDevice)").skip()) .put(new Info("tvm::runtime::ADTObj").pointerTypes("ADTObj")) .put(new Info("tvm::runtime::InplaceArrayBase",