def f(*idxs): idxs = list(idxs) sm = lengths[0] load = tensors[0].load(idxs) for length, tensor in list(zip(lengths, tensors))[1:]: new_idxs = idxs[:] new_idxs[dim] -= to_expr(sm) load = te.ifThenElse(idxs[dim] < to_expr(sm), load, tensor.load(new_idxs)) return load
def f(*idxs): val = args[0].load(idxs) return te.ifThenElse( val < to_expr(args[1]), to_expr(args[1]), te.ifThenElse(val > to_expr(args[2]), to_expr(args[2]), val))
def compute(idxs): load = inputs[0].as_buf().load(idxs) return te.ifThenElse(te.ExprHandle.isnan(load), te.ExprHandle.float(0.), load)