# Path: morph_net/framework/op_regularizer_manager.py
# ITERATION_LIMIT = 1000000
# class OpSlice(collections.namedtuple('OpSlice', ['op', 'slice'])):
# class Slice(collections.namedtuple('Slice', ['start_index', 'size'])):
# class OpRegularizerManager(object):
# class OpGroup(object):
#   def __str__(self):
#   def __str__(self):
#   def __init__(
#       self,
#       output_boundary: List[tf.Operation],
#       op_handler_dict=None,
#       create_grouping_regularizer=grouping_regularizers.MaxGroupingRegularizer,
#       force_group=None,
#       regularizer_blacklist=None,
#       input_boundary: List[tf.Operation] = None,
#       iteration_limit=ITERATION_LIMIT):
#   def ops(self):
#   def get_regularizer(self, op):
#   def create_op_group_for_op_slice(self, op_slice, is_source=True):
#   def group_op_slices(self, op_slices, omit_source_op_slices=None):
#   def slice_op(self, op, sizes):
#   def process_ops(self, ops):
#   def process_ops_last(self, ops):
#   def is_source_op(self, op):
#   def is_passthrough(self, op):
#   def get_op_slices(self, op):
#   def get_op_group(self, op_slice):
#   def _slice_op_slice(self, op_slice, sizes, size_index, size_count,
#                       new_op_slice_group):
#   def _slice_op_with_sizes(self, op, sizes, is_source, is_resliced):
#   def _get_source_slices(self, sizes, op_slices):
#   def _dfs_for_source_ops(self, output_boundary, input_boundary=None):
#   def _force_group_ops(self, force_group):
#   def __init__(self, op_slice=None, op_groups=None, omit_source_op_slices=None):
#   def op_slices(self):
#   def source_op_slices(self):
# 
# Path: morph_net/framework/output_non_passthrough_op_handler.py
# class OutputNonPassthroughOpHandler(op_handler.OpHandler):
#   def is_source_op(self):
#   def is_passthrough(self):
#   def assign_grouping(self, op, op_reg_manager):
#   def _group_with_output_slices(
#       self, op, output_op_slices, op_slices, op_reg_manager):
#   def _get_output_op_slices(self, output_ops, op_reg_manager):
#   def create_regularizer(self, _):


import mock
import tensorflow.compat.v1 as tf
from morph_net.framework import op_regularizer_manager as orm
from morph_net.framework import output_non_passthrough_op_handler
from tensorflow.contrib import framework
from tensorflow.contrib import layers
        return h.is_passthrough
      if op == self.batch_norm_op:
        return True
      else:
        return False

    self.mock_op_reg_manager.get_op_slices.side_effect = get_op_slices
    self.mock_op_reg_manager.get_op_group.side_effect = get_op_group
    self.mock_op_reg_manager.is_source_op.return_value = False
    self.mock_op_reg_manager.is_passthrough.side_effect = is_passthrough
    self.mock_op_reg_manager.ops = [
        self.conv1_op, self.relu1_op, self.conv2_op, self.relu2_op,
        self.batch_norm_op]

  def testAssignGrouping_GroupWithOutputOnly(self):
    # Map ops to slices.
    self.op_slice_dict = {
        self.conv1_op: [self.conv1_op_slice],
        self.relu1_op: [self.relu1_op_slice],
        self.conv2_op: [self.conv2_op_slice],
        self.relu2_op: [self.relu2_op_slice],
        self.batch_norm_op: [self.batch_norm_op_slice],
    }

    # Map each slice to a group. Corresponding op slices have the same group.
    self.op_group_dict = {
        self.batch_norm_op_slice: self.batch_norm_op_group,
    }

    # Call handler to assign grouping.

# Path: morph_net/framework/op_regularizer_manager.py
# ITERATION_LIMIT = 1000000
# class OpSlice(collections.namedtuple('OpSlice', ['op', 'slice'])):
# class Slice(collections.namedtuple('Slice', ['start_index', 'size'])):
# class OpRegularizerManager(object):
# class OpGroup(object):
#   def __str__(self):
#   def __str__(self):
#   def __init__(
#       self,
#       output_boundary: List[tf.Operation],
#       op_handler_dict=None,
#       create_grouping_regularizer=grouping_regularizers.MaxGroupingRegularizer,
#       force_group=None,
#       regularizer_blacklist=None,
#       input_boundary: List[tf.Operation] = None,
#       iteration_limit=ITERATION_LIMIT):
#   def ops(self):
#   def get_regularizer(self, op):
#   def create_op_group_for_op_slice(self, op_slice, is_source=True):
#   def group_op_slices(self, op_slices, omit_source_op_slices=None):
#   def slice_op(self, op, sizes):
#   def process_ops(self, ops):
#   def process_ops_last(self, ops):
#   def is_source_op(self, op):
#   def is_passthrough(self, op):
#   def get_op_slices(self, op):
#   def get_op_group(self, op_slice):
#   def _slice_op_slice(self, op_slice, sizes, size_index, size_count,
#                       new_op_slice_group):
#   def _slice_op_with_sizes(self, op, sizes, is_source, is_resliced):
#   def _get_source_slices(self, sizes, op_slices):
#   def _dfs_for_source_ops(self, output_boundary, input_boundary=None):
#   def _force_group_ops(self, force_group):
#   def __init__(self, op_slice=None, op_groups=None, omit_source_op_slices=None):
#   def op_slices(self):
#   def source_op_slices(self):
# 
# Path: morph_net/framework/output_non_passthrough_op_handler.py
# class OutputNonPassthroughOpHandler(op_handler.OpHandler):
#   def is_source_op(self):
#   def is_passthrough(self):
#   def assign_grouping(self, op, op_reg_manager):
#   def _group_with_output_slices(
#       self, op, output_op_slices, op_slices, op_reg_manager):
#   def _get_output_op_slices(self, output_ops, op_reg_manager):
#   def create_regularizer(self, _):


# Path: morph_net/framework/output_non_passthrough_op_handler_test.py
import mock
import tensorflow.compat.v1 as tf
from morph_net.framework import op_regularizer_manager as orm
from morph_net.framework import output_non_passthrough_op_handler
from tensorflow.contrib import framework
from tensorflow.contrib import layers

        return h.is_passthrough
      if op == self.batch_norm_op:
        return True
      else:
        return False

    self.mock_op_reg_manager.get_op_slices.side_effect = get_op_slices
    self.mock_op_reg_manager.get_op_group.side_effect = get_op_group
    self.mock_op_reg_manager.is_source_op.return_value = False
    self.mock_op_reg_manager.is_passthrough.side_effect = is_passthrough
    self.mock_op_reg_manager.ops = [
        self.conv1_op, self.relu1_op, self.conv2_op, self.relu2_op,
        self.batch_norm_op]

  def testAssignGrouping_GroupWithOutputOnly(self):
    # Map ops to slices.
    self.op_slice_dict = {
        self.conv1_op: [self.conv1_op_slice],
        self.relu1_op: [self.relu1_op_slice],
        self.conv2_op: [self.conv2_op_slice],
        self.relu2_op: [self.relu2_op_slice],
        self.batch_norm_op: [self.batch_norm_op_slice],
    }

    # Map each slice to a group. Corresponding op slices have the same group.
    self.op_group_dict = {
        self.batch_norm_op_slice: self.batch_norm_op_group,
    }

    # Call handler to assign grouping.

    handler = output_non_passthrough_op_handler.OutputNonPassthroughOpHandler()