# Path: morph_net/framework/depthwise_convolution_op_handler.py
# class DepthwiseConvolutionOpHandler(grouping_op_handler.GroupingOpHandler):
#   def assign_grouping(self, op, op_reg_manager):
#   def _get_depth_multiplier_input_output_op_slices(
#       self, input_ops, input_size, output_ops, op_reg_manager,
#       depth_multiplier):
# 
# 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):


import mock
import tensorflow.compat.v1 as tf
from morph_net.framework import depthwise_convolution_op_handler
from morph_net.framework import op_regularizer_manager as orm
from tensorflow.contrib import framework as framework
from tensorflow.contrib import layers
    self.conv3_op_slice = orm.OpSlice(self.conv3_op, orm.Slice(0, 6))

    # Create mock OpRegularizerManager with custom mapping of OpSlice and
    # OpGroup.
    self.mock_op_reg_manager = mock.create_autospec(orm.OpRegularizerManager)

    self.op_slice_dict = {
        self.dwise_conv2_op: [self.dwise_conv2_op_slice],
        self.conv2_op: [self.conv2_op_slice],
        self.relu1_op: [self.relu1_op_slice],
        self.conv3_op: [self.conv3_op_slice],
    }
    def get_op_slices(op):
      return self.op_slice_dict.get(op)

    def get_op_group(op_slice):
      return self.op_group_dict.get(op_slice)

    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.ops = [
        self.relu1_op, self.dwise_conv2_op, self.conv2_op, self.conv3_op]

    # All neighbor ops have groups.
    self.op_group_dict = {
        self.relu1_op_slice: self.relu1_op_group,
    }

    # Call handler to assign grouping.

# Path: morph_net/framework/depthwise_convolution_op_handler.py
# class DepthwiseConvolutionOpHandler(grouping_op_handler.GroupingOpHandler):
#   def assign_grouping(self, op, op_reg_manager):
#   def _get_depth_multiplier_input_output_op_slices(
#       self, input_ops, input_size, output_ops, op_reg_manager,
#       depth_multiplier):
# 
# 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/depthwise_convolution_op_handler_test.py
import mock
import tensorflow.compat.v1 as tf
from morph_net.framework import depthwise_convolution_op_handler
from morph_net.framework import op_regularizer_manager as orm
from tensorflow.contrib import framework as framework
from tensorflow.contrib import layers

    self.conv3_op_slice = orm.OpSlice(self.conv3_op, orm.Slice(0, 6))

    # Create mock OpRegularizerManager with custom mapping of OpSlice and
    # OpGroup.
    self.mock_op_reg_manager = mock.create_autospec(orm.OpRegularizerManager)

    self.op_slice_dict = {
        self.dwise_conv2_op: [self.dwise_conv2_op_slice],
        self.conv2_op: [self.conv2_op_slice],
        self.relu1_op: [self.relu1_op_slice],
        self.conv3_op: [self.conv3_op_slice],
    }
    def get_op_slices(op):
      return self.op_slice_dict.get(op)

    def get_op_group(op_slice):
      return self.op_group_dict.get(op_slice)

    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.ops = [
        self.relu1_op, self.dwise_conv2_op, self.conv2_op, self.conv3_op]

    # All neighbor ops have groups.
    self.op_group_dict = {
        self.relu1_op_slice: self.relu1_op_group,
    }

    # Call handler to assign grouping.

    handler = depthwise_convolution_op_handler.DepthwiseConvolutionOpHandler()