MCPcopy Create free account
hub / github.com/apache/singa / init_wrapper

Method init_wrapper

python/singa/layer.py:31–53  ·  view source on GitHub ↗
(func)

Source from the content-addressed store, hash-verified

29class LayerMeta(type):
30
31 def init_wrapper(func):
32
33 @wraps(func)
34 def wrapper(self, *args, **kwargs):
35 if len(args) == 0:
36 return
37
38 if isinstance(args[0], list):
39 assert len(args) > 0 and isinstance(args[0][0], Tensor), (
40 'initialize function expects PlaceHolders or Tensors')
41 dev = args[0][0].device
42 else:
43 assert len(args) > 0 and isinstance(args[0], Tensor), (
44 'initialize function expects PlaceHolders or Tensors')
45 dev = args[0].device
46
47 prev_state = dev.graph_enabled()
48 dev.EnableGraph(False)
49 func(self, *args, **kwargs)
50 self._initialized = True
51 dev.EnableGraph(prev_state)
52
53 return wrapper
54
55 def forward_wrapper(func):
56

Callers 1

__new__Method · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected