Exemplo n.º 1
0
    def call(*curr):
      """ Call 'func', replacing missing and defaulted arguments.
      Args:
        ... Forwarded arguments
      Returns:
        Forwarded returned value
      """
      assert len(args) <= len(curr) + len(defs), "Not enough parameters provided in native function call"
      return func(*(curr + defs[len(curr) - len(args) + len(defs):]))
    return call

# ---------------------------------------------------------------------------- #
# Automatic building and loading

# Register foreign import instance
_register      = tools.ClassRegister("foreign import")
itemize_py     = _register.itemize
register_py    = _register.register
instantiate_py = _register.instantiate
del _register

def _loader_ctypes(so_path):
  """ Post-building ctypes loading operations.
  Args:
    so_path Shared object path
  """
  try:
    lib = ctypes.CDLL(str(so_path))
    register_py(so_path.stem[3:], lambda: lib)
  except Exception as err:
    with tools.Context(so_path.stem, "warning"):
Exemplo n.º 2
0
    Args:
      nbworkers Total number of workers
      nbbyzwrks Declared number of Byzantine workers
      args      Command line argument list
    """
        raise NotImplementedError

    def aggregate(self, gradients):
        """ Build the gradient aggregation operation of the given gradients.
    Args:
      gradients Computed gradient tensors
    Returns:
      Aggregated gradient tensor
    """
        raise NotImplementedError


# ---------------------------------------------------------------------------- #
# GAR script loader

# Register instance
_register = tools.ClassRegister("GAR")
itemize = _register.itemize
register = _register.register
instantiate = _register.instantiate
del _register

# Load all local modules
with tools.Context("aggregators", None):
    tools.import_directory(pathlib.Path(__file__).parent, globals())
Exemplo n.º 3
0
      trace          Whether to add trace prints for every important step of the computations
    Returns:
      List of loss tensors associated with 'device_models'
    """
    raise NotImplementedError

  def accuracy(self, device_dataset, device_model, trace=False):
    """ Build an accuracy tensor on the specified devices, placement on parameter server by default.
    Args:
      device_dataset Dataset device name/function (same instance between calls if same task, i.e. can use 'is')
      device_models  Model device names/functions, one per worker on the associated task
      trace          Whether to add trace prints for every important step of the computations
    Returns:
      Map of metric string name -> aggregated metric tensor associated with 'device_models'
    """
    raise NotImplementedError

# ---------------------------------------------------------------------------- #
# Experiment register and loader

# Register instance
_register   = tools.ClassRegister("experiment")
itemize     = _register.itemize
register    = _register.register
instantiate = _register.instantiate
del _register

# Load all local modules
with tools.Context("experiments", None):
  tools.import_directory(pathlib.Path(__file__).parent, globals())