diff --git a/pytorch/src/gen/java/org/bytedeco/pytorch/BooleanElementReference.java b/pytorch/src/gen/java/org/bytedeco/pytorch/BooleanElementReference.java index bb6a598c072..b88c2f26df7 100644 --- a/pytorch/src/gen/java/org/bytedeco/pytorch/BooleanElementReference.java +++ b/pytorch/src/gen/java/org/bytedeco/pytorch/BooleanElementReference.java @@ -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); } diff --git a/pytorch/src/gen/java/org/bytedeco/pytorch/DoubleComplexElementReference.java b/pytorch/src/gen/java/org/bytedeco/pytorch/DoubleComplexElementReference.java index 3b1ad7127e4..b2cff9eb382 100644 --- a/pytorch/src/gen/java/org/bytedeco/pytorch/DoubleComplexElementReference.java +++ b/pytorch/src/gen/java/org/bytedeco/pytorch/DoubleComplexElementReference.java @@ -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); } diff --git a/pytorch/src/gen/java/org/bytedeco/pytorch/DoubleElementReference.java b/pytorch/src/gen/java/org/bytedeco/pytorch/DoubleElementReference.java index c3f779ad666..65776d25482 100644 --- a/pytorch/src/gen/java/org/bytedeco/pytorch/DoubleElementReference.java +++ b/pytorch/src/gen/java/org/bytedeco/pytorch/DoubleElementReference.java @@ -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); } diff --git a/pytorch/src/gen/java/org/bytedeco/pytorch/ExampleStack.java b/pytorch/src/gen/java/org/bytedeco/pytorch/ExampleStack.java index 76b3468f69a..c349b470401 100644 --- a/pytorch/src/gen/java/org/bytedeco/pytorch/ExampleStack.java +++ b/pytorch/src/gen/java/org/bytedeco/pytorch/ExampleStack.java @@ -18,25 +18,10 @@ import static org.bytedeco.pytorch.global.torch.*; -/** A {@code Collation} for {@code Example} types that stacks all data - * tensors into one tensor, and all target (label) tensors into one tensor. */ -@Name("torch::data::transforms::Stack >") @Properties(inherit = org.bytedeco.pytorch.presets.torch.class) +@Name("torch::data::transforms::Stack >") @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); } diff --git a/pytorch/src/gen/java/org/bytedeco/pytorch/FuturePtrElementReference.java b/pytorch/src/gen/java/org/bytedeco/pytorch/FuturePtrElementReference.java index 3b43f647e23..73efb1e3e95 100644 --- a/pytorch/src/gen/java/org/bytedeco/pytorch/FuturePtrElementReference.java +++ b/pytorch/src/gen/java/org/bytedeco/pytorch/FuturePtrElementReference.java @@ -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); } diff --git a/pytorch/src/gen/java/org/bytedeco/pytorch/GenericElementReference.java b/pytorch/src/gen/java/org/bytedeco/pytorch/GenericElementReference.java index 2423290abad..d1c2b3f0ad4 100644 --- a/pytorch/src/gen/java/org/bytedeco/pytorch/GenericElementReference.java +++ b/pytorch/src/gen/java/org/bytedeco/pytorch/GenericElementReference.java @@ -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); } diff --git a/pytorch/src/gen/java/org/bytedeco/pytorch/HalfComplex.java b/pytorch/src/gen/java/org/bytedeco/pytorch/HalfComplex.java index b6b36add496..fdde6aeb652 100644 --- a/pytorch/src/gen/java/org/bytedeco/pytorch/HalfComplex.java +++ b/pytorch/src/gen/java/org/bytedeco/pytorch/HalfComplex.java @@ -18,7 +18,6 @@ import static org.bytedeco.pytorch.global.torch.*; -// TODO : move to complex.h @Name("c10::complex") @NoOffset @Properties(inherit = org.bytedeco.pytorch.presets.torch.class) public class HalfComplex extends Pointer { static { Loader.load(); } @@ -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") 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 and + // c10::complex - 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(); + } diff --git a/pytorch/src/gen/java/org/bytedeco/pytorch/LongElementReference.java b/pytorch/src/gen/java/org/bytedeco/pytorch/LongElementReference.java index 29d9edfce66..36d4873a234 100644 --- a/pytorch/src/gen/java/org/bytedeco/pytorch/LongElementReference.java +++ b/pytorch/src/gen/java/org/bytedeco/pytorch/LongElementReference.java @@ -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); } diff --git a/pytorch/src/gen/java/org/bytedeco/pytorch/TensorElementReference.java b/pytorch/src/gen/java/org/bytedeco/pytorch/TensorElementReference.java index e6df15406d8..8bda59f178a 100644 --- a/pytorch/src/gen/java/org/bytedeco/pytorch/TensorElementReference.java +++ b/pytorch/src/gen/java/org/bytedeco/pytorch/TensorElementReference.java @@ -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); } diff --git a/pytorch/src/gen/java/org/bytedeco/pytorch/TensorExampleStack.java b/pytorch/src/gen/java/org/bytedeco/pytorch/TensorExampleStack.java index c05d4c21576..a079551b6aa 100644 --- a/pytorch/src/gen/java/org/bytedeco/pytorch/TensorExampleStack.java +++ b/pytorch/src/gen/java/org/bytedeco/pytorch/TensorExampleStack.java @@ -18,25 +18,10 @@ import static org.bytedeco.pytorch.global.torch.*; -/** A {@code Collation} for {@code Example} types that stacks all data - * tensors into one tensor. */ -@Name("torch::data::transforms::Stack") @Properties(inherit = org.bytedeco.pytorch.presets.torch.class) +@Name("torch::data::transforms::Stack >") @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); } diff --git a/pytorch/src/gen/java/org/bytedeco/pytorch/TensorOptionalElementReference.java b/pytorch/src/gen/java/org/bytedeco/pytorch/TensorOptionalElementReference.java index b202bbe9bc9..7a847b2dda3 100644 --- a/pytorch/src/gen/java/org/bytedeco/pytorch/TensorOptionalElementReference.java +++ b/pytorch/src/gen/java/org/bytedeco/pytorch/TensorOptionalElementReference.java @@ -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); } diff --git a/pytorch/src/gen/java/org/bytedeco/pytorch/class_.java b/pytorch/src/gen/java/org/bytedeco/pytorch/class_.java deleted file mode 100644 index c70b60d5c01..00000000000 --- a/pytorch/src/gen/java/org/bytedeco/pytorch/class_.java +++ /dev/null @@ -1,26 +0,0 @@ -// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE - -package org.bytedeco.pytorch; - -import org.bytedeco.pytorch.Allocator; -import org.bytedeco.pytorch.Function; -import org.bytedeco.pytorch.functions.*; -import org.bytedeco.pytorch.Module; -import org.bytedeco.javacpp.annotation.Cast; -import java.nio.*; -import org.bytedeco.javacpp.*; -import org.bytedeco.javacpp.annotation.*; - -import static org.bytedeco.javacpp.presets.javacpp.*; -import static org.bytedeco.openblas.global.openblas_nolapack.*; -import static org.bytedeco.openblas.global.openblas.*; - -import static org.bytedeco.pytorch.global.torch.*; - -@Namespace("pybind11") @Opaque @Properties(inherit = org.bytedeco.pytorch.presets.torch.class) -public class class_ extends Pointer { - /** Empty constructor. Calls {@code super((Pointer)null)}. */ - public class_() { super((Pointer)null); } - /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ - public class_(Pointer p) { super(p); } -} diff --git a/pytorch/src/gen/java/org/bytedeco/pytorch/global/torch.java b/pytorch/src/gen/java/org/bytedeco/pytorch/global/torch.java index 2b1fd19f54f..9cbb7c23035 100644 --- a/pytorch/src/gen/java/org/bytedeco/pytorch/global/torch.java +++ b/pytorch/src/gen/java/org/bytedeco/pytorch/global/torch.java @@ -4488,136 +4488,107 @@ public class torch extends org.bytedeco.pytorch.presets.torch { // namespace std -// Parsed from c10/util/Half.h +// Parsed from c10/util/complex_utils.h + +// #if !defined(C10_INTERNAL_INCLUDE_COMPLEX_REMAINING_H) +// #error +// "c10/util/complex_utils.h is not meant to be individually included. Include c10/util/complex.h instead." +// #endif + +// #include + +// Extract double from std::complex; is identity otherwise +// TODO: Write in more idiomatic C++17 + + // namespace c10 + + // namespace std + + +// Parsed from c10/util/complex.h // #pragma once -/** Defines the Half type (half-precision floating-point) including conversions - * to standard C types and basic arithmetic operations. Note that arithmetic - * operations are implemented by converting to floating point and - * performing the operation in float32, instead of using CUDA half intrinsics. - * Most uses of this type within ATen are memory bound, including the - * element-wise kernels, and the half intrinsics aren't efficient on all GPUs. - * If you are writing a compute bound kernel, you can use the CUDA half - * intrinsics directly on the Half type from device code. */ +// #include // #include -// #include -// #include -// #include -// #include -// #include -// #if defined(__cplusplus) && (__cplusplus >= 201103L) -// #include -// #include -// #elif !defined(__OPENCL_VERSION__) -// #include -// #include +// #if defined(__CUDACC__) || defined(__HIPCC__) // #endif -// #ifdef _MSC_VER -// #include +// #if C10_CLANG_HAS_WARNING("-Wimplicit-float-conversion") // #endif +// #if C10_CLANG_HAS_WARNING("-Wfloat-conversion") +// #endif +// Targeting ../DoubleComplex.java -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #ifdef __CUDACC__ -// #include -// #endif +// Targeting ../FloatComplex.java -// #ifdef __HIPCC__ -// #include -// #endif -// #if defined(CL_SYCL_LANGUAGE_VERSION) -// #include // for SYCL 1.2.1 -// #elif defined(SYCL_LANGUAGE_VERSION) -// #include // for SYCL 2020 -// #endif +// Targeting ../HalfComplex.java -// #include // operator typeid -/* - * Convert a 16-bit floating-point number in IEEE half-precision format, in bit - * representation, to a 32-bit floating-point number in IEEE single-precision - * format, in bit representation. - * - * @note The implementation doesn't use any floating-point operations. - */ -@Namespace("c10::detail") public static native @Cast("uint32_t") int fp16_ieee_to_fp32_bits(@Cast("uint16_t") short h); -/* - * Convert a 16-bit floating-point number in IEEE half-precision format, in bit - * representation, to a 32-bit floating-point number in IEEE single-precision - * format. - * - * @note The implementation relies on IEEE-like (no assumption about rounding - * mode and no operations on denormals) floating-point operations and bitcasts - * between integer and floating-point variables. - */ -@Namespace("c10::detail") public static native float fp16_ieee_to_fp32_value(@Cast("uint16_t") short h); -/* - * Convert a 32-bit floating-point number in IEEE single-precision format to a - * 16-bit floating-point number in IEEE half-precision format, in bit - * representation. - * - * @note The implementation relies on IEEE-like (no assumption about rounding - * mode and no operations on denormals) floating-point operations and bitcasts - * between integer and floating-point variables. - */ -@Namespace("c10::detail") public static native @Cast("uint16_t") short fp16_ieee_from_fp32_value(float f); -// Targeting ../Half.java -// Targeting ../HalfComplex.java -// In some versions of MSVC, there will be a compiler error when building. -// C4146: unary minus operator applied to unsigned type, result still unsigned -// C4804: unsafe use of type 'bool' in operation -// It can be addressed by disabling the following warning. -// #ifdef _MSC_VER -// #pragma warning(push) -// #pragma warning(disable : 4146) -// #pragma warning(disable : 4804) -// #pragma warning(disable : 4018) -// #endif + // namespace complex_literals -// The overflow checks may involve float to int conversion which may -// trigger precision loss warning. Re-enable the warning once the code -// is fixed. See T58053069. -// #if C10_CLANG_HAS_WARNING("-Wimplicit-float-conversion") -// #endif +// Define operators between integral scalars and c10::complex. std::complex does +// not support this when T is a floating-point number. This is useful because it +// saves a lot of "static_cast" when operate a complex and an integer. This +// makes the code both less verbose and potentially more efficient. +// #define COMPLEX_INTEGER_OP_TEMPLATE_CONDITION +// typename std::enable_if_t< +// std::is_floating_point::value && std::is_integral::value, +// int> = 0 -// bool can be converted to any type. -// Without specializing on bool, in pytorch_linux_trusty_py2_7_9_build: -// `error: comparison of constant '255' with boolean expression is always false` -// for `f > limit::max()` below +// #undef COMPLEX_INTEGER_OP_TEMPLATE_CONDITION -// skip isnan and isinf check for integral types + // namespace c10 -// #ifdef _MSC_VER -// #pragma warning(pop) +// std functions +// +// The implementation of these functions also follow the design of C++20 + +// #if defined(USE_ROCM) +// #else +// #define ROCm_Bug(x) x // #endif -@Namespace("c10") public static native @Cast("std::ostream*") @ByRef @Name("operator <<") Pointer shiftLeft(@Cast("std::ostream*") @ByRef Pointer out, @Const @ByRef Half value); +// #undef ROCm_Bug + +// For std::conj, there are other versions of it: +// constexpr std::complex conj( float z ); +// template< class DoubleOrInteger > +// constexpr std::complex conj( DoubleOrInteger z ); +// constexpr std::complex conj( long double z ); +// These are not implemented +// TODO(@zasdfgbnm): implement them as c10::conj + +// Thrust does not have complex --> complex version of thrust::proj, +// so this function is not implemented at c10 right now. +// TODO(@zasdfgbnm): implement it by ourselves + +// There is no c10 version of std::polar, because std::polar always +// returns std::complex. Use c10::polar instead; + + // namespace std // namespace c10 -// #include // IWYU pragma: keep +// #define C10_INTERNAL_INCLUDE_COMPLEX_REMAINING_H +// math functions are included in a separate file +// #include // IWYU pragma: keep +// utilities for complex types +// #include // IWYU pragma: keep +// #undef C10_INTERNAL_INCLUDE_COMPLEX_REMAINING_H // Parsed from c10/util/Half-inl.h @@ -4758,104 +4729,135 @@ public class torch extends org.bytedeco.pytorch.presets.torch { -// Parsed from c10/util/complex_utils.h - -// #if !defined(C10_INTERNAL_INCLUDE_COMPLEX_REMAINING_H) -// #error -// "c10/util/complex_utils.h is not meant to be individually included. Include c10/util/complex.h instead." -// #endif - -// #include - -// Extract double from std::complex; is identity otherwise -// TODO: Write in more idiomatic C++17 - - // namespace c10 - - // namespace std - - -// Parsed from c10/util/complex.h +// Parsed from c10/util/Half.h // #pragma once -// #include +/** Defines the Half type (half-precision floating-point) including conversions + * to standard C types and basic arithmetic operations. Note that arithmetic + * operations are implemented by converting to floating point and + * performing the operation in float32, instead of using CUDA half intrinsics. + * Most uses of this type within ATen are memory bound, including the + * element-wise kernels, and the half intrinsics aren't efficient on all GPUs. + * If you are writing a compute bound kernel, you can use the CUDA half + * intrinsics directly on the Half type from device code. */ // #include +// #include +// #include +// #include +// #include +// #include -// #if defined(__CUDACC__) || defined(__HIPCC__) +// #if defined(__cplusplus) && (__cplusplus >= 201103L) +// #include +// #include +// #elif !defined(__OPENCL_VERSION__) +// #include +// #include // #endif -// #if C10_CLANG_HAS_WARNING("-Wimplicit-float-conversion") -// #endif -// #if C10_CLANG_HAS_WARNING("-Wfloat-conversion") +// #ifdef _MSC_VER +// #include // #endif -// Targeting ../DoubleComplex.java - - -// Targeting ../FloatComplex.java - - +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #ifdef __CUDACC__ +// #include +// #endif +// #ifdef __HIPCC__ +// #include +// #endif +// #if defined(CL_SYCL_LANGUAGE_VERSION) +// #include // for SYCL 1.2.1 +// #elif defined(SYCL_LANGUAGE_VERSION) +// #include // for SYCL 2020 +// #endif +// #include // operator typeid +/* + * Convert a 16-bit floating-point number in IEEE half-precision format, in bit + * representation, to a 32-bit floating-point number in IEEE single-precision + * format, in bit representation. + * + * @note The implementation doesn't use any floating-point operations. + */ +@Namespace("c10::detail") public static native @Cast("uint32_t") int fp16_ieee_to_fp32_bits(@Cast("uint16_t") short h); +/* + * Convert a 16-bit floating-point number in IEEE half-precision format, in bit + * representation, to a 32-bit floating-point number in IEEE single-precision + * format. + * + * @note The implementation relies on IEEE-like (no assumption about rounding + * mode and no operations on denormals) floating-point operations and bitcasts + * between integer and floating-point variables. + */ +@Namespace("c10::detail") public static native float fp16_ieee_to_fp32_value(@Cast("uint16_t") short h); +/* + * Convert a 32-bit floating-point number in IEEE single-precision format to a + * 16-bit floating-point number in IEEE half-precision format, in bit + * representation. + * + * @note The implementation relies on IEEE-like (no assumption about rounding + * mode and no operations on denormals) floating-point operations and bitcasts + * between integer and floating-point variables. + */ +@Namespace("c10::detail") public static native @Cast("uint16_t") short fp16_ieee_from_fp32_value(float f); - // namespace complex_literals -// Define operators between integral scalars and c10::complex. std::complex does -// not support this when T is a floating-point number. This is useful because it -// saves a lot of "static_cast" when operate a complex and an integer. This -// makes the code both less verbose and potentially more efficient. -// #define COMPLEX_INTEGER_OP_TEMPLATE_CONDITION -// typename std::enable_if_t< -// std::is_floating_point::value && std::is_integral::value, -// int> = 0 +// Targeting ../Half.java -// #undef COMPLEX_INTEGER_OP_TEMPLATE_CONDITION - // namespace c10 -// std functions -// -// The implementation of these functions also follow the design of C++20 +// TODO : move to complex.h -// #if defined(USE_ROCM) -// #else -// #define ROCm_Bug(x) x +// In some versions of MSVC, there will be a compiler error when building. +// C4146: unary minus operator applied to unsigned type, result still unsigned +// C4804: unsafe use of type 'bool' in operation +// It can be addressed by disabling the following warning. +// #ifdef _MSC_VER +// #pragma warning(push) +// #pragma warning(disable : 4146) +// #pragma warning(disable : 4804) +// #pragma warning(disable : 4018) // #endif -// #undef ROCm_Bug +// The overflow checks may involve float to int conversion which may +// trigger precision loss warning. Re-enable the warning once the code +// is fixed. See T58053069. +// #if C10_CLANG_HAS_WARNING("-Wimplicit-float-conversion") +// #endif -// For std::conj, there are other versions of it: -// constexpr std::complex conj( float z ); -// template< class DoubleOrInteger > -// constexpr std::complex conj( DoubleOrInteger z ); -// constexpr std::complex conj( long double z ); -// These are not implemented -// TODO(@zasdfgbnm): implement them as c10::conj +// bool can be converted to any type. +// Without specializing on bool, in pytorch_linux_trusty_py2_7_9_build: +// `error: comparison of constant '255' with boolean expression is always false` +// for `f > limit::max()` below -// Thrust does not have complex --> complex version of thrust::proj, -// so this function is not implemented at c10 right now. -// TODO(@zasdfgbnm): implement it by ourselves +// skip isnan and isinf check for integral types -// There is no c10 version of std::polar, because std::polar always -// returns std::complex. Use c10::polar instead; +// #ifdef _MSC_VER +// #pragma warning(pop) +// #endif - // namespace std +@Namespace("c10") public static native @Cast("std::ostream*") @ByRef @Name("operator <<") Pointer shiftLeft(@Cast("std::ostream*") @ByRef Pointer out, @Const @ByRef Half value); // namespace c10 -// #define C10_INTERNAL_INCLUDE_COMPLEX_REMAINING_H -// math functions are included in a separate file -// #include // IWYU pragma: keep -// utilities for complex types -// #include // IWYU pragma: keep -// #undef C10_INTERNAL_INCLUDE_COMPLEX_REMAINING_H +// #include // IWYU pragma: keep // Parsed from c10/util/Float8_e5m2-inl.h @@ -6712,9 +6714,6 @@ public class torch extends org.bytedeco.pytorch.presets.torch { // #include // #include -@Namespace("c10") public static native @StdString BytePointer KeyStrRepr(@StdString BytePointer key); -@Namespace("c10") public static native @StdString String KeyStrRepr(@StdString String key); - @Namespace("c10") public enum RegistryPriority { REGISTRY_FALLBACK(1), REGISTRY_DEFAULT(2), @@ -12622,20 +12621,18 @@ public class torch extends org.bytedeco.pytorch.presets.torch { // Targeting ../OptionalType.java + + // Targeting ../Stride.java -@Namespace("c10") public static native @ByVal StrideOptional merge_primitive( - @Const @ByRef StrideOptional a, - @Const @ByRef StrideOptional b); + // Targeting ../ShapeSymbol.java -@Namespace("c10") public static native @ByVal ShapeSymbol merge_primitive( - @Const @ByRef ShapeSymbol a, - @Const @ByRef ShapeSymbol b); + // Targeting ../SymbolicShape.java @@ -13302,9 +13299,6 @@ public class torch extends org.bytedeco.pytorch.presets.torch { // #include // #include // #include -// Targeting ../class_.java - - @Namespace("c10::raw::weak_intrusive_ptr") public static native void incref(@Cast("c10::intrusive_ptr_target*") Pointer self); @@ -16798,12 +16792,6 @@ public class torch extends org.bytedeco.pytorch.presets.torch { // forward; it doesn't work if you try to deduce it // NB: keep this in sync with cloneWithRealTypes in function_schema.cpp -@Namespace("c10") public static native long unpackSymInt(@ByVal SymInt x); - -@Namespace("c10") public static native @ByVal LongArrayRef unpackSymInt(@ByVal SymIntArrayRef x); - -@Namespace("c10") public static native @ByVal LongOptional unpackSymInt(@ByVal SymIntOptional x); - @@ -58814,9 +58802,6 @@ public class torch extends org.bytedeco.pytorch.presets.torch { //===----------------------------------------------------------------------===// // Utilities //===----------------------------------------------------------------------===// -// Targeting ../pack.java - - // namespace detail // namespace torch @@ -65118,6 +65103,12 @@ The list of (type, depth) pairs controls the type of specializations and the num // Targeting ../TensorExampleStack.java + +/** A {@code Collation} for {@code Example} types that stacks all data + * tensors into one tensor, and all target (label) tensors into one tensor. */ + +/** A {@code Collation} for {@code Example} types that stacks all data + * tensors into one tensor. */ // namespace transforms // namespace data // namespace torch diff --git a/pytorch/src/gen/java/org/bytedeco/pytorch/pack.java b/pytorch/src/gen/java/org/bytedeco/pytorch/pack.java deleted file mode 100644 index 462a5983648..00000000000 --- a/pytorch/src/gen/java/org/bytedeco/pytorch/pack.java +++ /dev/null @@ -1,26 +0,0 @@ -// Targeted by JavaCPP version 1.5.10-SNAPSHOT: DO NOT EDIT THIS FILE - -package org.bytedeco.pytorch; - -import org.bytedeco.pytorch.Allocator; -import org.bytedeco.pytorch.Function; -import org.bytedeco.pytorch.functions.*; -import org.bytedeco.pytorch.Module; -import org.bytedeco.javacpp.annotation.Cast; -import java.nio.*; -import org.bytedeco.javacpp.*; -import org.bytedeco.javacpp.annotation.*; - -import static org.bytedeco.javacpp.presets.javacpp.*; -import static org.bytedeco.openblas.global.openblas_nolapack.*; -import static org.bytedeco.openblas.global.openblas.*; - -import static org.bytedeco.pytorch.global.torch.*; - -@Namespace("torch::detail") @Opaque @Properties(inherit = org.bytedeco.pytorch.presets.torch.class) -public class pack extends Pointer { - /** Empty constructor. Calls {@code super((Pointer)null)}. */ - public pack() { super((Pointer)null); } - /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ - public pack(Pointer p) { super(p); } -} diff --git a/pytorch/src/main/java/org/bytedeco/pytorch/presets/torch.java b/pytorch/src/main/java/org/bytedeco/pytorch/presets/torch.java index 20a39cf47f8..ad6b0e72d1e 100644 --- a/pytorch/src/main/java/org/bytedeco/pytorch/presets/torch.java +++ b/pytorch/src/main/java/org/bytedeco/pytorch/presets/torch.java @@ -1093,6 +1093,32 @@ public void map(InfoMap infoMap) { .put(new Info("c10::complex::real", "c10::complex::imag", "c10::complex::real", "c10::complex::imag", "c10::complex::real", "c10::complex::imag").annotations("@org.bytedeco.javacpp.annotation.Function")) + .put(new Info( // Not implemented in c10::complex template specialization: + "c10::complex::operator =(c10::Half)", + "c10::complex::real(c10::Half)", + "c10::complex::imag(c10::Half)", + "c10::complex::operator const bool()", + "c10::complex::operator +=(c10::Half)", + "c10::complex::operator -=(c10::Half)", + "c10::complex::operator *=(c10::Half)", + "c10::complex::operator /=(c10::Half)" + ).skip()) + .put(new Info("c10::complex::complex(const c10::Half&, const c10::Half&)").javaText( // Second argument not optional + add specific functions + "public HalfComplex(Half re, Half im) { super((Pointer)null); allocate(re, im); }\n" + + "private native void allocate(@Const @ByRef Half re, @Const @ByRef(nullValue = \"c10::Half()\") Half im);\n" + + "public HalfComplex(@Const @ByRef FloatComplex value) { super((Pointer)null); allocate(value); }\n" + + "private native void allocate(@Const @ByRef FloatComplex value);\n" + + "\n" + + "// Conversion operator\n" + + "public native @ByVal @Name(\"operator c10::complex\") FloatComplex asFloatComplex();\n" + + "\n" + + "public native @ByRef @Name(\"operator +=\") HalfComplex addPut(@Const @ByRef HalfComplex other);\n" + + "\n" + + "public native @ByRef @Name(\"operator -=\") HalfComplex subtractPut(@Const @ByRef HalfComplex other);\n" + + "\n" + + "public native @ByRef @Name(\"operator *=\") HalfComplex multiplyPut(@Const @ByRef HalfComplex other);" + ) + ) ; @@ -1284,7 +1310,10 @@ public void map(InfoMap infoMap) { template("torch::data::transforms::BatchTransform", template("std::vector", example), example), template("torch::data::transforms::Collation", example) ).pointerTypes(p + "ExampleCollation")) - .put(new Info(template("torch::data::transforms::Stack", example)).pointerTypes(p + "ExampleStack")) + // The Stack primary template is empty. Constructors are defined in template specializations. + // So the generated Java classes are @Opaque and have no constructors. + // We might need to force the generation of constructors somehow. + .put(new Info(template("torch::data::transforms::Stack", example)).pointerTypes(p + "ExampleStack").base(p + "ExampleCollation")) .put(new Info(chunkDataReader).pointerTypes("Chunk" + p + "DataReader").virtualize()) .put(new Info( template("torch::data::datasets::ChunkDataset", mangledChunkDataReader, "torch::data::samplers::RandomSampler", "torch::data::samplers::RandomSampler") @@ -2298,7 +2327,9 @@ We need either to put an annotation info on each member, or javaName("@NoOffset "torch::detail::constructSchemaOrName", "torch::jit::ClassDef::create", "torch::jit::Code::operator <<(std::ostream&, const torch::jit::Code&)", // The friend operator is truly a member of torch::jit and not torch::jit::Code - "torch::profiler::impl::getNvtxStr" + "torch::profiler::impl::getNvtxStr", + "c10::merge_primitive" // templated function with some specializations. Will have to figure what + // instances to create if needed. ).skip()); //// Aliases necessary because of Parser limited namespace resolution diff --git a/pytorch/src/main/resources/org/bytedeco/pytorch/presets/torch_include.h b/pytorch/src/main/resources/org/bytedeco/pytorch/presets/torch_include.h index bfb6b5def37..a759d1a0c1d 100644 --- a/pytorch/src/main/resources/org/bytedeco/pytorch/presets/torch_include.h +++ b/pytorch/src/main/resources/org/bytedeco/pytorch/presets/torch_include.h @@ -47,10 +47,10 @@ #include "c10/util/Float8_e4m3fn-inl.h" #include "c10/util/Float8_e4m3fn.h" #include "c10/util/complex_math.h" -#include "c10/util/Half.h" // Moved before complex.h because it overrides complex -#include "c10/util/Half-inl.h" #include "c10/util/complex_utils.h" #include "c10/util/complex.h" +#include "c10/util/Half-inl.h" +#include "c10/util/Half.h" #include "c10/util/Float8_e5m2-inl.h" #include "c10/util/Float8_e5m2.h" #include "c10/util/bits.h"