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,
)
| 692 | |
| 693 | |
| 694 | def blockwise( |
| 695 | func, |
| 696 | out_ind, |
| 697 | *args, |
| 698 | name=None, |
| 699 | token=None, |
| 700 | dtype=None, |
| 701 | adjust_chunks=None, |
| 702 | new_axes=None, |
| 703 | align_arrays=True, |
| 704 | concatenate=None, |
| 705 | meta=None, |
| 706 | **kwargs, |
| 707 | ): |
| 708 | """Tensor operation: Generalized inner and outer products |
| 709 | |
| 710 | A broad class of blocked algorithms and patterns can be specified with a |
| 711 | concise multi-index notation. The ``blockwise`` function applies an in-memory |
| 712 | function across multiple blocks of multiple inputs in a variety of ways. |
| 713 | Many dask.array operations are special cases of blockwise including |
| 714 | elementwise, broadcasting, reductions, tensordot, and transpose. |
| 715 | |
| 716 | Parameters |
| 717 | ---------- |
| 718 | func : callable |
| 719 | Function to apply to individual tuples of blocks |
| 720 | out_ind : iterable |
| 721 | Block pattern of the output, something like 'ijk' or (1, 2, 3) |
| 722 | *args : sequence of Array, index pairs |
| 723 | You may also pass literal arguments, accompanied by None index |
| 724 | e.g. (x, 'ij', y, 'jk', z, 'i', some_literal, None) |
| 725 | **kwargs : dict |
| 726 | Extra keyword arguments to pass to function |
| 727 | dtype : np.dtype |
| 728 | Datatype of resulting array. |
| 729 | concatenate : bool, keyword only |
| 730 | If true concatenate arrays along dummy indices, else provide lists |
| 731 | adjust_chunks : dict |
| 732 | Dictionary mapping index to function to be applied to chunk sizes |
| 733 | new_axes : dict, keyword only |
| 734 | New indexes and their dimension lengths |
| 735 | align_arrays: bool |
| 736 | Whether or not to align chunks along equally sized dimensions when |
| 737 | multiple arrays are provided. This allows for larger chunks in some |
| 738 | arrays to be broken into smaller ones that match chunk sizes in other |
| 739 | arrays such that they are compatible for block function mapping. If |
| 740 | this is false, then an error will be thrown if arrays do not already |
| 741 | have the same number of blocks in each dimension. |
| 742 | |
| 743 | Examples |
| 744 | -------- |
| 745 | 2D embarrassingly parallel operation from two arrays, x, and y. |
| 746 | |
| 747 | >>> import operator, numpy as np, dask.array as da |
| 748 | >>> x = da.from_array([[1, 2], |
| 749 | ... [3, 4]], chunks=(1, 2)) |
| 750 | >>> y = da.from_array([[10, 20], |
| 751 | ... [0, 0]]) |
no test coverage detected
searching dependent graphs…