Exemple #1
0
 def _apply(cls, slices, eachfunc, dtype=rtypes.unknown, named_params=False, keep_name=False, per_slice=False, **kwargs):
     if(not isinstance(dtype,rtypes.TypeUnknown)):
         dtype = rtypes.createType(dtype,len(slices[0].dims)) 
     if per_slice:   
         return tuple([ops.EachOp((slice,), eachfunc, dtype, named_params, keep_name, kwargs) for slice in slices])
     else:
         slices,plans = ops.broadcast(slices, mode='dim', partial=False)
         return (ops.EachOp(slices, eachfunc, dtype, named_params, keep_name, kwargs),)
Exemple #2
0
    def _apply(
        cls, slices, eachfunc, dtype=rtypes.unknown, named_params=False, keep_name=False, per_slice=False, **kwargs
    ):
        if not isinstance(dtype, rtypes.TypeUnknown):
            refdims = []
            for slice in slices:
                refdims.extend(slice.dims)
                refdims.extend(slice.type.getAllDims())

            dtype = rtypes.createType(dtype, len(slices[0].dims), refdims=refdims)
        if per_slice:
            return tuple([ops.EachOp((slice,), eachfunc, dtype, named_params, keep_name, kwargs) for slice in slices])
        else:
            slices, plans = ops.broadcast(slices, mode="dim", partial=False)
            return (ops.EachOp(slices, eachfunc, dtype, named_params, keep_name, kwargs),)
Exemple #3
0
 def _apply(cls, binslices, mode, pos=None, **kwargs):
     binslices = cls._prepareSlices(*binslices)
     (lslice, rslice), plans = ops.broadcast(binslices, mode, partial=cls._allow_partial_bc)
     sig, nkwargs, outparam = cls._findSignature(left=lslice, right=rslice, **kwargs)
     if isinstance(outparam, rtypes.TypeUnknown):
         if binslices[0].name == binslices[1].name:
             name = binslices[0].name
         elif binslices[0].name == "data":
             name = binslices[1].name
         elif binslices[1].name == "data":
             name = binslices[0].name
         else:
             name = "result"
         outparam = Param(name, outparam)
         if not pos is None and name == "result":
             outparam = outparam.withNumber(pos)
     s = ops.BinFuncElemOp(cls.__name__, sig, outparam, **nkwargs)
     return s