diff --git a/docs/source/index.rst b/docs/source/index.rst index 6154bd2..9466514 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -10,8 +10,10 @@ Contents: .. toctree:: :maxdepth: 2 + :numbered: tensor + functions random nn diff --git a/docs/source/tensor.rst b/docs/source/tensor.rst index ccda1e5..4b1f8ba 100644 --- a/docs/source/tensor.rst +++ b/docs/source/tensor.rst @@ -1,6 +1,6 @@ -============== -Tensor library -============== +=============== +Tensor Overview +=============== .. |STEM| replace:: **STEM** .. |Tensor| replace:: ``Tensor`` @@ -8,17 +8,6 @@ Tensor library .. |Matrix| replace:: ``Matrix`` .. |Number| replace:: ``NumericType`` -Overview --------- -The documentation is split into several sections: - -* :ref:`Synopsis`: Quick overview of library -* :ref:`Storage`: Discussion of how Tensors are storage and how this affects acceleration -* :ref:`Tensor_Class`: Discussion of the Tensor class -* :ref:`Tensor_Construction`: Discussion of how to construct new instances of Tensors -* :ref:`Functions`: Discussion of operator overloading in |STEM|, the standard set of operators, and how to define new operators -* :ref:`Indexing`: Discussion of how to index into Tensors - .. _Synopsis: Synopsis @@ -212,194 +201,6 @@ To create a view of a |Tensor| with the ability to shuffle the dimensions, where init(_ tensor:Tensor, dimIndex:[Int]?=nil, view:StorageView?=nil, copy:Bool=false) - -Functions ---------- - -.. function:: add(lhs:Tensor, rhs:Tensor, result:Tensor) - add(lhs:Tensor, rhs:NumericType, result:Tensor) - add(lhs:NumericType, rhs:Tensor, result:Tensor) - +(lhs:Tensor, rhs:Tensor) -> Tensor - +(lhs:Tensor, rhs:NumericType) -> Tensor - +(lhs:NumericType, rhs:Tensor) -> Tensor - - Adds ``lhs`` and ``rhs`` together, either place results in ``result`` - or returning its value. If the shape of ``lhs`` and ``rhs`` do not - match, will either use ``broadcast`` to match their size, or use - optimized methods to accomplish the same purpose. - -.. function:: sub(lhs:Tensor, rhs:Tensor, result:Tensor) - sub(lhs:Tensor, rhs:NumericType, result:Tensor) - sub(lhs:NumericType, rhs:Tensor, result:Tensor) - -(lhs:Tensor, rhs:Tensor) -> Tensor - -(lhs:Tensor, rhs:NumericType) -> Tensor - -(lhs:NumericType, rhs:Tensor) -> Tensor - - Subtracts ``lhs`` from ``rhs``, either place results in ``result`` - or returning its value. If the shape of ``lhs`` and ``rhs`` do not - match, will either use ``broadcast`` to match their size, or use - optimized methods to accomplish the same purpose. - -.. function:: mul(lhs:Tensor, rhs:Tensor, result:Tensor) - mul(lhs:Tensor, rhs:NumericType, result:Tensor) - mul(lhs:NumericType, rhs:Tensor, result:Tensor) - *(lhs:Tensor, rhs:Tensor) -> Tensor - *(lhs:Tensor, rhs:NumericType) -> Tensor - *(lhs:NumericType, rhs:Tensor) -> Tensor - - Performs element-wise multiplication between ``lhs`` and ``rhs``, - either place results in ``result`` or returning its value. If the - shape of ``lhs`` and ``rhs`` do not match, will either use ``broadcast`` - to match their size, or use optimized methods to accomplish the same purpose. - -.. function:: div(lhs:Tensor, rhs:Tensor, result:Tensor) - div(lhs:Tensor, rhs:NumericType, result:Tensor) - div(lhs:NumericType, rhs:Tensor, result:Tensor) - /(lhs:Tensor, rhs:Tensor) -> Tensor - /(lhs:Tensor, rhs:NumericType) -> Tensor - /(lhs:NumericType, rhs:Tensor) -> Tensor - - Performs element-wise division between ``lhs`` and ``rhs``, - either place results in ``result`` or returning its value. If the - shape of ``lhs`` and ``rhs`` do not match, will either use ``broadcast`` - to match their size, or use optimized methods to accomplish the same purpose. - -.. function:: iadd(lhs:Tensor, rhs:Tensor) - iadd(lhs:Tensor, rhs:NumericType) - iadd(lhs:NumericType, rhs:Tensor) - +=(lhs:Tensor, rhs:Tensor) -> Tensor - +=(lhs:Tensor, rhs:NumericType) -> Tensor - +=(lhs:NumericType, rhs:Tensor) -> Tensor - - Adds ``lhs`` to ``rhs`` and stores result in ``lhs``, - either place results in ``result`` or returning its value. If the - shape of ``lhs`` and ``rhs`` do not match, will either use ``broadcast`` - to match their size, or use optimized methods to accomplish the same purpose. - -.. function:: isub(lhs:Tensor, rhs:Tensor) - isub(lhs:Tensor, rhs:NumericType) - isub(lhs:NumericType, rhs:Tensor) - -=(lhs:Tensor, rhs:Tensor) -> Tensor - -=(lhs:Tensor, rhs:NumericType) -> Tensor - -=(lhs:NumericType, rhs:Tensor) -> Tensor - - Subtracts ``rhs`` from ``lhs`` and stores result in ``lhs``, - either place results in ``result`` or returning its value. If the - shape of ``lhs`` and ``rhs`` do not match, will either use ``broadcast`` - to match their size, or use optimized methods to accomplish the same purpose. - -.. function:: imul(lhs:Tensor, rhs:Tensor) - imul(lhs:Tensor, rhs:NumericType) - imul(lhs:NumericType, rhs:Tensor) - *=(lhs:Tensor, rhs:Tensor) -> Tensor - *=(lhs:Tensor, rhs:NumericType) -> Tensor - *=(lhs:NumericType, rhs:Tensor) -> Tensor - - Multiplies ``lhs`` by ``rhs`` and stores result in ``lhs``, - either place results in ``result`` or returning its value. If the - shape of ``lhs`` and ``rhs`` do not match, will either use ``broadcast`` - to match their size, or use optimized methods to accomplish the same purpose. - -.. function:: idiv(lhs:Tensor, rhs:Tensor) - idiv(lhs:Tensor, rhs:NumericType) - idiv(lhs:NumericType, rhs:Tensor) - /=(lhs:Tensor, rhs:Tensor) -> Tensor - /=(lhs:Tensor, rhs:NumericType) -> Tensor - /=(lhs:NumericType, rhs:Tensor) -> Tensor - - Divides ``lhs`` by ``rhs`` and stores results in ``lhs``, - either place results in ``result`` or returning its value. If the - shape of ``lhs`` and ``rhs`` do not match, will either use ``broadcast`` - to match their size, or use optimized methods to accomplish the same purpose. - -.. function:: pow(lhs:Tensor, exp:NumericType) -> Tensor - **(lhs:Tensor, exp:NumericType) -> Tensor - - Raises every element of ``lhs`` by ``exp``. - -.. function:: exp(op::Tensor) -> Tensor - - Returns an element-wise exponentiation of ``op``. - -.. function:: dot(lhs:Tensor, rhs:Tensor) -> NumericType - ⊙(lhs:Tensor, rhs:Tensor) -> NumericType - - Returns the dot product between two vectors. - Both ``lhs`` and ``rhs`` must be vectors. - -.. function:: outer(lhs:Tensor, rhs:Tensor) -> NumericType - ⊗(lhs:Tensor, rhs:Tensor) -> NumericType - - Returns the outer product between two vectors. - Both ``lhs`` and ``rhs`` must be vectors. - -.. function:: abs(op:Tensor) -> Tensor - - Performs an elementwise ``abs`` on Tensor. - -.. function:: concat(op1:Tensor, op2:Tensor, ..., opN:Tensor, axis:Int) - - Concats N Tensors along ``axis``. - -.. function:: vstack(op1:Tensor, op2:Tensor) -> Tensor - - Returns a new Tensor that is a composite of ``op1`` and ``op2`` vertically - stacked. - -.. function:: hstack(op1:Tensor, op2:Tensor) -> Tensor - - Returns a new Tensor that is a composite of ``op1`` and ``op2`` horizontally - stacked. - -.. function:: broadcast(op1:Tensor, op2:Tensor) -> (Tensor, Tensor) - - Returns two Tensors of the same shape broadcasted from ``op1`` and ``op2``. - Need to go into much more detail about broadcasting. - -.. function:: reduce(op:Tensor, fn:(Tensor, Tensor) -> NumericType) -> NumericType - - Applies ``fn`` to elements of Tensor, returns a scalar. - -.. function:: sum(op:Tensor, axis:Int) -> Tensor - sum(op:Tensor) -> NumericType - - When ``axis`` is specified, sums ``op`` along ``axis`` and returns resulting - Tensor. When no ``axis`` is specified, returns entire Tensor summed. - -.. function:: max(op:Tensor, axis:Int) -> Tensor - max(op:Tensor) -> NumericType - - When ``axis`` is specified, find the maximum value ``op`` across ``axis`` - and returns resulting Tensor. When no ``axis`` is specified, returns - maximum value of entire Tensor. - -.. function:: min(op:Tensor, axis:Int) -> Tensor - min(op:Tensor) -> NumericType - - When ``axis`` is specified, find the minimum value ``op`` across ``axis`` - and returns resulting Tensor. When no ``axis`` is specified, returns - minimum value of entire Tensor. - -.. function:: fill(op:Tensor, value:NumericType) - - Sets all elements of ``op`` to ``value``. - -.. function:: copy(op:Tensor) -> Tensor - copy(from:Tensor, to:Tensor) - - First form creates a new Tensor and copies ``op`` into it. The second form - copies ``op`` into an already existing Tensor. - -.. function:: map(op:Tensor, fn:(NumericType) -> NumericType) -> Tensor - - Applies ``fn`` to each element of Tensor and returns resulting Tensor. - -TODO -+++++ -* norm(|Tensor|, axis: ``axis``) -* hist(|Tensor|, bins:``Int``) -> |Vector| -* isClose(``Tensor1``, ``Tensor2``) -> ``Bool`` - .. _Indexing: Indexing