提交 88424899 编写于 作者: L luotao1

fix bug after high get_places and get_dims

上级 92e04896
...@@ -28,7 +28,7 @@ def to_lodtensor(data, place): ...@@ -28,7 +28,7 @@ def to_lodtensor(data, place):
def lodtensor_to_ndarray(lod_tensor): def lodtensor_to_ndarray(lod_tensor):
"""conver lodtensor to ndarray """conver lodtensor to ndarray
""" """
dims = lod_tensor.get_dims() dims = lod_tensor._get_dims()
ret = np.zeros(shape=dims).astype('float32') ret = np.zeros(shape=dims).astype('float32')
for i in xrange(np.product(dims)): for i in xrange(np.product(dims)):
ret.ravel()[i] = lod_tensor.get_float_element(i) ret.ravel()[i] = lod_tensor.get_float_element(i)
......
...@@ -88,7 +88,7 @@ def stacked_lstmp_model(frame_dim, ...@@ -88,7 +88,7 @@ def stacked_lstmp_model(frame_dim,
# When the execution place is specified to CUDAPlace, the program will # When the execution place is specified to CUDAPlace, the program will
# run on all $CUDA_VISIBLE_DEVICES GPUs. Otherwise the program will # run on all $CUDA_VISIBLE_DEVICES GPUs. Otherwise the program will
# run on all CPU devices. # run on all CPU devices.
places = fluid.layers.get_places() places = fluid.layers.device.get_places()
pd = fluid.layers.ParallelDo(places) pd = fluid.layers.ParallelDo(places)
with pd.do(): with pd.do():
feat_ = pd.read_input(feature) feat_ = pd.read_input(feature)
......
...@@ -187,7 +187,7 @@ def do_train(train_reader, ...@@ -187,7 +187,7 @@ def do_train(train_reader,
init_low_bound, init_high_bound) init_low_bound, init_high_bound)
avg_cost = fluid.layers.mean(x=cost) avg_cost = fluid.layers.mean(x=cost)
else: else:
places = fluid.layers.get_places() places = fluid.layers.device.get_places()
pd = fluid.layers.ParallelDo(places) pd = fluid.layers.ParallelDo(places)
with pd.do(): with pd.do():
cost = network( cost = network(
......
...@@ -109,7 +109,7 @@ def ner_net(word_dict_len, label_dict_len, parallel, stack_num=2): ...@@ -109,7 +109,7 @@ def ner_net(word_dict_len, label_dict_len, parallel, stack_num=2):
name="target", shape=[1], dtype='int64', lod_level=1) name="target", shape=[1], dtype='int64', lod_level=1)
if parallel: if parallel:
places = fluid.layers.get_places() places = fluid.layers.device.get_places()
pd = fluid.layers.ParallelDo(places) pd = fluid.layers.ParallelDo(places)
with pd.do(): with pd.do():
word_ = pd.read_input(word) word_ = pd.read_input(word)
......
...@@ -34,7 +34,7 @@ def train(train_reader, ...@@ -34,7 +34,7 @@ def train(train_reader,
if not parallel: if not parallel:
cost, acc, prediction = network(data, label, len(word_dict)) cost, acc, prediction = network(data, label, len(word_dict))
else: else:
places = fluid.layers.get_places(device_count=2) places = fluid.layers.device.get_places(device_count=2)
pd = fluid.layers.ParallelDo(places) pd = fluid.layers.ParallelDo(places)
with pd.do(): with pd.do():
cost, acc, prediction = network( cost, acc, prediction = network(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册