Caffe2 - Python API
A deep learning, cross platform ML framework
backend.py
1 
2 class FunctionBackend(object):
3 
4  def __init__(self):
5  self.function_classes = {}
6 
7  def __getattr__(self, name):
8  fn = self.function_classes.get(name)
9  if fn is None:
10  raise NotImplementedError
11  return fn
12 
13  def register_function(self, name, function_class):
14  if self.function_classes.get(name):
15  raise RuntimeError("Trying to register second function under name " + name + " in " + type(self).__name__)
16  self.function_classes[name] = function_class