ml-dtypes 0.3.2__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/PKG-INFO +1 -1
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/ml_dtypes/__init__.py +12 -12
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/ml_dtypes/_src/custom_float.h +62 -41
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/ml_dtypes/_src/dtypes.cc +1 -1
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/ml_dtypes/_src/int4_numpy.h +67 -46
- ml_dtypes-0.4.0/ml_dtypes/include/int4.h +8 -0
- ml_dtypes-0.4.0/ml_dtypes/include/intn.h +313 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/ml_dtypes.egg-info/PKG-INFO +1 -1
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/ml_dtypes.egg-info/SOURCES.txt +1 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/pyproject.toml +3 -5
- ml_dtypes-0.3.2/ml_dtypes/include/int4.h +0 -312
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/AUTHORS +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/LICENSE +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/LICENSE.eigen +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/MANIFEST.in +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/README.md +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/ml_dtypes/_finfo.py +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/ml_dtypes/_iinfo.py +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/ml_dtypes/_src/common.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/ml_dtypes/_src/numpy.cc +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/ml_dtypes/_src/numpy.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/ml_dtypes/_src/ufuncs.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/ml_dtypes/include/float8.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/ml_dtypes/py.typed +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/ml_dtypes.egg-info/dependency_links.txt +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/ml_dtypes.egg-info/requires.txt +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/ml_dtypes.egg-info/top_level.txt +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/setup.cfg +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/setup.py +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/Core +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/ArithmeticSequence.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Array.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/ArrayBase.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/ArrayWrapper.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Assign.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/AssignEvaluator.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Assign_MKL.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/BandMatrix.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Block.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/CommaInitializer.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/ConditionEstimator.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/CoreEvaluators.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/CoreIterators.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/CwiseBinaryOp.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/CwiseNullaryOp.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/CwiseTernaryOp.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/CwiseUnaryOp.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/CwiseUnaryView.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/DenseBase.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/DenseCoeffsBase.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/DenseStorage.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Diagonal.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/DiagonalMatrix.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/DiagonalProduct.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Dot.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/EigenBase.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/ForceAlignedAccess.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Fuzzy.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/GeneralProduct.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/GenericPacketMath.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/GlobalFunctions.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/IO.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/IndexedView.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/InternalHeaderCheck.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Inverse.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Map.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/MapBase.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/MathFunctions.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/MathFunctionsImpl.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Matrix.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/MatrixBase.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/NestByValue.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/NoAlias.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/NumTraits.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/PartialReduxEvaluator.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/PermutationMatrix.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/PlainObjectBase.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Product.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/ProductEvaluators.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Random.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Redux.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Ref.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Replicate.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Reshaped.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/ReturnByValue.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Reverse.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Select.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/SelfAdjointView.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/SelfCwiseBinaryOp.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/SkewSymmetricMatrix3.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Solve.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/SolveTriangular.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/SolverBase.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/StableNorm.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/StlIterators.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Stride.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Swap.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Transpose.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Transpositions.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/TriangularMatrix.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/VectorBlock.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/VectorwiseOp.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/Visitor.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/AVX/Complex.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/AVX/MathFunctions.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/AVX/PacketMath.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/AVX/TypeCasting.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/AVX512/Complex.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/AVX512/GemmKernel.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/AVX512/MathFunctions.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/AVX512/PacketMath.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/AVX512/PacketMathFP16.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/AVX512/TrsmKernel.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/AVX512/TypeCasting.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/AltiVec/Complex.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/AltiVec/MathFunctions.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/AltiVec/MatrixProduct.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductCommon.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductMMA.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductMMAbfloat16.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/AltiVec/MatrixVectorProduct.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/AltiVec/PacketMath.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/Default/BFloat16.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/Default/ConjHelper.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/Default/Half.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/Default/Settings.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/Default/TypeCasting.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/GPU/Complex.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/GPU/MathFunctions.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/GPU/PacketMath.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/GPU/Tuple.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/GPU/TypeCasting.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/HIP/hcc/math_constants.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/MSA/Complex.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/MSA/MathFunctions.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/MSA/PacketMath.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/NEON/Complex.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/NEON/GeneralBlockPanelKernel.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/NEON/MathFunctions.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/NEON/PacketMath.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/NEON/TypeCasting.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/NEON/UnaryFunctors.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/SSE/Complex.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/SSE/MathFunctions.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/SSE/PacketMath.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/SSE/TypeCasting.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/SVE/MathFunctions.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/SVE/PacketMath.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/SVE/TypeCasting.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/SYCL/InteropHeaders.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/SYCL/MathFunctions.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/SYCL/PacketMath.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/SYCL/SyclMemoryModel.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/SYCL/TypeCasting.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/ZVector/Complex.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/ZVector/MathFunctions.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/arch/ZVector/PacketMath.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/functors/AssignmentFunctors.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/functors/BinaryFunctors.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/functors/NullaryFunctors.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/functors/StlFunctors.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/functors/TernaryFunctors.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/functors/UnaryFunctors.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/products/GeneralMatrixMatrix.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/products/GeneralMatrixVector.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/products/Parallelizer.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/products/SelfadjointMatrixVector.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/products/SelfadjointMatrixVector_BLAS.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/products/SelfadjointProduct.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/products/SelfadjointRank2Update.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/products/TriangularMatrixMatrix.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/products/TriangularMatrixVector.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/products/TriangularMatrixVector_BLAS.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/products/TriangularSolverMatrix.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/products/TriangularSolverVector.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/util/Assert.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/util/BlasUtil.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/util/ConfigureVectorization.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/util/Constants.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/util/DisableStupidWarnings.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/util/ForwardDeclarations.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/util/IndexedViewHelper.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/util/IntegralConstant.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/util/MKL_support.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/util/Macros.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/util/Memory.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/util/Meta.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/util/ReenableStupidWarnings.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/util/ReshapedHelper.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/util/Serializer.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/util/StaticAssert.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/util/SymbolicIndex.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/Core/util/XprHelper.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/plugins/ArrayCwiseBinaryOps.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/plugins/BlockMethods.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/plugins/CommonCwiseBinaryOps.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/plugins/CommonCwiseUnaryOps.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/plugins/IndexedViewMethods.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/plugins/InternalHeaderCheck.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.h +0 -0
- {ml_dtypes-0.3.2 → ml_dtypes-0.4.0}/third_party/eigen/Eigen/src/plugins/ReshapedMethods.h +0 -0
|
@@ -12,19 +12,19 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
__version__ =
|
|
15
|
+
__version__ = "0.4.0" # Keep in sync with pyproject.toml:version
|
|
16
16
|
__all__ = [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
"__version__",
|
|
18
|
+
"bfloat16",
|
|
19
|
+
"finfo",
|
|
20
|
+
"float8_e4m3b11fnuz",
|
|
21
|
+
"float8_e4m3fn",
|
|
22
|
+
"float8_e4m3fnuz",
|
|
23
|
+
"float8_e5m2",
|
|
24
|
+
"float8_e5m2fnuz",
|
|
25
|
+
"iinfo",
|
|
26
|
+
"int4",
|
|
27
|
+
"uint4",
|
|
28
28
|
]
|
|
29
29
|
|
|
30
30
|
from typing import Type
|
|
@@ -35,13 +35,17 @@ limitations under the License.
|
|
|
35
35
|
#include <Python.h>
|
|
36
36
|
|
|
37
37
|
#include "Eigen/Core"
|
|
38
|
-
#include "_src/common.h"
|
|
38
|
+
#include "_src/common.h" // NOLINT
|
|
39
39
|
#include "_src/ufuncs.h" // NOLINT
|
|
40
40
|
|
|
41
41
|
#undef copysign // TODO(ddunleavy): temporary fix for Windows bazel build
|
|
42
42
|
// Possible this has to do with numpy.h being included before
|
|
43
43
|
// system headers and in bfloat16.{cc,h}?
|
|
44
44
|
|
|
45
|
+
#if NPY_ABI_VERSION < 0x02000000
|
|
46
|
+
#define PyArray_DescrProto PyArray_Descr
|
|
47
|
+
#endif
|
|
48
|
+
|
|
45
49
|
namespace ml_dtypes {
|
|
46
50
|
|
|
47
51
|
template <typename T>
|
|
@@ -59,13 +63,18 @@ struct CustomFloatType {
|
|
|
59
63
|
|
|
60
64
|
static PyNumberMethods number_methods;
|
|
61
65
|
static PyArray_ArrFuncs arr_funcs;
|
|
62
|
-
static
|
|
66
|
+
static PyArray_DescrProto npy_descr_proto;
|
|
67
|
+
static PyArray_Descr* npy_descr;
|
|
63
68
|
};
|
|
64
69
|
|
|
65
70
|
template <typename T>
|
|
66
71
|
int CustomFloatType<T>::npy_type = NPY_NOTYPE;
|
|
67
72
|
template <typename T>
|
|
68
73
|
PyObject* CustomFloatType<T>::type_ptr = nullptr;
|
|
74
|
+
template <typename T>
|
|
75
|
+
PyArray_DescrProto CustomFloatType<T>::npy_descr_proto;
|
|
76
|
+
template <typename T>
|
|
77
|
+
PyArray_Descr* CustomFloatType<T>::npy_descr = nullptr;
|
|
69
78
|
|
|
70
79
|
// Representation of a Python custom float object.
|
|
71
80
|
template <typename T>
|
|
@@ -397,24 +406,26 @@ template <typename T>
|
|
|
397
406
|
PyArray_ArrFuncs CustomFloatType<T>::arr_funcs;
|
|
398
407
|
|
|
399
408
|
template <typename T>
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
409
|
+
PyArray_DescrProto GetCustomFloatDescrProto() {
|
|
410
|
+
return {
|
|
411
|
+
PyObject_HEAD_INIT(nullptr)
|
|
412
|
+
/*typeobj=*/nullptr, // Filled in later
|
|
413
|
+
/*kind=*/TypeDescriptor<T>::kNpyDescrKind,
|
|
414
|
+
/*type=*/TypeDescriptor<T>::kNpyDescrType,
|
|
415
|
+
/*byteorder=*/TypeDescriptor<T>::kNpyDescrByteorder,
|
|
416
|
+
/*flags=*/NPY_NEEDS_PYAPI | NPY_USE_SETITEM,
|
|
417
|
+
/*type_num=*/0,
|
|
418
|
+
/*elsize=*/sizeof(T),
|
|
419
|
+
/*alignment=*/alignof(T),
|
|
420
|
+
/*subarray=*/nullptr,
|
|
421
|
+
/*fields=*/nullptr,
|
|
422
|
+
/*names=*/nullptr,
|
|
423
|
+
/*f=*/&CustomFloatType<T>::arr_funcs,
|
|
424
|
+
/*metadata=*/nullptr,
|
|
425
|
+
/*c_metadata=*/nullptr,
|
|
426
|
+
/*hash=*/-1, // -1 means "not computed yet".
|
|
427
|
+
};
|
|
428
|
+
}
|
|
418
429
|
|
|
419
430
|
// Implementations of NumPy array methods.
|
|
420
431
|
|
|
@@ -628,8 +639,8 @@ bool RegisterCustomFloatCast(int numpy_type = TypeDescriptor<OtherT>::Dtype()) {
|
|
|
628
639
|
NPyCast<OtherT, T>) < 0) {
|
|
629
640
|
return false;
|
|
630
641
|
}
|
|
631
|
-
if (PyArray_RegisterCastFunc(
|
|
632
|
-
|
|
642
|
+
if (PyArray_RegisterCastFunc(CustomFloatType<T>::npy_descr, numpy_type,
|
|
643
|
+
NPyCast<T, OtherT>) < 0) {
|
|
633
644
|
return false;
|
|
634
645
|
}
|
|
635
646
|
return true;
|
|
@@ -697,27 +708,27 @@ bool RegisterFloatCasts() {
|
|
|
697
708
|
}
|
|
698
709
|
|
|
699
710
|
// Safe casts from T to other types
|
|
700
|
-
if (PyArray_RegisterCanCast(
|
|
711
|
+
if (PyArray_RegisterCanCast(TypeDescriptor<T>::npy_descr, NPY_FLOAT,
|
|
701
712
|
NPY_NOSCALAR) < 0) {
|
|
702
713
|
return false;
|
|
703
714
|
}
|
|
704
|
-
if (PyArray_RegisterCanCast(
|
|
715
|
+
if (PyArray_RegisterCanCast(TypeDescriptor<T>::npy_descr, NPY_DOUBLE,
|
|
705
716
|
NPY_NOSCALAR) < 0) {
|
|
706
717
|
return false;
|
|
707
718
|
}
|
|
708
|
-
if (PyArray_RegisterCanCast(
|
|
719
|
+
if (PyArray_RegisterCanCast(TypeDescriptor<T>::npy_descr, NPY_LONGDOUBLE,
|
|
709
720
|
NPY_NOSCALAR) < 0) {
|
|
710
721
|
return false;
|
|
711
722
|
}
|
|
712
|
-
if (PyArray_RegisterCanCast(
|
|
723
|
+
if (PyArray_RegisterCanCast(TypeDescriptor<T>::npy_descr, NPY_CFLOAT,
|
|
713
724
|
NPY_NOSCALAR) < 0) {
|
|
714
725
|
return false;
|
|
715
726
|
}
|
|
716
|
-
if (PyArray_RegisterCanCast(
|
|
727
|
+
if (PyArray_RegisterCanCast(TypeDescriptor<T>::npy_descr, NPY_CDOUBLE,
|
|
717
728
|
NPY_NOSCALAR) < 0) {
|
|
718
729
|
return false;
|
|
719
730
|
}
|
|
720
|
-
if (PyArray_RegisterCanCast(
|
|
731
|
+
if (PyArray_RegisterCanCast(TypeDescriptor<T>::npy_descr, NPY_CLONGDOUBLE,
|
|
721
732
|
NPY_NOSCALAR) < 0) {
|
|
722
733
|
return false;
|
|
723
734
|
}
|
|
@@ -921,19 +932,26 @@ bool RegisterFloatDtype(PyObject* numpy) {
|
|
|
921
932
|
arr_funcs.argmax = NPyCustomFloat_ArgMaxFunc<T>;
|
|
922
933
|
arr_funcs.argmin = NPyCustomFloat_ArgMinFunc<T>;
|
|
923
934
|
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
935
|
+
// This is messy, but that's because the NumPy 2.0 API transition is messy.
|
|
936
|
+
// Before 2.0, NumPy assumes we'll keep the descriptor passed in to
|
|
937
|
+
// RegisterDataType alive, because it stores its pointer.
|
|
938
|
+
// After 2.0, the proto and descriptor types diverge, and NumPy allocates
|
|
939
|
+
// and manages the lifetime of the descriptor itself.
|
|
940
|
+
PyArray_DescrProto& descr_proto = CustomFloatType<T>::npy_descr_proto;
|
|
941
|
+
descr_proto = GetCustomFloatDescrProto<T>();
|
|
942
|
+
Py_SET_TYPE(&descr_proto, &PyArrayDescr_Type);
|
|
943
|
+
descr_proto.typeobj = type;
|
|
930
944
|
|
|
931
|
-
TypeDescriptor<T>::npy_type =
|
|
932
|
-
|
|
933
|
-
if (TypeDescriptor<T>::Dtype() < 0) {
|
|
945
|
+
TypeDescriptor<T>::npy_type = PyArray_RegisterDataType(&descr_proto);
|
|
946
|
+
if (TypeDescriptor<T>::npy_type < 0) {
|
|
934
947
|
return false;
|
|
935
948
|
}
|
|
936
949
|
|
|
950
|
+
// TODO(phawkins): We intentionally leak the pointer to the descriptor.
|
|
951
|
+
// Implement a better module destructor to handle this.
|
|
952
|
+
CustomFloatType<T>::npy_descr =
|
|
953
|
+
PyArray_DescrFromType(TypeDescriptor<T>::npy_type);
|
|
954
|
+
|
|
937
955
|
Safe_PyObjectPtr typeDict_obj =
|
|
938
956
|
make_safe(PyObject_GetAttrString(numpy, "sctypeDict"));
|
|
939
957
|
if (!typeDict_obj) return false;
|
|
@@ -945,10 +963,9 @@ bool RegisterFloatDtype(PyObject* numpy) {
|
|
|
945
963
|
}
|
|
946
964
|
|
|
947
965
|
// Support dtype(type_name)
|
|
948
|
-
if (PyObject_SetAttrString(
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
0) {
|
|
966
|
+
if (PyObject_SetAttrString(
|
|
967
|
+
TypeDescriptor<T>::type_ptr, "dtype",
|
|
968
|
+
reinterpret_cast<PyObject*>(CustomFloatType<T>::npy_descr)) < 0) {
|
|
952
969
|
return false;
|
|
953
970
|
}
|
|
954
971
|
|
|
@@ -957,4 +974,8 @@ bool RegisterFloatDtype(PyObject* numpy) {
|
|
|
957
974
|
|
|
958
975
|
} // namespace ml_dtypes
|
|
959
976
|
|
|
977
|
+
#if NPY_ABI_VERSION < 0x02000000
|
|
978
|
+
#undef PyArray_DescrProto
|
|
979
|
+
#endif
|
|
980
|
+
|
|
960
981
|
#endif // ML_DTYPES_CUSTOM_FLOAT_H_
|
|
@@ -27,7 +27,11 @@ limitations under the License.
|
|
|
27
27
|
#include "Eigen/Core"
|
|
28
28
|
#include "_src/common.h" // NOLINT
|
|
29
29
|
#include "_src/ufuncs.h" // NOLINT
|
|
30
|
-
#include "include/
|
|
30
|
+
#include "include/intn.h"
|
|
31
|
+
|
|
32
|
+
#if NPY_ABI_VERSION < 0x02000000
|
|
33
|
+
#define PyArray_DescrProto PyArray_Descr
|
|
34
|
+
#endif
|
|
31
35
|
|
|
32
36
|
namespace ml_dtypes {
|
|
33
37
|
|
|
@@ -48,13 +52,18 @@ struct Int4TypeDescriptor {
|
|
|
48
52
|
|
|
49
53
|
static PyNumberMethods number_methods;
|
|
50
54
|
static PyArray_ArrFuncs arr_funcs;
|
|
51
|
-
static
|
|
55
|
+
static PyArray_DescrProto npy_descr_proto;
|
|
56
|
+
static PyArray_Descr* npy_descr;
|
|
52
57
|
};
|
|
53
58
|
|
|
54
59
|
template <typename T>
|
|
55
60
|
int Int4TypeDescriptor<T>::npy_type = NPY_NOTYPE;
|
|
56
61
|
template <typename T>
|
|
57
62
|
PyObject* Int4TypeDescriptor<T>::type_ptr = nullptr;
|
|
63
|
+
template <typename T>
|
|
64
|
+
PyArray_DescrProto Int4TypeDescriptor<T>::npy_descr_proto;
|
|
65
|
+
template <typename T>
|
|
66
|
+
PyArray_Descr* Int4TypeDescriptor<T>::npy_descr = nullptr;
|
|
58
67
|
|
|
59
68
|
// Representation of a Python custom integer object.
|
|
60
69
|
template <typename T>
|
|
@@ -406,24 +415,26 @@ template <typename T>
|
|
|
406
415
|
PyArray_ArrFuncs Int4TypeDescriptor<T>::arr_funcs;
|
|
407
416
|
|
|
408
417
|
template <typename T>
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
418
|
+
PyArray_DescrProto GetInt4DescrProto() {
|
|
419
|
+
return {
|
|
420
|
+
PyObject_HEAD_INIT(nullptr)
|
|
421
|
+
/*typeobj=*/nullptr, // Filled in later
|
|
422
|
+
/*kind=*/TypeDescriptor<T>::kNpyDescrKind,
|
|
423
|
+
/*type=*/TypeDescriptor<T>::kNpyDescrType,
|
|
424
|
+
/*byteorder=*/TypeDescriptor<T>::kNpyDescrByteorder,
|
|
425
|
+
/*flags=*/NPY_NEEDS_PYAPI | NPY_USE_SETITEM,
|
|
426
|
+
/*type_num=*/0,
|
|
427
|
+
/*elsize=*/sizeof(T),
|
|
428
|
+
/*alignment=*/alignof(T),
|
|
429
|
+
/*subarray=*/nullptr,
|
|
430
|
+
/*fields=*/nullptr,
|
|
431
|
+
/*names=*/nullptr,
|
|
432
|
+
/*f=*/&Int4TypeDescriptor<T>::arr_funcs,
|
|
433
|
+
/*metadata=*/nullptr,
|
|
434
|
+
/*c_metadata=*/nullptr,
|
|
435
|
+
/*hash=*/-1, // -1 means "not computed yet".
|
|
436
|
+
};
|
|
437
|
+
}
|
|
427
438
|
|
|
428
439
|
// Implementations of NumPy array methods.
|
|
429
440
|
|
|
@@ -606,7 +617,7 @@ bool RegisterCustomIntCast(int numpy_type = TypeDescriptor<OtherT>::Dtype()) {
|
|
|
606
617
|
IntegerCast<OtherT, T>) < 0) {
|
|
607
618
|
return false;
|
|
608
619
|
}
|
|
609
|
-
if (PyArray_RegisterCastFunc(
|
|
620
|
+
if (PyArray_RegisterCastFunc(Int4TypeDescriptor<T>::npy_descr, numpy_type,
|
|
610
621
|
IntegerCast<T, OtherT>) < 0) {
|
|
611
622
|
return false;
|
|
612
623
|
}
|
|
@@ -674,66 +685,66 @@ bool RegisterInt4Casts() {
|
|
|
674
685
|
}
|
|
675
686
|
|
|
676
687
|
// Safe casts from T to other types
|
|
677
|
-
if (PyArray_RegisterCanCast(
|
|
688
|
+
if (PyArray_RegisterCanCast(TypeDescriptor<T>::npy_descr, NPY_INT8,
|
|
678
689
|
NPY_NOSCALAR) < 0) {
|
|
679
690
|
return false;
|
|
680
691
|
}
|
|
681
|
-
if (PyArray_RegisterCanCast(
|
|
692
|
+
if (PyArray_RegisterCanCast(TypeDescriptor<T>::npy_descr, NPY_INT16,
|
|
682
693
|
NPY_NOSCALAR) < 0) {
|
|
683
694
|
return false;
|
|
684
695
|
}
|
|
685
|
-
if (PyArray_RegisterCanCast(
|
|
696
|
+
if (PyArray_RegisterCanCast(TypeDescriptor<T>::npy_descr, NPY_INT32,
|
|
686
697
|
NPY_NOSCALAR) < 0) {
|
|
687
698
|
return false;
|
|
688
699
|
}
|
|
689
|
-
if (PyArray_RegisterCanCast(
|
|
700
|
+
if (PyArray_RegisterCanCast(TypeDescriptor<T>::npy_descr, NPY_INT64,
|
|
690
701
|
NPY_NOSCALAR) < 0) {
|
|
691
702
|
return false;
|
|
692
703
|
}
|
|
693
704
|
|
|
694
705
|
if (std::is_same_v<uint4, T>) {
|
|
695
|
-
if (PyArray_RegisterCanCast(
|
|
706
|
+
if (PyArray_RegisterCanCast(TypeDescriptor<T>::npy_descr, NPY_UINT8,
|
|
696
707
|
NPY_NOSCALAR) < 0) {
|
|
697
708
|
return false;
|
|
698
709
|
}
|
|
699
|
-
if (PyArray_RegisterCanCast(
|
|
710
|
+
if (PyArray_RegisterCanCast(TypeDescriptor<T>::npy_descr, NPY_UINT16,
|
|
700
711
|
NPY_NOSCALAR) < 0) {
|
|
701
712
|
return false;
|
|
702
713
|
}
|
|
703
|
-
if (PyArray_RegisterCanCast(
|
|
714
|
+
if (PyArray_RegisterCanCast(TypeDescriptor<T>::npy_descr, NPY_UINT32,
|
|
704
715
|
NPY_NOSCALAR) < 0) {
|
|
705
716
|
return false;
|
|
706
717
|
}
|
|
707
|
-
if (PyArray_RegisterCanCast(
|
|
718
|
+
if (PyArray_RegisterCanCast(TypeDescriptor<T>::npy_descr, NPY_UINT64,
|
|
708
719
|
NPY_NOSCALAR) < 0) {
|
|
709
720
|
return false;
|
|
710
721
|
}
|
|
711
722
|
}
|
|
712
|
-
if (PyArray_RegisterCanCast(
|
|
723
|
+
if (PyArray_RegisterCanCast(TypeDescriptor<T>::npy_descr, NPY_HALF,
|
|
713
724
|
NPY_NOSCALAR) < 0) {
|
|
714
725
|
return false;
|
|
715
726
|
}
|
|
716
|
-
if (PyArray_RegisterCanCast(
|
|
727
|
+
if (PyArray_RegisterCanCast(TypeDescriptor<T>::npy_descr, NPY_FLOAT,
|
|
717
728
|
NPY_NOSCALAR) < 0) {
|
|
718
729
|
return false;
|
|
719
730
|
}
|
|
720
|
-
if (PyArray_RegisterCanCast(
|
|
731
|
+
if (PyArray_RegisterCanCast(TypeDescriptor<T>::npy_descr, NPY_DOUBLE,
|
|
721
732
|
NPY_NOSCALAR) < 0) {
|
|
722
733
|
return false;
|
|
723
734
|
}
|
|
724
|
-
if (PyArray_RegisterCanCast(
|
|
735
|
+
if (PyArray_RegisterCanCast(TypeDescriptor<T>::npy_descr, NPY_LONGDOUBLE,
|
|
725
736
|
NPY_NOSCALAR) < 0) {
|
|
726
737
|
return false;
|
|
727
738
|
}
|
|
728
|
-
if (PyArray_RegisterCanCast(
|
|
739
|
+
if (PyArray_RegisterCanCast(TypeDescriptor<T>::npy_descr, NPY_CFLOAT,
|
|
729
740
|
NPY_NOSCALAR) < 0) {
|
|
730
741
|
return false;
|
|
731
742
|
}
|
|
732
|
-
if (PyArray_RegisterCanCast(
|
|
743
|
+
if (PyArray_RegisterCanCast(TypeDescriptor<T>::npy_descr, NPY_CDOUBLE,
|
|
733
744
|
NPY_NOSCALAR) < 0) {
|
|
734
745
|
return false;
|
|
735
746
|
}
|
|
736
|
-
if (PyArray_RegisterCanCast(
|
|
747
|
+
if (PyArray_RegisterCanCast(TypeDescriptor<T>::npy_descr, NPY_CLONGDOUBLE,
|
|
737
748
|
NPY_NOSCALAR) < 0) {
|
|
738
749
|
return false;
|
|
739
750
|
}
|
|
@@ -821,18 +832,24 @@ bool RegisterInt4Dtype(PyObject* numpy) {
|
|
|
821
832
|
arr_funcs.argmax = NPyInt4_ArgMaxFunc<T>;
|
|
822
833
|
arr_funcs.argmin = NPyInt4_ArgMinFunc<T>;
|
|
823
834
|
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
835
|
+
// This is messy, but that's because the NumPy 2.0 API transition is messy.
|
|
836
|
+
// Before 2.0, NumPy assumes we'll keep the descriptor passed in to
|
|
837
|
+
// RegisterDataType alive, because it stores its pointer.
|
|
838
|
+
// After 2.0, the proto and descriptor types diverge, and NumPy allocates
|
|
839
|
+
// and manages the lifetime of the descriptor itself.
|
|
840
|
+
PyArray_DescrProto& descr_proto = Int4TypeDescriptor<T>::npy_descr_proto;
|
|
841
|
+
descr_proto = GetInt4DescrProto<T>();
|
|
842
|
+
Py_SET_TYPE(&descr_proto, &PyArrayDescr_Type);
|
|
843
|
+
descr_proto.typeobj = type;
|
|
830
844
|
|
|
831
|
-
TypeDescriptor<T>::npy_type =
|
|
832
|
-
|
|
833
|
-
if (TypeDescriptor<T>::Dtype() < 0) {
|
|
845
|
+
TypeDescriptor<T>::npy_type = PyArray_RegisterDataType(&descr_proto);
|
|
846
|
+
if (TypeDescriptor<T>::npy_type < 0) {
|
|
834
847
|
return false;
|
|
835
848
|
}
|
|
849
|
+
// TODO(phawkins): We intentionally leak the pointer to the descriptor.
|
|
850
|
+
// Implement a better module destructor to handle this.
|
|
851
|
+
Int4TypeDescriptor<T>::npy_descr =
|
|
852
|
+
PyArray_DescrFromType(TypeDescriptor<T>::npy_type);
|
|
836
853
|
|
|
837
854
|
Safe_PyObjectPtr typeDict_obj =
|
|
838
855
|
make_safe(PyObject_GetAttrString(numpy, "sctypeDict"));
|
|
@@ -847,7 +864,7 @@ bool RegisterInt4Dtype(PyObject* numpy) {
|
|
|
847
864
|
// Support dtype(type_name)
|
|
848
865
|
if (PyObject_SetAttrString(
|
|
849
866
|
TypeDescriptor<T>::type_ptr, "dtype",
|
|
850
|
-
reinterpret_cast<PyObject*>(
|
|
867
|
+
reinterpret_cast<PyObject*>(Int4TypeDescriptor<T>::npy_descr)) < 0) {
|
|
851
868
|
return false;
|
|
852
869
|
}
|
|
853
870
|
|
|
@@ -856,4 +873,8 @@ bool RegisterInt4Dtype(PyObject* numpy) {
|
|
|
856
873
|
|
|
857
874
|
} // namespace ml_dtypes
|
|
858
875
|
|
|
876
|
+
#if NPY_ABI_VERSION < 0x02000000
|
|
877
|
+
#undef PyArray_DescrProto
|
|
878
|
+
#endif
|
|
879
|
+
|
|
859
880
|
#endif // ML_DTYPES_INT4_NUMPY_H_
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#ifndef THIRD_PARTY_PY_ML_DTYPES_INCLUDE_INT4_H_
|
|
2
|
+
#define THIRD_PARTY_PY_ML_DTYPES_INCLUDE_INT4_H_
|
|
3
|
+
|
|
4
|
+
// IWYU pragma: begin_exports
|
|
5
|
+
#include "include/intn.h" // INLINER_FORWARD_TO
|
|
6
|
+
// IWYU pragma: end_exports
|
|
7
|
+
|
|
8
|
+
#endif // THIRD_PARTY_PY_ML_DTYPES_INCLUDE_INT4_H_
|