Revert D19320493: Javadoc changes

Test Plan: revert-hammer

Differential Revision:
D19320493

Original commit changeset: cc76b2a2acbe

fbshipit-source-id: 3b36dd2d2591acc60a06a421dd625c21adbe578a
This commit is contained in:
Bram Wasti 2020-01-09 14:21:24 -08:00 committed by Facebook Github Bot
parent 700d1c5cbc
commit 021e1e20c1
17 changed files with 1206 additions and 3 deletions

View File

@ -2,4 +2,4 @@ sphinx
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
sphinxcontrib.katex
matplotlib
javasphinx

View File

@ -46,6 +46,7 @@ extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.napoleon',

View File

@ -17,13 +17,13 @@ PyTorch is an optimized tensor library for deep learning using GPUs and CPUs.
notes/*
PyTorch on XLA Devices <http://pytorch.org/xla/>
.. toctree::
:maxdepth: 1
:caption: Language Bindings
C++ API <https://pytorch.org/cppdocs/>
Javadoc <https://pytorch.org/javadoc/>
packages
.. toctree::
:maxdepth: 1

View File

@ -0,0 +1,67 @@
DType
=====
.. java:package:: org.pytorch
:noindex:
.. java:type:: public enum DType
Codes representing tensor data types.
Enum Constants
--------------
FLOAT32
^^^^^^^
.. java:field:: public static final DType FLOAT32
:outertype: DType
Code for dtype torch.float32. \ :java:ref:`Tensor.dtype()`\
FLOAT64
^^^^^^^
.. java:field:: public static final DType FLOAT64
:outertype: DType
Code for dtype torch.float64. \ :java:ref:`Tensor.dtype()`\
INT32
^^^^^
.. java:field:: public static final DType INT32
:outertype: DType
Code for dtype torch.int32. \ :java:ref:`Tensor.dtype()`\
INT64
^^^^^
.. java:field:: public static final DType INT64
:outertype: DType
Code for dtype torch.int64. \ :java:ref:`Tensor.dtype()`\
INT8
^^^^
.. java:field:: public static final DType INT8
:outertype: DType
Code for dtype torch.int8. \ :java:ref:`Tensor.dtype()`\
UINT8
^^^^^
.. java:field:: public static final DType UINT8
:outertype: DType
Code for dtype torch.uint8. \ :java:ref:`Tensor.dtype()`\
Fields
------
jniCode
^^^^^^^
.. java:field:: final int jniCode
:outertype: DType

View File

@ -0,0 +1,297 @@
.. java:import:: java.util Locale
.. java:import:: java.util Map
IValue
======
.. java:package:: org.pytorch
:noindex:
.. java:type:: public class IValue
Java representation of a TorchScript value, which is implemented as tagged union that can be one of the supported types: https://pytorch.org/docs/stable/jit.html#types .
Calling \ ``toX``\ methods for inappropriate types will throw \ :java:ref:`IllegalStateException`\ .
\ ``IValue``\ objects are constructed with \ ``IValue.from(value)``\ , \ ``IValue.tupleFrom(value1, value2, ...)``\ , \ ``IValue.listFrom(value1, value2, ...)``\ , or one of the \ ``dict``\ methods, depending on the key type.
Data is retrieved from \ ``IValue``\ objects with the \ ``toX()``\ methods. Note that \ ``str``\ -type IValues must be extracted with \ :java:ref:`toStr()`\ , rather than \ :java:ref:`toString()`\ .
\ ``IValue``\ objects may retain references to objects passed into their constructors, and may return references to their internal state from \ ``toX()``\ .
Methods
-------
dictLongKeyFrom
^^^^^^^^^^^^^^^
.. java:method:: public static IValue dictLongKeyFrom(Map<Long, IValue> map)
:outertype: IValue
Creates a new \ ``IValue``\ of type \ ``Dict[int, V]``\ .
dictStringKeyFrom
^^^^^^^^^^^^^^^^^
.. java:method:: public static IValue dictStringKeyFrom(Map<String, IValue> map)
:outertype: IValue
Creates a new \ ``IValue``\ of type \ ``Dict[str, V]``\ .
from
^^^^
.. java:method:: public static IValue from(Tensor tensor)
:outertype: IValue
Creates a new \ ``IValue``\ of type \ ``Tensor``\ .
from
^^^^
.. java:method:: public static IValue from(boolean value)
:outertype: IValue
Creates a new \ ``IValue``\ of type \ ``bool``\ .
from
^^^^
.. java:method:: public static IValue from(long value)
:outertype: IValue
Creates a new \ ``IValue``\ of type \ ``int``\ .
from
^^^^
.. java:method:: public static IValue from(double value)
:outertype: IValue
Creates a new \ ``IValue``\ of type \ ``float``\ .
from
^^^^
.. java:method:: public static IValue from(String value)
:outertype: IValue
Creates a new \ ``IValue``\ of type \ ``str``\ .
isBool
^^^^^^
.. java:method:: public boolean isBool()
:outertype: IValue
isBoolList
^^^^^^^^^^
.. java:method:: public boolean isBoolList()
:outertype: IValue
isDictLongKey
^^^^^^^^^^^^^
.. java:method:: public boolean isDictLongKey()
:outertype: IValue
isDictStringKey
^^^^^^^^^^^^^^^
.. java:method:: public boolean isDictStringKey()
:outertype: IValue
isDouble
^^^^^^^^
.. java:method:: public boolean isDouble()
:outertype: IValue
isDoubleList
^^^^^^^^^^^^
.. java:method:: public boolean isDoubleList()
:outertype: IValue
isList
^^^^^^
.. java:method:: public boolean isList()
:outertype: IValue
isLong
^^^^^^
.. java:method:: public boolean isLong()
:outertype: IValue
isLongList
^^^^^^^^^^
.. java:method:: public boolean isLongList()
:outertype: IValue
isNull
^^^^^^
.. java:method:: public boolean isNull()
:outertype: IValue
isString
^^^^^^^^
.. java:method:: public boolean isString()
:outertype: IValue
isTensor
^^^^^^^^
.. java:method:: public boolean isTensor()
:outertype: IValue
isTensorList
^^^^^^^^^^^^
.. java:method:: public boolean isTensorList()
:outertype: IValue
isTuple
^^^^^^^
.. java:method:: public boolean isTuple()
:outertype: IValue
listFrom
^^^^^^^^
.. java:method:: public static IValue listFrom(boolean... list)
:outertype: IValue
Creates a new \ ``IValue``\ of type \ ``List[bool]``\ .
listFrom
^^^^^^^^
.. java:method:: public static IValue listFrom(long... list)
:outertype: IValue
Creates a new \ ``IValue``\ of type \ ``List[int]``\ .
listFrom
^^^^^^^^
.. java:method:: public static IValue listFrom(double... list)
:outertype: IValue
Creates a new \ ``IValue``\ of type \ ``List[float]``\ .
listFrom
^^^^^^^^
.. java:method:: public static IValue listFrom(Tensor... list)
:outertype: IValue
Creates a new \ ``IValue``\ of type \ ``List[Tensor]``\ .
listFrom
^^^^^^^^
.. java:method:: public static IValue listFrom(IValue... array)
:outertype: IValue
Creates a new \ ``IValue``\ of type \ ``List[T]``\ . All elements must have the same type.
optionalNull
^^^^^^^^^^^^
.. java:method:: public static IValue optionalNull()
:outertype: IValue
Creates a new \ ``IValue``\ of type \ ``Optional``\ that contains no value.
toBool
^^^^^^
.. java:method:: public boolean toBool()
:outertype: IValue
toBoolList
^^^^^^^^^^
.. java:method:: public boolean[] toBoolList()
:outertype: IValue
toDictLongKey
^^^^^^^^^^^^^
.. java:method:: public Map<Long, IValue> toDictLongKey()
:outertype: IValue
toDictStringKey
^^^^^^^^^^^^^^^
.. java:method:: public Map<String, IValue> toDictStringKey()
:outertype: IValue
toDouble
^^^^^^^^
.. java:method:: public double toDouble()
:outertype: IValue
toDoubleList
^^^^^^^^^^^^
.. java:method:: public double[] toDoubleList()
:outertype: IValue
toList
^^^^^^
.. java:method:: public IValue[] toList()
:outertype: IValue
toLong
^^^^^^
.. java:method:: public long toLong()
:outertype: IValue
toLongList
^^^^^^^^^^
.. java:method:: public long[] toLongList()
:outertype: IValue
toStr
^^^^^
.. java:method:: public String toStr()
:outertype: IValue
toTensor
^^^^^^^^
.. java:method:: public Tensor toTensor()
:outertype: IValue
toTensorList
^^^^^^^^^^^^
.. java:method:: public Tensor[] toTensorList()
:outertype: IValue
toTuple
^^^^^^^
.. java:method:: public IValue[] toTuple()
:outertype: IValue
tupleFrom
^^^^^^^^^
.. java:method:: public static IValue tupleFrom(IValue... array)
:outertype: IValue
Creates a new \ ``IValue``\ of type \ ``Tuple[T0, T1, ...]``\ .

View File

@ -0,0 +1,55 @@
.. java:import:: com.facebook.jni HybridData
Module
======
.. java:package:: org.pytorch
:noindex:
.. java:type:: public class Module
Java wrapper for torch::jit::script::Module.
Methods
-------
destroy
^^^^^^^
.. java:method:: public void destroy()
:outertype: Module
Explicitly destroys the native torch::jit::script::Module. Calling this method is not required, as the native object will be destroyed when this object is garbage-collected. However, the timing of garbage collection is not guaranteed, so proactively calling \ ``destroy``\ can free memory more quickly. See \ :java:ref:`com.facebook.jni.HybridData.resetNative`\ .
forward
^^^^^^^
.. java:method:: public IValue forward(IValue... inputs)
:outertype: Module
Runs the 'forward' method of this module with the specified arguments.
:param inputs: arguments for the TorchScript module's 'forward' method.
:return: return value from the 'forward' method.
load
^^^^
.. java:method:: public static Module load(String modelPath)
:outertype: Module
Loads a serialized TorchScript module from the specified path on the disk.
:param modelPath: path to file that contains the serialized TorchScript module.
:return: new \ :java:ref:`org.pytorch.Module`\ object which owns torch::jit::script::Module.
runMethod
^^^^^^^^^
.. java:method:: public IValue runMethod(String methodName, IValue... inputs)
:outertype: Module
Runs the specified method of this module with the specified arguments.
:param methodName: name of the TorchScript method to run.
:param inputs: arguments that will be passed to TorchScript method.
:return: return value from the method.

View File

@ -0,0 +1,60 @@
.. java:import:: java.nio Buffer
.. java:import:: java.nio ByteBuffer
.. java:import:: java.nio ByteOrder
.. java:import:: java.nio DoubleBuffer
.. java:import:: java.nio FloatBuffer
.. java:import:: java.nio IntBuffer
.. java:import:: java.nio LongBuffer
.. java:import:: java.util Arrays
.. java:import:: java.util Locale
Tensor.Tensor_float32
=====================
.. java:package:: org.pytorch
:noindex:
.. java:type:: static class Tensor_float32 extends Tensor
:outertype: Tensor
Constructors
------------
Tensor_float32
^^^^^^^^^^^^^^
.. java:constructor:: Tensor_float32(FloatBuffer data, long[] shape)
:outertype: Tensor.Tensor_float32
Methods
-------
dtype
^^^^^
.. java:method:: @Override public DType dtype()
:outertype: Tensor.Tensor_float32
getDataAsFloatArray
^^^^^^^^^^^^^^^^^^^
.. java:method:: @Override public float[] getDataAsFloatArray()
:outertype: Tensor.Tensor_float32
getRawDataBuffer
^^^^^^^^^^^^^^^^
.. java:method:: @Override Buffer getRawDataBuffer()
:outertype: Tensor.Tensor_float32
toString
^^^^^^^^
.. java:method:: @Override public String toString()
:outertype: Tensor.Tensor_float32

View File

@ -0,0 +1,52 @@
.. java:import:: java.nio Buffer
.. java:import:: java.nio ByteBuffer
.. java:import:: java.nio ByteOrder
.. java:import:: java.nio DoubleBuffer
.. java:import:: java.nio FloatBuffer
.. java:import:: java.nio IntBuffer
.. java:import:: java.nio LongBuffer
.. java:import:: java.util Arrays
.. java:import:: java.util Locale
Tensor.Tensor_float64
=====================
.. java:package:: org.pytorch
:noindex:
.. java:type:: static class Tensor_float64 extends Tensor
:outertype: Tensor
Methods
-------
dtype
^^^^^
.. java:method:: @Override public DType dtype()
:outertype: Tensor.Tensor_float64
getDataAsDoubleArray
^^^^^^^^^^^^^^^^^^^^
.. java:method:: @Override public double[] getDataAsDoubleArray()
:outertype: Tensor.Tensor_float64
getRawDataBuffer
^^^^^^^^^^^^^^^^
.. java:method:: @Override Buffer getRawDataBuffer()
:outertype: Tensor.Tensor_float64
toString
^^^^^^^^
.. java:method:: @Override public String toString()
:outertype: Tensor.Tensor_float64

View File

@ -0,0 +1,52 @@
.. java:import:: java.nio Buffer
.. java:import:: java.nio ByteBuffer
.. java:import:: java.nio ByteOrder
.. java:import:: java.nio DoubleBuffer
.. java:import:: java.nio FloatBuffer
.. java:import:: java.nio IntBuffer
.. java:import:: java.nio LongBuffer
.. java:import:: java.util Arrays
.. java:import:: java.util Locale
Tensor.Tensor_int32
===================
.. java:package:: org.pytorch
:noindex:
.. java:type:: static class Tensor_int32 extends Tensor
:outertype: Tensor
Methods
-------
dtype
^^^^^
.. java:method:: @Override public DType dtype()
:outertype: Tensor.Tensor_int32
getDataAsIntArray
^^^^^^^^^^^^^^^^^
.. java:method:: @Override public int[] getDataAsIntArray()
:outertype: Tensor.Tensor_int32
getRawDataBuffer
^^^^^^^^^^^^^^^^
.. java:method:: @Override Buffer getRawDataBuffer()
:outertype: Tensor.Tensor_int32
toString
^^^^^^^^
.. java:method:: @Override public String toString()
:outertype: Tensor.Tensor_int32

View File

@ -0,0 +1,52 @@
.. java:import:: java.nio Buffer
.. java:import:: java.nio ByteBuffer
.. java:import:: java.nio ByteOrder
.. java:import:: java.nio DoubleBuffer
.. java:import:: java.nio FloatBuffer
.. java:import:: java.nio IntBuffer
.. java:import:: java.nio LongBuffer
.. java:import:: java.util Arrays
.. java:import:: java.util Locale
Tensor.Tensor_int64
===================
.. java:package:: org.pytorch
:noindex:
.. java:type:: static class Tensor_int64 extends Tensor
:outertype: Tensor
Methods
-------
dtype
^^^^^
.. java:method:: @Override public DType dtype()
:outertype: Tensor.Tensor_int64
getDataAsLongArray
^^^^^^^^^^^^^^^^^^
.. java:method:: @Override public long[] getDataAsLongArray()
:outertype: Tensor.Tensor_int64
getRawDataBuffer
^^^^^^^^^^^^^^^^
.. java:method:: @Override Buffer getRawDataBuffer()
:outertype: Tensor.Tensor_int64
toString
^^^^^^^^
.. java:method:: @Override public String toString()
:outertype: Tensor.Tensor_int64

View File

@ -0,0 +1,52 @@
.. java:import:: java.nio Buffer
.. java:import:: java.nio ByteBuffer
.. java:import:: java.nio ByteOrder
.. java:import:: java.nio DoubleBuffer
.. java:import:: java.nio FloatBuffer
.. java:import:: java.nio IntBuffer
.. java:import:: java.nio LongBuffer
.. java:import:: java.util Arrays
.. java:import:: java.util Locale
Tensor.Tensor_int8
==================
.. java:package:: org.pytorch
:noindex:
.. java:type:: static class Tensor_int8 extends Tensor
:outertype: Tensor
Methods
-------
dtype
^^^^^
.. java:method:: @Override public DType dtype()
:outertype: Tensor.Tensor_int8
getDataAsByteArray
^^^^^^^^^^^^^^^^^^
.. java:method:: @Override public byte[] getDataAsByteArray()
:outertype: Tensor.Tensor_int8
getRawDataBuffer
^^^^^^^^^^^^^^^^
.. java:method:: @Override Buffer getRawDataBuffer()
:outertype: Tensor.Tensor_int8
toString
^^^^^^^^
.. java:method:: @Override public String toString()
:outertype: Tensor.Tensor_int8

View File

@ -0,0 +1,52 @@
.. java:import:: java.nio Buffer
.. java:import:: java.nio ByteBuffer
.. java:import:: java.nio ByteOrder
.. java:import:: java.nio DoubleBuffer
.. java:import:: java.nio FloatBuffer
.. java:import:: java.nio IntBuffer
.. java:import:: java.nio LongBuffer
.. java:import:: java.util Arrays
.. java:import:: java.util Locale
Tensor.Tensor_uint8
===================
.. java:package:: org.pytorch
:noindex:
.. java:type:: static class Tensor_uint8 extends Tensor
:outertype: Tensor
Methods
-------
dtype
^^^^^
.. java:method:: @Override public DType dtype()
:outertype: Tensor.Tensor_uint8
getDataAsUnsignedByteArray
^^^^^^^^^^^^^^^^^^^^^^^^^^
.. java:method:: @Override public byte[] getDataAsUnsignedByteArray()
:outertype: Tensor.Tensor_uint8
getRawDataBuffer
^^^^^^^^^^^^^^^^
.. java:method:: @Override Buffer getRawDataBuffer()
:outertype: Tensor.Tensor_uint8
toString
^^^^^^^^
.. java:method:: @Override public String toString()
:outertype: Tensor.Tensor_uint8

View File

@ -0,0 +1,315 @@
.. java:import:: java.nio Buffer
.. java:import:: java.nio ByteBuffer
.. java:import:: java.nio ByteOrder
.. java:import:: java.nio DoubleBuffer
.. java:import:: java.nio FloatBuffer
.. java:import:: java.nio IntBuffer
.. java:import:: java.nio LongBuffer
.. java:import:: java.util Arrays
.. java:import:: java.util Locale
Tensor
======
.. java:package:: org.pytorch
:noindex:
.. java:type:: public abstract class Tensor
Representation of a Tensor. Behavior is similar to PyTorch's tensor objects.
Most tensors will be constructed as \ ``Tensor.fromBlob(data, shape)``\ , where \ ``data``\ can be an array or a direct \ :java:ref:`Buffer`\ (of the proper subclass). Helper methods are provided to allocate buffers properly.
To access Tensor data, see \ :java:ref:`dtype()`\ , \ :java:ref:`shape()`\ , and various \ ``getDataAs*``\ methods.
When constructing \ ``Tensor``\ objects with \ ``data``\ as an array, it is not specified whether this data is is copied or retained as a reference so it is recommended not to modify it after constructing. \ ``data``\ passed as a \ :java:ref:`Buffer`\ is not copied, so it can be modified between \ :java:ref:`Module`\ calls to avoid reallocation. Data retrieved from \ ``Tensor``\ objects may be copied or may be a reference to the \ ``Tensor``\ 's internal data buffer. \ ``shape``\ is always copied.
Methods
-------
allocateByteBuffer
^^^^^^^^^^^^^^^^^^
.. java:method:: public static ByteBuffer allocateByteBuffer(int numElements)
:outertype: Tensor
Allocates a new direct \ :java:ref:`java.nio.ByteBuffer`\ with native byte order with specified capacity that can be used in \ :java:ref:`Tensor.fromBlob(ByteBuffer,long[])`\ , \ :java:ref:`Tensor.fromBlobUnsigned(ByteBuffer,long[])`\ .
:param numElements: capacity (number of elements) of result buffer.
allocateDoubleBuffer
^^^^^^^^^^^^^^^^^^^^
.. java:method:: public static DoubleBuffer allocateDoubleBuffer(int numElements)
:outertype: Tensor
Allocates a new direct \ :java:ref:`java.nio.DoubleBuffer`\ with native byte order with specified capacity that can be used in \ :java:ref:`Tensor.fromBlob(DoubleBuffer,long[])`\ .
:param numElements: capacity (number of elements) of result buffer.
allocateFloatBuffer
^^^^^^^^^^^^^^^^^^^
.. java:method:: public static FloatBuffer allocateFloatBuffer(int numElements)
:outertype: Tensor
Allocates a new direct \ :java:ref:`java.nio.FloatBuffer`\ with native byte order with specified capacity that can be used in \ :java:ref:`Tensor.fromBlob(FloatBuffer,long[])`\ .
:param numElements: capacity (number of elements) of result buffer.
allocateIntBuffer
^^^^^^^^^^^^^^^^^
.. java:method:: public static IntBuffer allocateIntBuffer(int numElements)
:outertype: Tensor
Allocates a new direct \ :java:ref:`java.nio.IntBuffer`\ with native byte order with specified capacity that can be used in \ :java:ref:`Tensor.fromBlob(IntBuffer,long[])`\ .
:param numElements: capacity (number of elements) of result buffer.
allocateLongBuffer
^^^^^^^^^^^^^^^^^^
.. java:method:: public static LongBuffer allocateLongBuffer(int numElements)
:outertype: Tensor
Allocates a new direct \ :java:ref:`java.nio.LongBuffer`\ with native byte order with specified capacity that can be used in \ :java:ref:`Tensor.fromBlob(LongBuffer,long[])`\ .
:param numElements: capacity (number of elements) of result buffer.
dtype
^^^^^
.. java:method:: public abstract DType dtype()
:outertype: Tensor
:return: data type of this tensor.
dtypeJniCode
^^^^^^^^^^^^
.. java:method:: int dtypeJniCode()
:outertype: Tensor
fromBlob
^^^^^^^^
.. java:method:: public static Tensor fromBlob(byte[] data, long[] shape)
:outertype: Tensor
Creates a new Tensor instance with dtype torch.int8 with specified shape and data as array of bytes.
:param data: Tensor elements
:param shape: Tensor shape
fromBlob
^^^^^^^^
.. java:method:: public static Tensor fromBlob(int[] data, long[] shape)
:outertype: Tensor
Creates a new Tensor instance with dtype torch.int32 with specified shape and data as array of ints.
:param data: Tensor elements
:param shape: Tensor shape
fromBlob
^^^^^^^^
.. java:method:: public static Tensor fromBlob(float[] data, long[] shape)
:outertype: Tensor
Creates a new Tensor instance with dtype torch.float32 with specified shape and data as array of floats.
:param data: Tensor elements
:param shape: Tensor shape
fromBlob
^^^^^^^^
.. java:method:: public static Tensor fromBlob(long[] data, long[] shape)
:outertype: Tensor
Creates a new Tensor instance with dtype torch.int64 with specified shape and data as array of longs.
:param data: Tensor elements
:param shape: Tensor shape
fromBlob
^^^^^^^^
.. java:method:: public static Tensor fromBlob(long[] shape, double[] data)
:outertype: Tensor
Creates a new Tensor instance with dtype torch.float64 with specified shape and data as array of doubles.
:param shape: Tensor shape
:param data: Tensor elements
fromBlob
^^^^^^^^
.. java:method:: public static Tensor fromBlob(ByteBuffer data, long[] shape)
:outertype: Tensor
Creates a new Tensor instance with dtype torch.int8 with specified shape and data.
:param data: Direct buffer with native byte order that contains \ ``Tensor.numel(shape)``\ elements. The buffer is used directly without copying, and changes to its content will change the tensor.
:param shape: Tensor shape
fromBlob
^^^^^^^^
.. java:method:: public static Tensor fromBlob(IntBuffer data, long[] shape)
:outertype: Tensor
Creates a new Tensor instance with dtype torch.int32 with specified shape and data.
:param data: Direct buffer with native byte order that contains \ ``Tensor.numel(shape)``\ elements. The buffer is used directly without copying, and changes to its content will change the tensor.
:param shape: Tensor shape
fromBlob
^^^^^^^^
.. java:method:: public static Tensor fromBlob(FloatBuffer data, long[] shape)
:outertype: Tensor
Creates a new Tensor instance with dtype torch.float32 with specified shape and data.
:param data: Direct buffer with native byte order that contains \ ``Tensor.numel(shape)``\ elements. The buffer is used directly without copying, and changes to its content will change the tensor.
:param shape: Tensor shape
fromBlob
^^^^^^^^
.. java:method:: public static Tensor fromBlob(LongBuffer data, long[] shape)
:outertype: Tensor
Creates a new Tensor instance with dtype torch.int64 with specified shape and data.
:param data: Direct buffer with native byte order that contains \ ``Tensor.numel(shape)``\ elements. The buffer is used directly without copying, and changes to its content will change the tensor.
:param shape: Tensor shape
fromBlob
^^^^^^^^
.. java:method:: public static Tensor fromBlob(DoubleBuffer data, long[] shape)
:outertype: Tensor
Creates a new Tensor instance with dtype torch.float64 with specified shape and data.
:param data: Direct buffer with native byte order that contains \ ``Tensor.numel(shape)``\ elements. The buffer is used directly without copying, and changes to its content will change the tensor.
:param shape: Tensor shape
fromBlobUnsigned
^^^^^^^^^^^^^^^^
.. java:method:: public static Tensor fromBlobUnsigned(byte[] data, long[] shape)
:outertype: Tensor
Creates a new Tensor instance with dtype torch.uint8 with specified shape and data as array of bytes.
:param data: Tensor elements
:param shape: Tensor shape
fromBlobUnsigned
^^^^^^^^^^^^^^^^
.. java:method:: public static Tensor fromBlobUnsigned(ByteBuffer data, long[] shape)
:outertype: Tensor
Creates a new Tensor instance with dtype torch.uint8 with specified shape and data.
:param data: Direct buffer with native byte order that contains \ ``Tensor.numel(shape)``\ elements. The buffer is used directly without copying, and changes to its content will change the tensor.
:param shape: Tensor shape
getDataAsByteArray
^^^^^^^^^^^^^^^^^^
.. java:method:: public byte[] getDataAsByteArray()
:outertype: Tensor
:throws IllegalStateException: if it is called for a non-int8 tensor.
:return: a Java byte array that contains the tensor data. This may be a copy or reference.
getDataAsDoubleArray
^^^^^^^^^^^^^^^^^^^^
.. java:method:: public double[] getDataAsDoubleArray()
:outertype: Tensor
:throws IllegalStateException: if it is called for a non-float64 tensor.
:return: a Java double array that contains the tensor data. This may be a copy or reference.
getDataAsFloatArray
^^^^^^^^^^^^^^^^^^^
.. java:method:: public float[] getDataAsFloatArray()
:outertype: Tensor
:throws IllegalStateException: if it is called for a non-float32 tensor.
:return: a Java float array that contains the tensor data. This may be a copy or reference.
getDataAsIntArray
^^^^^^^^^^^^^^^^^
.. java:method:: public int[] getDataAsIntArray()
:outertype: Tensor
:throws IllegalStateException: if it is called for a non-int32 tensor.
:return: a Java int array that contains the tensor data. This may be a copy or reference.
getDataAsLongArray
^^^^^^^^^^^^^^^^^^
.. java:method:: public long[] getDataAsLongArray()
:outertype: Tensor
:throws IllegalStateException: if it is called for a non-int64 tensor.
:return: a Java long array that contains the tensor data. This may be a copy or reference.
getDataAsUnsignedByteArray
^^^^^^^^^^^^^^^^^^^^^^^^^^
.. java:method:: public byte[] getDataAsUnsignedByteArray()
:outertype: Tensor
:throws IllegalStateException: if it is called for a non-uint8 tensor.
:return: a Java byte array that contains the tensor data. This may be a copy or reference.
getRawDataBuffer
^^^^^^^^^^^^^^^^
.. java:method:: Buffer getRawDataBuffer()
:outertype: Tensor
numel
^^^^^
.. java:method:: public long numel()
:outertype: Tensor
Returns the number of elements in this tensor.
numel
^^^^^
.. java:method:: public static long numel(long[] shape)
:outertype: Tensor
Calculates the number of elements in a tensor with the specified shape.
shape
^^^^^
.. java:method:: public long[] shape()
:outertype: Tensor
Returns the shape of this tensor. (The array is a fresh copy.)

View File

@ -0,0 +1,114 @@
.. java:import:: android.graphics Bitmap
.. java:import:: android.graphics ImageFormat
.. java:import:: android.media Image
.. java:import:: org.pytorch Tensor
.. java:import:: java.nio ByteBuffer
.. java:import:: java.nio FloatBuffer
.. java:import:: java.util Locale
TensorImageUtils
================
.. java:package:: org.pytorch.torchvision
:noindex:
.. java:type:: public final class TensorImageUtils
Contains utility functions for \ :java:ref:`org.pytorch.Tensor`\ creation from \ :java:ref:`android.graphics.Bitmap`\ or \ :java:ref:`android.media.Image`\ source.
Fields
------
TORCHVISION_NORM_MEAN_RGB
^^^^^^^^^^^^^^^^^^^^^^^^^
.. java:field:: public static float[] TORCHVISION_NORM_MEAN_RGB
:outertype: TensorImageUtils
TORCHVISION_NORM_STD_RGB
^^^^^^^^^^^^^^^^^^^^^^^^
.. java:field:: public static float[] TORCHVISION_NORM_STD_RGB
:outertype: TensorImageUtils
Methods
-------
bitmapToFloat32Tensor
^^^^^^^^^^^^^^^^^^^^^
.. java:method:: public static Tensor bitmapToFloat32Tensor(Bitmap bitmap, float[] normMeanRGB, float[] normStdRGB)
:outertype: TensorImageUtils
Creates new \ :java:ref:`org.pytorch.Tensor`\ from full \ :java:ref:`android.graphics.Bitmap`\ , normalized with specified in parameters mean and std.
:param normMeanRGB: means for RGB channels normalization, length must equal 3, RGB order
:param normStdRGB: standard deviation for RGB channels normalization, length must equal 3, RGB order
bitmapToFloat32Tensor
^^^^^^^^^^^^^^^^^^^^^
.. java:method:: public static Tensor bitmapToFloat32Tensor(Bitmap bitmap, int x, int y, int width, int height, float[] normMeanRGB, float[] normStdRGB)
:outertype: TensorImageUtils
Creates new \ :java:ref:`org.pytorch.Tensor`\ from specified area of \ :java:ref:`android.graphics.Bitmap`\ , normalized with specified in parameters mean and std.
:param bitmap: \ :java:ref:`android.graphics.Bitmap`\ as a source for Tensor data
:param x: - x coordinate of top left corner of bitmap's area
:param y: - y coordinate of top left corner of bitmap's area
:param width: - width of bitmap's area
:param height: - height of bitmap's area
:param normMeanRGB: means for RGB channels normalization, length must equal 3, RGB order
:param normStdRGB: standard deviation for RGB channels normalization, length must equal 3, RGB order
bitmapToFloatBuffer
^^^^^^^^^^^^^^^^^^^
.. java:method:: public static void bitmapToFloatBuffer(Bitmap bitmap, int x, int y, int width, int height, float[] normMeanRGB, float[] normStdRGB, FloatBuffer outBuffer, int outBufferOffset)
:outertype: TensorImageUtils
Writes tensor content from specified \ :java:ref:`android.graphics.Bitmap`\ , normalized with specified in parameters mean and std to specified \ :java:ref:`java.nio.FloatBuffer`\ with specified offset.
:param bitmap: \ :java:ref:`android.graphics.Bitmap`\ as a source for Tensor data
:param x: - x coordinate of top left corner of bitmap's area
:param y: - y coordinate of top left corner of bitmap's area
:param width: - width of bitmap's area
:param height: - height of bitmap's area
:param normMeanRGB: means for RGB channels normalization, length must equal 3, RGB order
:param normStdRGB: standard deviation for RGB channels normalization, length must equal 3, RGB order
imageYUV420CenterCropToFloat32Tensor
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. java:method:: public static Tensor imageYUV420CenterCropToFloat32Tensor(Image image, int rotateCWDegrees, int tensorWidth, int tensorHeight, float[] normMeanRGB, float[] normStdRGB)
:outertype: TensorImageUtils
Creates new \ :java:ref:`org.pytorch.Tensor`\ from specified area of \ :java:ref:`android.media.Image`\ , doing optional rotation, scaling (nearest) and center cropping.
:param image: \ :java:ref:`android.media.Image`\ as a source for Tensor data
:param rotateCWDegrees: Clockwise angle through which the input image needs to be rotated to be upright. Range of valid values: 0, 90, 180, 270
:param tensorWidth: return tensor width, must be positive
:param tensorHeight: return tensor height, must be positive
:param normMeanRGB: means for RGB channels normalization, length must equal 3, RGB order
:param normStdRGB: standard deviation for RGB channels normalization, length must equal 3, RGB order
imageYUV420CenterCropToFloatBuffer
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. java:method:: public static void imageYUV420CenterCropToFloatBuffer(Image image, int rotateCWDegrees, int tensorWidth, int tensorHeight, float[] normMeanRGB, float[] normStdRGB, FloatBuffer outBuffer, int outBufferOffset)
:outertype: TensorImageUtils
Writes tensor content from specified \ :java:ref:`android.media.Image`\ , doing optional rotation, scaling (nearest) and center cropping to specified \ :java:ref:`java.nio.FloatBuffer`\ with specified offset.
:param image: \ :java:ref:`android.media.Image`\ as a source for Tensor data
:param rotateCWDegrees: Clockwise angle through which the input image needs to be rotated to be upright. Range of valid values: 0, 90, 180, 270
:param tensorWidth: return tensor width, must be positive
:param tensorHeight: return tensor height, must be positive
:param normMeanRGB: means for RGB channels normalization, length must equal 3, RGB order
:param normStdRGB: standard deviation for RGB channels normalization, length must equal 3, RGB order
:param outBuffer: Output buffer, where tensor content will be written
:param outBufferOffset: Output buffer offset with which tensor content will be written

View File

@ -0,0 +1,18 @@
org.pytorch
===========
.. java:package:: org.pytorch
.. toctree::
:maxdepth: 1
DType
IValue
Module
Tensor
Tensor-Tensor_float32
Tensor-Tensor_float64
Tensor-Tensor_int32
Tensor-Tensor_int64
Tensor-Tensor_int8
Tensor-Tensor_uint8

View File

@ -0,0 +1,9 @@
rg.pytorch.torchvision
=======================
.. java:package:: org.pytorch.torchvision
.. toctree::
:maxdepth: 1
TensorImageUtils

7
docs/source/packages.rst Normal file
View File

@ -0,0 +1,7 @@
Javadoc
=======
.. toctree::
:maxdepth: 2
org/pytorch/package-index