def __init__(self, places, prefix="_expr", max_vectors_in_batch_expr=None): IdentityMapper.__init__(self) self.places = places self.prefix = prefix self.max_vectors_in_batch_expr = max_vectors_in_batch_expr self.code = [] self.expr_to_var = {} self.assigned_names = set()
def __call__(self, expr): # {{{ collect operators by operand from pytential.symbolic.mappers import OperatorCollector from pytential.symbolic.primitives import IntG operators = [ op for op in OperatorCollector()(expr) if isinstance(op, IntG) ] self.group_to_operators = {} for op in operators: features = self.op_group_features(op) self.group_to_operators.setdefault(features, set()).add(op) # }}} # Traverse the expression, generate code. result = IdentityMapper.__call__(self, expr) # Put the toplevel expressions into variables as well. from pytools.obj_array import obj_array_vectorize result = obj_array_vectorize(self.assign_to_new_var, result) return Code(self.code, result)
def __call__(self, expr): # {{{ collect operators by operand from pytential.symbolic.mappers import OperatorCollector from pytential.symbolic.primitives import IntG operators = [ op for op in OperatorCollector()(expr) if isinstance(op, IntG)] self.group_to_operators = {} for op in operators: features = self.op_group_features(op) self.group_to_operators.setdefault(features, set()).add(op) # }}} # Traverse the expression, generate code. result = IdentityMapper.__call__(self, expr) # Put the toplevel expressions into variables as well. from pytools.obj_array import with_object_array_or_scalar result = with_object_array_or_scalar(self.assign_to_new_var, result) return Code(self.code, result)