Skip to content

Commit

Permalink
Adaptations to bytedeco/javacpp#733
Browse files Browse the repository at this point in the history
  • Loading branch information
HGuillemet committed Jan 9, 2024
1 parent 291033f commit 77e27ac
Show file tree
Hide file tree
Showing 16 changed files with 266 additions and 296 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class BooleanElementReference extends Pointer {

public native @Const @ByRef IValue get();

private static native @Namespace @Name("swap") void swap(@ByRef(true) BooleanElementReference lhs, @ByRef(true) BooleanElementReference rhs);
private static native @Namespace void swap(@ByRef(true) BooleanElementReference lhs, @ByRef(true) BooleanElementReference rhs);
public void swap(BooleanElementReference rhs) { swap(this, rhs); }


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class DoubleComplexElementReference extends Pointer {

public native @Const @ByRef IValue get();

private static native @Namespace @Name("swap") void swap(@ByRef(true) DoubleComplexElementReference lhs, @ByRef(true) DoubleComplexElementReference rhs);
private static native @Namespace void swap(@ByRef(true) DoubleComplexElementReference lhs, @ByRef(true) DoubleComplexElementReference rhs);
public void swap(DoubleComplexElementReference rhs) { swap(this, rhs); }


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class DoubleElementReference extends Pointer {

public native @Const @ByRef IValue get();

private static native @Namespace @Name("swap") void swap(@ByRef(true) DoubleElementReference lhs, @ByRef(true) DoubleElementReference rhs);
private static native @Namespace void swap(@ByRef(true) DoubleElementReference lhs, @ByRef(true) DoubleElementReference rhs);
public void swap(DoubleElementReference rhs) { swap(this, rhs); }


Expand Down
21 changes: 3 additions & 18 deletions pytorch/src/gen/java/org/bytedeco/pytorch/ExampleStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,10 @@
import static org.bytedeco.pytorch.global.torch.*;


/** A {@code Collation} for {@code Example<Tensor, Tensor>} types that stacks all data
* tensors into one tensor, and all target (label) tensors into one tensor. */
@Name("torch::data::transforms::Stack<torch::data::Example<> >") @Properties(inherit = org.bytedeco.pytorch.presets.torch.class)
@Name("torch::data::transforms::Stack<torch::data::Example<torch::Tensor,torch::Tensor> >") @Opaque @Properties(inherit = org.bytedeco.pytorch.presets.torch.class)
public class ExampleStack extends ExampleCollation {
static { Loader.load(); }
/** Default native constructor. */
public ExampleStack() { super((Pointer)null); allocate(); }
/** Native array allocator. Access with {@link Pointer#position(long)}. */
public ExampleStack(long size) { super((Pointer)null); allocateArray(size); }
/** Empty constructor. Calls {@code super((Pointer)null)}. */
public ExampleStack() { super((Pointer)null); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public ExampleStack(Pointer p) { super(p); }
private native void allocate();
private native void allocateArray(long size);
@Override public ExampleStack position(long position) {
return (ExampleStack)super.position(position);
}
@Override public ExampleStack getPointer(long i) {
return new ExampleStack((Pointer)this).offsetAddress(i);
}

public native @ByVal Example apply_batch(@StdVector Example examples);
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class FuturePtrElementReference extends Pointer {

public native @Const @ByRef IValue get();

private static native @Namespace @Name("swap") void swap(@ByRef(true) FuturePtrElementReference lhs, @ByRef(true) FuturePtrElementReference rhs);
private static native @Namespace void swap(@ByRef(true) FuturePtrElementReference lhs, @ByRef(true) FuturePtrElementReference rhs);
public void swap(FuturePtrElementReference rhs) { swap(this, rhs); }


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class GenericElementReference extends Pointer {

public native @Const @ByRef IValue get();

private static native @Namespace @Name("swap") void swap(@ByRef(true) GenericElementReference lhs, @ByRef(true) GenericElementReference rhs);
private static native @Namespace void swap(@ByRef(true) GenericElementReference lhs, @ByRef(true) GenericElementReference rhs);
public void swap(GenericElementReference rhs) { swap(this, rhs); }


Expand Down
54 changes: 42 additions & 12 deletions pytorch/src/gen/java/org/bytedeco/pytorch/HalfComplex.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import static org.bytedeco.pytorch.global.torch.*;


// TODO : move to complex.h
@Name("c10::complex<c10::Half>") @NoOffset @Properties(inherit = org.bytedeco.pytorch.presets.torch.class)
public class HalfComplex extends Pointer {
static { Loader.load(); }
Expand All @@ -34,28 +33,59 @@ public class HalfComplex extends Pointer {
return new HalfComplex((Pointer)this).offsetAddress(i);
}


public native @ByRef Half real_(); public native HalfComplex real_(Half setter);
public native @ByRef Half imag_(); public native HalfComplex imag_(Half setter);

// Constructors
public HalfComplex() { super((Pointer)null); allocate(); }
private native void allocate();
// Half constructor is not constexpr so the following constructor can't
// be constexpr
public HalfComplex(@Const @ByRef Half real, @Const @ByRef Half imag) { super((Pointer)null); allocate(real, imag); }
private native void allocate(@Const @ByRef Half real, @Const @ByRef Half imag);
public HalfComplex(Half re, Half im) { super((Pointer)null); allocate(re, im); }
private native void allocate(@Const @ByRef Half re, @Const @ByRef(nullValue = "c10::Half()") Half im);
public HalfComplex(@Const @ByRef FloatComplex value) { super((Pointer)null); allocate(value); }
private native void allocate(@Const @ByRef FloatComplex value);

// Conversion operator
public native @ByVal @Name("operator c10::complex<float>") FloatComplex asFloatComplex();

public native @ByRef @Name("operator +=") HalfComplex addPut(@Const @ByRef HalfComplex other);

public native @ByRef @Name("operator -=") HalfComplex subtractPut(@Const @ByRef HalfComplex other);

public native @ByRef @Name("operator *=") HalfComplex multiplyPut(@Const @ByRef HalfComplex other);
// #if defined(__CUDACC__) || defined(__HIPCC__)
// #endif

public native @Const @ByVal @org.bytedeco.javacpp.annotation.Function Half real();
public native @Const @ByVal @org.bytedeco.javacpp.annotation.Function Half imag();
// Use SFINAE to specialize casting constructor for c10::complex<float> and
// c10::complex<double>

public native @ByRef @Name("operator +=") HalfComplex addPut(@Const @ByRef HalfComplex other);


public native @ByRef @Name("operator -=") HalfComplex subtractPut(@Const @ByRef HalfComplex other);


public native @ByRef @Name("operator *=") HalfComplex multiplyPut(@Const @ByRef HalfComplex other);






// #ifdef __APPLE__
// #define FORCE_INLINE_APPLE __attribute__((always_inline))
// #else
// #define FORCE_INLINE_APPLE
// #endif
// #undef FORCE_INLINE_APPLE

// #if defined(__CUDACC__) || defined(__HIPCC__)
// #endif

// #if defined(__CUDACC__) || defined(__HIPCC__)
// #endif

// consistent with NumPy behavior


public native @Const @ByVal @org.bytedeco.javacpp.annotation.Function Half real();

public native @Const @ByVal @org.bytedeco.javacpp.annotation.Function Half imag();

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class LongElementReference extends Pointer {

public native @Const @ByRef IValue get();

private static native @Namespace @Name("swap") void swap(@ByRef(true) LongElementReference lhs, @ByRef(true) LongElementReference rhs);
private static native @Namespace void swap(@ByRef(true) LongElementReference lhs, @ByRef(true) LongElementReference rhs);
public void swap(LongElementReference rhs) { swap(this, rhs); }


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class TensorElementReference extends Pointer {

public native @Const @ByRef IValue get();

private static native @Namespace @Name("swap") void swap(@ByRef(true) TensorElementReference lhs, @ByRef(true) TensorElementReference rhs);
private static native @Namespace void swap(@ByRef(true) TensorElementReference lhs, @ByRef(true) TensorElementReference rhs);
public void swap(TensorElementReference rhs) { swap(this, rhs); }


Expand Down
21 changes: 3 additions & 18 deletions pytorch/src/gen/java/org/bytedeco/pytorch/TensorExampleStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,10 @@
import static org.bytedeco.pytorch.global.torch.*;


/** A {@code Collation} for {@code Example<Tensor, NoTarget>} types that stacks all data
* tensors into one tensor. */
@Name("torch::data::transforms::Stack<torch::data::TensorExample>") @Properties(inherit = org.bytedeco.pytorch.presets.torch.class)
@Name("torch::data::transforms::Stack<torch::data::Example<torch::Tensor,torch::data::example::NoTarget> >") @Opaque @Properties(inherit = org.bytedeco.pytorch.presets.torch.class)
public class TensorExampleStack extends TensorExampleCollation {
static { Loader.load(); }
/** Default native constructor. */
public TensorExampleStack() { super((Pointer)null); allocate(); }
/** Native array allocator. Access with {@link Pointer#position(long)}. */
public TensorExampleStack(long size) { super((Pointer)null); allocateArray(size); }
/** Empty constructor. Calls {@code super((Pointer)null)}. */
public TensorExampleStack() { super((Pointer)null); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public TensorExampleStack(Pointer p) { super(p); }
private native void allocate();
private native void allocateArray(long size);
@Override public TensorExampleStack position(long position) {
return (TensorExampleStack)super.position(position);
}
@Override public TensorExampleStack getPointer(long i) {
return new TensorExampleStack((Pointer)this).offsetAddress(i);
}

public native @ByVal @Cast("torch::data::TensorExample*") Example apply_batch(@Cast("torch::data::TensorExample*") @StdVector Example examples);
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class TensorOptionalElementReference extends Pointer {

public native @Const @ByRef IValue get();

private static native @Namespace @Name("swap") void swap(@ByRef(true) TensorOptionalElementReference lhs, @ByRef(true) TensorOptionalElementReference rhs);
private static native @Namespace void swap(@ByRef(true) TensorOptionalElementReference lhs, @ByRef(true) TensorOptionalElementReference rhs);
public void swap(TensorOptionalElementReference rhs) { swap(this, rhs); }


Expand Down
26 changes: 0 additions & 26 deletions pytorch/src/gen/java/org/bytedeco/pytorch/class_.java

This file was deleted.

Loading

0 comments on commit 77e27ac

Please sign in to comment.