def _apply_generic_op(op, arg): if not (arg.type_signature.is_federated() or type_analysis.is_structure_of_tensors(arg.type_signature)): # If there are federated elements nested in a struct, we need to zip these # together before passing to binary operator constructor. arg = building_block_factory.create_federated_zip(arg) return building_block_factory.apply_binary_operator_with_upcast(arg, op)
def _apply_generic_op(op, x, y, intrinsics, context_stack): arg = _pack_binary_operator_args(x, y, intrinsics, context_stack) arg_comp = value_impl.ValueImpl.get_comp(arg) result = building_block_factory.apply_binary_operator_with_upcast( arg_comp, op) return value_impl.ValueImpl(result, context_stack)