Skip to content

Commit

Permalink
Mark MultiInputter as built when all children are built (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumekln authored Apr 29, 2019
1 parent 0383fea commit fd0a7f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ OpenNMT-tf follows [semantic versioning 2.0.0](https://semver.org/). The API cov
### Fixes and improvements

* Fix usage of `--checkpoint_path` during training
* Fix embedding sharing with a `ParallelInputter` as input

## [1.22.0](https://github.com/OpenNMT/OpenNMT-tf/releases/tag/v1.22.0) (2019-04-06)

Expand Down
6 changes: 6 additions & 0 deletions opennmt/inputters/inputter.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,12 @@ def get_leaf_inputters(self):
inputters.append(inputter)
return inputters

def __getattribute__(self, name):
if name == "built":
return all(inputter.built for inputter in self.inputters)
else:
return super(MultiInputter, self).__getattribute__(name)

def initialize(self, metadata, asset_dir=None, asset_prefix=""):
for i, inputter in enumerate(self.inputters):
inputter.initialize(metadata, asset_prefix="%s%d_" % (asset_prefix, i + 1))
Expand Down

0 comments on commit fd0a7f6

Please sign in to comment.