Пример #1
0
 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
Пример #2
0
 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))
Пример #3
0
 def compute(idxs):
     load = inputs[0].as_buf().load(idxs)
     return te.ifThenElse(te.ExprHandle.isnan(load),
                          te.ExprHandle.float(0.), load)