You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/README.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,15 @@
1
-
Documentation
1
+
Documentation (WIP)
2
2
==========
3
3
4
+
**This documentation is a work in progress and may not contain all currently supported operations. Please check the functions signature and description for more info on it**
5
+
4
6
We use [`Sphinx`](https://www.sphinx-doc.org/en/master/index.html) for presenting our documentation.
5
7
6
8
To build the docs follow these steps:
7
9
8
-
1. Install the required sphinx packages and extensions from the [requirements.txt](../requirements.txt)
10
+
1. Install the required sphinx packages and extensions from the [dev-requirements.txt](../dev-requirements.txt)
9
11
```sh
10
-
pip install -r requirements.txt # install sphinx and its extensions
12
+
pip install -r dev-requirements.txt # install sphinx and its extensions
The 'af.constant()' function in the ArrayFire library is used to create arrays filled with a specific scalar value. This is a common operation when initializing arrays that will be updated or manipulated later in numerical computations. The function allows you to specify the dimensions and data type of the array, making it flexible for various use cases.
4
+
5
+
Function
6
+
--------
7
+
:literal:`af.constant()`
8
+
- Python interface to create a multi-dimensional array filled with a constant value.
9
+
10
+
Detailed Description
11
+
--------------------
12
+
The 'af.constant()' function creates an ArrayFire array where every element is initialized to the scalar (integer, floating point, or complex) value specified. It is particularly useful when you need to allocate space for an array but want to ensure that all values start from zero. This is often used in numerical methods, data processing, and initialization of variables in scientific computing.
13
+
14
+
You can specify the dimensions of the array as well as its data type. By default, the function creates arrays with a single precision floating-point type (float), but you can specify other data types if needed.
15
+
16
+
Function Documentation
17
+
----------------------
18
+
.. sidebar:: af.constant()
19
+
20
+
Syntax:
21
+
af.constant(scalar, dims, dtype)
22
+
23
+
Parameters:
24
+
'scalar': value that will be used to initialize
25
+
'dims': List of integers representing the dimensions of the array. You can specify multiple dimensions to create multi-dimensional arrays. For example, dim0 is the number of rows, and dim1 is the number of columns for a 2D array, etc.
26
+
'dtype': type that will be used to store the value internally. For example, af.int64 for signed 64-bit integer, af.float32 for 32-bit floating-point, and af.float64 for 64-bit floating-point
27
+
28
+
Returns:
29
+
An ArrayFire array with the specified dimensions and data type, where all elements are initialized to a scalar value.
The 'af.matmul()' function in ArrayFire performs general matrix multiplication. General Matrix multiplication is a fundamental operation in linear algebra and is widely used in various neural networks, scientific and engineering computations.
4
+
5
+
Function
6
+
--------
7
+
:literal:`af.gemm()`
8
+
- Python interface used to perform general matrix multiplication
9
+
10
+
Detailed Description
11
+
--------------------
12
+
The af.gemm() function computes the general matrix product of various input arrays. General Matrix multiplication is defined for three matrices A, B, C and two scalars alpha and beta as the operation alpha * A * B + beta * C where the number of columns in A is equal to the number of rows in B, while C has the same number of columns as B and same number of rows as A. The result is that is a weighted average of the matrix multiplication between A and B, and the accumulator matrix C.
'A': The first input array (matrix) to be multiplied.
23
+
'B': The second input array (matrix) to be multiplied.
24
+
'alpha': scalar that will be multiplied with the matrix multiplication. If not specified, this is taken to be one and the output is the same as 'matmul'
25
+
'beta': scalar that will be multiplied with the accumulator. If not specified, this is taken to be zero and the output is the same as 'matmul'
26
+
'C': The accumulator input array that will be added to the matrix multiplication. If not specified, this behaves as array full of zeros and the output is the same as 'matmul'
27
+
'lhs_opts': specifies any type of transpose operation should be executed on 'A' prior to the matrix multiplication
28
+
'rhs_opts': specifies any type of transpose operation should be executed on 'B' prior to the matrix multiplication
29
+
30
+
Returns:
31
+
An ArrayFire array representing the result of the general matrix multiplication:
The 'af.get_backend()' function in ArrayFire is used to retrieve the BackendType object associated with the ArrayFire context. This function provides information about the current active backend. It is useful for managing and querying the status of a compute backend in a multi-device environment.
4
+
5
+
Function
6
+
--------
7
+
:literal:`af.get_backend()`
8
+
- Python interface used to retrieve the BackendType object associated with the ArrayFire context.
9
+
10
+
Detailed Description
11
+
--------------------
12
+
The 'af.get_backend()' function provides access to the BackendType object in ArrayFire. The possible return values are BackendType.cpu, BackendType.opencl, BackendType.cuda, BackendType.oneapi. This function is particularly useful in environments where multiple devices are available and you need to query or manage backend-specific information.
13
+
14
+
Function Documentation
15
+
----------------------
16
+
.. sidebar:: af.get_backend()
17
+
18
+
Syntax:
19
+
device = af.get_backend()
20
+
21
+
Parameters:
22
+
This function does not take any parameters.
23
+
24
+
Returns:
25
+
An ArrayFire device object representing the current active backend in the ArrayFire context.
The 'af.iota()' function in ArrayFire generates a multi-dimensional ArrayFire array with values populated based on their linear index within the array, optionally tiling the result to create larger arrays.
4
+
5
+
Function
6
+
--------
7
+
:literal:`af.iota()`
8
+
- Python interface used to generate linear indices with optional tiling
9
+
10
+
Detailed Description
11
+
--------------------
12
+
The 'af.iota()' function is used to generate array of a sequence of indices starting at 0 and ending at (exclusive) the size of the 'shape' dimensions specified, filling the array in column major ordering to the 'shape' specified that it is then duplicated as specified by the 'tile_shape'.
13
+
14
+
Function Documentation
15
+
----------------------
16
+
.. sidebar:: af.iota()
17
+
18
+
Syntax:
19
+
af.iota(shape, tile_shape, dtype)
20
+
21
+
Parameters:
22
+
'shape': List of Integers specifying the dimensions for which the sequence of integers is generated.
23
+
'tile_shape': List of integers specifying the number of times the indices should be tiled in each dimension.
24
+
'dtype': type that will be used to store the value internally. For example, af.int64 for signed 64-bit integer, af.float32 for 32-bit floating-point, and af.float64 for 64-bit floating-point
25
+
26
+
Returns:
27
+
An ArrayFire array of linear indices with the dimensions 'shape * tile_shape'
The 'af.range()' function in ArrayFire generates a multi-dimensional ArrayFire array of linear indices using the length of a dimension as a range, tiling the indices on the other dimensions.
4
+
5
+
Function
6
+
--------
7
+
:literal:`af.range()`
8
+
- Python interface used to generate a range in one dimension while tiling other dimensions
9
+
10
+
Detailed Description
11
+
--------------------
12
+
The 'af.range()' function is used to generate array of a sequence of indices starting at 0 and ending at (exclusive) the size of the length of the dimension specified, then it is duplicated on the remaining dimensions specified by 'shape'.
13
+
14
+
Function Documentation
15
+
----------------------
16
+
.. sidebar:: af.range()
17
+
18
+
Syntax:
19
+
af.range(shape, tile_shape, dtype)
20
+
21
+
Parameters:
22
+
'shape': List of Integers specifying the dimensions for which the sequence of integers is generated.
23
+
'axis': Integer from 0 to 3 (by default 0) specifying the dimension to use to generate the linear index range
24
+
'dtype': type that will be used to store the value internally. For example, af.int64 for signed 64-bit integer, af.float32 for 32-bit floating-point, and af.float64 for 64-bit floating-point
25
+
26
+
Returns:
27
+
An ArrayFire array of linear indices along 'axis' with the dimensions of 'shape'
The 'af.set_backend()' function in ArrayFire is used to specify which backend will be used for subsequent ArrayFire operations. This is useful when working with multiple devices or GPUs to ensure that computations are directed to the desired hardware and software libraries.
4
+
5
+
Function
6
+
--------
7
+
:literal:`af.set_backend()`
8
+
- Python interface used to specify which backend will be used for subsequent arrayfire operations.
9
+
10
+
Detailed Description
11
+
--------------------
12
+
The 'af.set_backend()' function sets the backend for ArrayFire operations. By default, ArrayFire uses the first available backend in order of priority: 'cuda', 'opencl', 'oneapi', 'cpu' from highest to lowest priority. When you have multiple GPUs or devices, you can use this function to select which backend ArrayFire should use for subsequent operations.
13
+
Note that previous instantiated af.Array's or results from functions before the backend has been set will not be migrated to the new backend and device.
14
+
15
+
Function Documentation
16
+
----------------------
17
+
.. sidebar:: af.set_backend()
18
+
19
+
Syntax:
20
+
af.set_backend(backend)
21
+
22
+
Parameters:
23
+
'backend': af.BackendType value that corresponds to the ArrayFire backend to be set. Available values are af.BackendType.cuda, af.BackendType.opencl, af.BackendType.oneapi, and af.BackendType.cpu
0 commit comments