Skip to content

Commit

Permalink
Merge pull request #11570 from JiayiFeng/dev_support_dynamic_size_rec…
Browse files Browse the repository at this point in the history
…ordio

make data_feeder support dynamic shape
  • Loading branch information
JiayiFeng committed Jun 20, 2018
2 parents 25241e9 + dfe54a4 commit 0d2dd1a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion python/paddle/fluid/data_feeder.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ def __init__(self, place, lod_level, shape, dtype):
self.place = place
self.lod_level = lod_level
self.shape = shape
negtive_count = 0
for s in self.shape:
if s < 0:
negtive_count += 1
if negtive_count > 1:
self.shape = None
break
if dtype == core.VarDesc.VarType.FP32:
self.dtype = 'float32'
elif dtype == core.VarDesc.VarType.INT64:
Expand Down Expand Up @@ -61,7 +68,9 @@ def _feed_impl_(self, data, lod, lod_level):
self._feed_impl_(each_data, lod[1:], lod_level - 1)

def done(self):
arr = numpy.array(self.data, dtype=self.dtype).reshape(self.shape)
arr = numpy.array(self.data, dtype=self.dtype)
if self.shape:
arr = arr.reshape(self.shape)
t = core.LoDTensor()
t.set(arr, self.place)
if self.lod_level > 0:
Expand Down

0 comments on commit 0d2dd1a

Please sign in to comment.