Skip to content

Commit

Permalink
fix params with only 1 dim (#15828) (#15832)
Browse files Browse the repository at this point in the history
* fix params with only 1 dim
* test=develop
  • Loading branch information
seiriosPlus committed Feb 21, 2019
1 parent 2307baf commit 4b3f9e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion python/paddle/fluid/io.py
Expand Up @@ -766,7 +766,10 @@ def __load_persistable_vars(executor, dirname, need_load_vars):
dtype=slice_var.dtype,
persistable=True)

dim1_flatten = reduce(lambda x, y: x * y, slice.shape[1:])
dim1_flatten = 1
if len(slice.shape) >= 2:
dim1_flatten = reduce(lambda x, y: x * y, slice.shape[1:])

start = int(offset / dim1_flatten)
end = int(offset / dim1_flatten + slice.shape[0])

Expand Down
6 changes: 5 additions & 1 deletion python/paddle/fluid/transpiler/distribute_transpiler.py
Expand Up @@ -1020,7 +1020,11 @@ def _get_slice_var_info(self, slice_var):
skip_dim0 = 0
slice_vars = self.param_var_mapping[orig_var_name]

orig_dim1_flatten = reduce(lambda x, y: x * y, slice_vars[0].shape[1:])
orig_dim1_flatten = 1

if len(slice_vars[0].shape) >= 2:
orig_dim1_flatten = reduce(lambda x, y: x * y,
slice_vars[0].shape[1:])

for slice_var in slice_vars[:block_idx]:
skip_dim0 += slice_var.shape[0]
Expand Down

0 comments on commit 4b3f9e5

Please sign in to comment.