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

Method wrapper

python/singa/layer.py:34–51  ·  view source on GitHub ↗
(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

graph_enabledMethod · 0.80
EnableGraphMethod · 0.80
initializeMethod · 0.45

Tested by

no test coverage detected