(
task,
output,
out_indices,
*arrind_pairs,
numblocks=None,
concatenate=None,
new_axes=None,
output_blocks=None,
dims=None,
io_deps=None,
keys=None,
)
| 912 | |
| 913 | |
| 914 | def _make_blockwise_graph( |
| 915 | task, |
| 916 | output, |
| 917 | out_indices, |
| 918 | *arrind_pairs, |
| 919 | numblocks=None, |
| 920 | concatenate=None, |
| 921 | new_axes=None, |
| 922 | output_blocks=None, |
| 923 | dims=None, |
| 924 | io_deps=None, |
| 925 | keys=None, |
| 926 | ): |
| 927 | if numblocks is None: |
| 928 | raise ValueError("Missing required numblocks argument.") |
| 929 | new_axes = new_axes or {} |
| 930 | io_deps = io_deps or {} |
| 931 | argpairs = list(toolz.partition(2, arrind_pairs)) |
| 932 | |
| 933 | if concatenate is True: |
| 934 | from dask.array.core import concatenate_axes as concatenate |
| 935 | |
| 936 | # Dictionary mapping {i: 3, j: 4, ...} for i, j, ... the dimensions |
| 937 | dims = dims or _make_dims(argpairs, numblocks, new_axes) |
| 938 | |
| 939 | # Generate the abstract "plan" before constructing |
| 940 | # the actual graph |
| 941 | coord_maps, concat_axes, dummies = _get_coord_mapping( |
| 942 | dims, |
| 943 | out_indices, |
| 944 | numblocks, |
| 945 | argpairs, |
| 946 | concatenate, |
| 947 | ) |
| 948 | |
| 949 | # Apply Culling. |
| 950 | # Only need to construct the specified set of output blocks. |
| 951 | # Note that we must convert itertools.product to list, |
| 952 | # because we may need to loop through output_blocks more than |
| 953 | # once below (itertools.product already uses an internal list, |
| 954 | # so this is not a memory regression) |
| 955 | output_blocks = output_blocks or list( |
| 956 | itertools.product(*[range(dims[i]) for i in out_indices]) |
| 957 | ) |
| 958 | from dask._task_spec import DataNode |
| 959 | |
| 960 | dsk = {} |
| 961 | for out_coords in output_blocks: |
| 962 | this_task = task |
| 963 | coords = out_coords + dummies |
| 964 | args = [] |
| 965 | for cmap, axes, (arg, ind), key in zip( |
| 966 | coord_maps, concat_axes, argpairs, keys, strict=True |
| 967 | ): |
| 968 | if key not in task.dependencies: |
| 969 | # FIXME: This feels like a bug |
| 970 | continue |
| 971 | if ind is None: |
searching dependent graphs…