Example #1
0
 def visit_PrimCall(self, expr):
   
   p = expr.prim
   args = self.visit_expr_list(expr.args)
   if p == prims.add: 
     return self.add(args[0], args[1])
   elif p == prims.subtract:
     return self.sub(args[0], args[1])
   elif p == prims.multiply:
     return self.mul(args[0], args[1])
   elif p == prims.divide:
     return self.div(args[0], args[1])
   else:
     return shape.combine_list(args, preserve_const = False)
Example #2
0
 def visit_PrimCall(self, expr):
   
   p = expr.prim
   args = self.visit_expr_list(expr.args)
   if p == prims.add: 
     return self.add(args[0], args[1])
   elif p == prims.subtract:
     return self.sub(args[0], args[1])
   elif p == prims.multiply:
     return self.mul(args[0], args[1])
   elif p == prims.divide:
     return self.div(args[0], args[1])
   else:
     result = shape.combine_list(args, preserve_const = False)
     if result.__class__ is Shape:
       return result
     else:
       # once a scalar passes through some prim, it's not longer the same value!
       return any_scalar 
Example #3
0
    def visit_PrimCall(self, expr):

        p = expr.prim
        args = self.visit_expr_list(expr.args)
        if p == prims.add:
            return self.add(args[0], args[1])
        elif p == prims.subtract:
            return self.sub(args[0], args[1])
        elif p == prims.multiply:
            return self.mul(args[0], args[1])
        elif p == prims.divide:
            return self.div(args[0], args[1])
        else:
            result = shape.combine_list(args, preserve_const=False)
            if result.__class__ is Shape:
                return result
            else:
                # once a scalar passes through some prim, it's not longer the same value!
                return any_scalar
Example #4
0
 def visit_Array(self, expr):
   elts = self.visit_expr_list(expr.elts)
   elt = combine_list(elts)
   n = len(elts)
   res = increase_rank(elt, 0, const(n))
   return res
Example #5
0
 def visit_PrimCall(self, expr):
   arg_shapes = self.visit_expr_list(expr.args)
   return shape.combine_list(arg_shapes, preserve_const = False)
Example #6
0
 def visit_Array(self, expr):
     elts = self.visit_expr_list(expr.elts)
     elt = combine_list(elts)
     n = len(elts)
     res = increase_rank(elt, 0, const(n))
     return res