def _load_general(data, targets, major_axis):
    """Load a list of arrays into a list of arrays specified by slices."""
    for d_src, d_targets, axis in zip(data, targets, major_axis): # pylint: disable=too-many-nested-blocks
        if isinstance(d_targets, nd.NDArray):
            d_src.copyto(d_targets)
        elif isinstance(d_src, (list, tuple)):
            for src, dst in zip(d_src, d_targets):
                src.copyto(dst)
        else:
            for slice_idx, d_dst in d_targets:
                if axis >= 0:
                    # copy slice
                    shape = d_src.shape
                    do_crop = (slice_idx.start != 0 or shape[axis] != slice_idx.stop)
                    # pylint: disable=no-member,protected-access
                    if do_crop:
                        if axis == 0:
                            d_src[slice_idx.start:slice_idx.stop].copyto(d_dst)
                        else:
                            if d_src.context == d_dst.context:
                                nd.slice_axis(d_src, axis=axis, begin=slice_idx.start,
                                              end=slice_idx.stop, out=d_dst)
                            else:
                                # on different device, crop and then do cross device copy
                                d_dst_copy = nd.slice_axis(d_src, axis=axis, begin=slice_idx.start,
                                                           end=slice_idx.stop)
                                d_dst_copy.copyto(d_dst)
                    else:
                        d_src.copyto(d_dst)
                    # pylint: enable=no-member,protected-access
                else:
                    d_src.copyto(d_dst)
def _load_general ( data , targets , major_axis ) : for d_src , d_targets , axis in zip ( data , targets , major_axis ) : if isinstance ( d_targets , nd . NDArray ) : d_src . copyto ( d_targets ) elif isinstance ( d_src , ( list , tuple ) ) : for src , dst in zip ( d_src , d_targets ) : src . copyto ( dst ) else : for slice_idx , d_dst in d_targets : if axis >= 0 : shape = d_src . shape do_crop = ( slice_idx . start != 0 or shape [ axis ] != slice_idx . stop ) if do_crop : if axis == 0 : d_src [ slice_idx . start : slice_idx . stop ] . copyto ( d_dst ) else : if d_src . context == d_dst . context : nd . slice_axis ( d_src , axis = axis , begin = slice_idx . start , end = slice_idx . stop , out = d_dst ) else : d_dst_copy = nd . slice_axis ( d_src , axis = axis , begin = slice_idx . start , end = slice_idx . stop ) d_dst_copy . copyto ( d_dst ) else : d_src . copyto ( d_dst ) else : d_src . copyto ( d_dst )
Load a list of arrays into a list of arrays specified by slices.