Tensor operation: Generalized inner and outer products A broad class of blocked algorithms and patterns can be specified with a concise multi-index notation. The ``blockwise`` function applies an in-memory function across multiple blocks of multiple inputs in a variety of ways. Man
(
func,
out_ind,
*args,
name=None,
token=None,
dtype=None,
adjust_chunks=None,
new_axes=None,
align_arrays=True,
concatenate=None,
meta=None,
**kwargs,
)
| 15 | |
| 16 | |
| 17 | def blockwise( |
| 18 | func, |
| 19 | out_ind, |
| 20 | *args, |
| 21 | name=None, |
| 22 | token=None, |
| 23 | dtype=None, |
| 24 | adjust_chunks=None, |
| 25 | new_axes=None, |
| 26 | align_arrays=True, |
| 27 | concatenate=None, |
| 28 | meta=None, |
| 29 | **kwargs, |
| 30 | ): |
| 31 | """Tensor operation: Generalized inner and outer products |
| 32 | |
| 33 | A broad class of blocked algorithms and patterns can be specified with a |
| 34 | concise multi-index notation. The ``blockwise`` function applies an in-memory |
| 35 | function across multiple blocks of multiple inputs in a variety of ways. |
| 36 | Many dask.array operations are special cases of blockwise including |
| 37 | elementwise, broadcasting, reductions, tensordot, and transpose. |
| 38 | |
| 39 | Parameters |
| 40 | ---------- |
| 41 | func : callable |
| 42 | Function to apply to individual tuples of blocks |
| 43 | out_ind : iterable |
| 44 | Block pattern of the output, something like 'ijk' or (1, 2, 3) |
| 45 | *args : sequence of Array, index pairs |
| 46 | You may also pass literal arguments, accompanied by None index |
| 47 | e.g. (x, 'ij', y, 'jk', z, 'i', some_literal, None) |
| 48 | **kwargs : dict |
| 49 | Extra keyword arguments to pass to function |
| 50 | dtype : np.dtype |
| 51 | Datatype of resulting array. |
| 52 | concatenate : bool, keyword only |
| 53 | If true concatenate arrays along dummy indices, else provide lists |
| 54 | adjust_chunks : dict |
| 55 | Dictionary mapping index to function to be applied to chunk sizes |
| 56 | new_axes : dict, keyword only |
| 57 | New indexes and their dimension lengths |
| 58 | align_arrays: bool |
| 59 | Whether or not to align chunks along equally sized dimensions when |
| 60 | multiple arrays are provided. This allows for larger chunks in some |
| 61 | arrays to be broken into smaller ones that match chunk sizes in other |
| 62 | arrays such that they are compatible for block function mapping. If |
| 63 | this is false, then an error will be thrown if arrays do not already |
| 64 | have the same number of blocks in each dimension. |
| 65 | |
| 66 | Examples |
| 67 | -------- |
| 68 | 2D embarrassingly parallel operation from two arrays, x, and y. |
| 69 | |
| 70 | >>> import operator, numpy as np, dask.array as da |
| 71 | >>> x = da.from_array([[1, 2], |
| 72 | ... [3, 4]], chunks=(1, 2)) |
| 73 | >>> y = da.from_array([[10, 20], |
| 74 | ... [0, 0]]) |
searching dependent graphs…