def wrapper(self, other, **kwargs): annotate = annotate_tape(kwargs) func = __idiv__(self, other, **kwargs) if annotate: block = FunctionAssignBlock(func, self / other) tape = get_working_tape() tape.add_block(block) block.add_output(func.create_block_variable()) return func
def wrapper(self, other, **kwargs): ad_block_tag = kwargs.pop("ad_block_tag", None) annotate = annotate_tape(kwargs) func = __imul__(self, other, **kwargs) if annotate: block = FunctionAssignBlock(func, self * other, ad_block_tag=ad_block_tag) tape = get_working_tape() tape.add_block(block) block.add_output(func.create_block_variable()) return func
def wrapper(self, *args, **kwargs): annotate = annotate_tape(kwargs) func = copy(self, *args, **kwargs) if annotate: if kwargs.pop("deepcopy", False): block = FunctionAssignBlock(func, self) tape = get_working_tape() tape.add_block(block) block.add_output(func.create_block_variable()) else: # TODO: Implement. Here we would need to use floating types. raise NotImplementedError("Currently kwargs['deepcopy'] must be set True") return func
def wrapper(self, other, *args, **kwargs): """To disable the annotation, just pass :py:data:`annotate=False` to this routine, and it acts exactly like the Firedrake assign call.""" # do not annotate in case of self assignment annotate = annotate_tape(kwargs) and self != other if annotate: if not isinstance(other, ufl.core.operator.Operator): other = create_overloaded_object(other) block = FunctionAssignBlock(self, other) tape = get_working_tape() tape.add_block(block) with stop_annotating(): ret = assign(self, other, *args, **kwargs) if annotate: block.add_output(self.create_block_variable()) return ret