MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / __init__

Method __init__

tensorpack/predict/multigpu.py:90–121  ·  view source on GitHub ↗

Args: config (PredictConfig): the config to use. towers: a list of relative GPU id.

(self, config, towers)

Source from the content-addressed store, hash-verified

88 """
89
90 def __init__(self, config, towers):
91 """
92 Args:
93 config (PredictConfig): the config to use.
94 towers: a list of relative GPU id.
95 """
96 self.graph = config._maybe_create_graph()
97 with self.graph.as_default():
98 input_tensors = []
99 output_tensors = []
100
101 for idx, t in enumerate(towers):
102 tower_name = 'tower' + str(t)
103
104 new_sig = [tf.TensorSpec(dtype=p.dtype, shape=p.shape, name=tower_name + '_' + p.name)
105 for p in config.input_signature]
106 input = PlaceholderInput()
107 input.setup(new_sig)
108
109 with tf.variable_scope(tf.get_variable_scope(), reuse=idx > 0), \
110 tf.device('/gpu:{}'.format(t)), \
111 PredictTowerContext(tower_name):
112 config.tower_func(*input.get_input_tensors())
113 h = config.tower_func.towers[-1]
114 input_tensors.extend(h.get_tensors(config.input_names))
115 output_tensors.extend(h.get_tensors(config.output_names))
116
117 config.session_init._setup_graph()
118 sess = config.session_creator.create_session()
119 config.session_init._run_init(sess)
120 super(DataParallelOfflinePredictor, self).__init__(
121 input_tensors, output_tensors, config.return_input, sess)

Callers

nothing calls this directly

Calls 13

PlaceholderInputClass · 0.85
PredictTowerContextClass · 0.85
_maybe_create_graphMethod · 0.80
setupMethod · 0.80
deviceMethod · 0.80
formatMethod · 0.80
tower_funcMethod · 0.80
get_input_tensorsMethod · 0.80
get_tensorsMethod · 0.80
_setup_graphMethod · 0.45
create_sessionMethod · 0.45
_run_initMethod · 0.45

Tested by

no test coverage detected