# Path: experimental/lo/compress.py
# class Compressor:
#   """Implements a hierarchical set class with better performance than a set."""
# 
#   def __init__(self, hash_only_input=False):
#     self.n_dict = {}
#     self.hash_only_input = hash_only_input
# 
#   def add_entry(self, table_in, table_out=""):
#     """Adds entry (table_in, table_out) to the set."""
#     line = (table_in, table_out)
# 
#     if self.hash_only_input:
#       h_line = hash(table_in)
#     else:
#       h_line = hash(line)
# 
#     if self.n_dict.get(h_line, None):
#       self.n_dict[h_line] = self.n_dict[h_line].union([line])
#     else:
#       self.n_dict[h_line] = set([line])
# 
#   def has_entry(self, table_in, table_out=""):
#     """Checks if table_in is already stored in the set."""
# 
#     line = (table_in, table_out)
# 
#     if self.hash_only_input:
#       h_line = hash(table_in)
#     else:
#       h_line = hash(line)
# 
#     if not self.n_dict.get(h_line, None):
#       return None
# 
#     set_h_line = self.n_dict[h_line]
# 
#     for (ti, to) in set_h_line:
#       if table_in == ti:
#         return to
# 
#     return None
# 
#   def __call__(self):
#     for key in self.n_dict:
#       for line in self.n_dict[key]:
#         yield line
# 
# Path: experimental/lo/utils.py
# def get_padding_value(padding, kernel):
#   """Returns padding value for kernel."""
# 
#   if padding == "valid":
#     return 0
#   elif padding == "same":
#     return kernel // 2
#   elif padding == "full":
#     return kernel - 1
# 
#   raise ValueError("accepted paddings are 'valid', 'same' or 'full', found " +
#                    padding)


import multiprocessing as mp
import os
import shutil
import numpy as np
import six
from .compress import Compressor
from tensorflow.keras.models import Model
from .utils import get_padding_value

          continue

        # these are unique table entries

        table_ins.append(table_i)
        table_ous.append(table_o)

        # we store this information in order to be able to debug
        # and discard information.

        table_set.add_entry(table_s)

        if DEBUG:
          table_set_line[table_s] = (table_o, (n, ho, wo))

  print("... indexing table from {} to {} completed".format(ni, ni+size))

  return (table_ins, table_ous)


def parallel_compress_output_table(
    filename, header, table_ins, table_ous, output_group, generate_pla,
    n_bits_og, o, o_bits):
  """Processes in parallel compression of table and writes it to a disk."""

  f = open(filename, "w")

  f.write("".join(header))


# Path: experimental/lo/compress.py
# class Compressor:
#   """Implements a hierarchical set class with better performance than a set."""
# 
#   def __init__(self, hash_only_input=False):
#     self.n_dict = {}
#     self.hash_only_input = hash_only_input
# 
#   def add_entry(self, table_in, table_out=""):
#     """Adds entry (table_in, table_out) to the set."""
#     line = (table_in, table_out)
# 
#     if self.hash_only_input:
#       h_line = hash(table_in)
#     else:
#       h_line = hash(line)
# 
#     if self.n_dict.get(h_line, None):
#       self.n_dict[h_line] = self.n_dict[h_line].union([line])
#     else:
#       self.n_dict[h_line] = set([line])
# 
#   def has_entry(self, table_in, table_out=""):
#     """Checks if table_in is already stored in the set."""
# 
#     line = (table_in, table_out)
# 
#     if self.hash_only_input:
#       h_line = hash(table_in)
#     else:
#       h_line = hash(line)
# 
#     if not self.n_dict.get(h_line, None):
#       return None
# 
#     set_h_line = self.n_dict[h_line]
# 
#     for (ti, to) in set_h_line:
#       if table_in == ti:
#         return to
# 
#     return None
# 
#   def __call__(self):
#     for key in self.n_dict:
#       for line in self.n_dict[key]:
#         yield line
# 
# Path: experimental/lo/utils.py
# def get_padding_value(padding, kernel):
#   """Returns padding value for kernel."""
# 
#   if padding == "valid":
#     return 0
#   elif padding == "same":
#     return kernel // 2
#   elif padding == "full":
#     return kernel - 1
# 
#   raise ValueError("accepted paddings are 'valid', 'same' or 'full', found " +
#                    padding)


# Path: experimental/lo/conv2d.py
import multiprocessing as mp
import os
import shutil
import numpy as np
import six
from .compress import Compressor
from tensorflow.keras.models import Model
from .utils import get_padding_value


          continue

        # these are unique table entries

        table_ins.append(table_i)
        table_ous.append(table_o)

        # we store this information in order to be able to debug
        # and discard information.

        table_set.add_entry(table_s)

        if DEBUG:
          table_set_line[table_s] = (table_o, (n, ho, wo))

  print("... indexing table from {} to {} completed".format(ni, ni+size))

  return (table_ins, table_ous)


def parallel_compress_output_table(
    filename, header, table_ins, table_ous, output_group, generate_pla,
    n_bits_og, o, o_bits):
  """Processes in parallel compression of table and writes it to a disk."""

  f = open(filename, "w")

  f.write("".join(header))


  c = Compressor()