Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark MultiInputter as built when all children are built #421

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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