Fix importing none inputs (#217)

This commit is contained in:
Tung D. Le 2020-07-14 23:06:58 +09:00 committed by GitHub
parent d235f248e4
commit 0df421f7ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -309,7 +309,13 @@ private:
int expectedNumOperands = T::getNumberOfOperands();
int expectedNumResults = T::getNumberOfResults();
for (const auto &item : node.input())
if (initializedTensors.ContainKey(legalize_name(item))) {
if (item.empty()) {
// Optional inputs using empty string will be imported as NoneType.
if (!none_)
none_ = builder_.create<mlir::ConstantOp>(
UnknownLoc(), builder_.getUnitAttr());
inputs.emplace_back(none_);
} else if (initializedTensors.ContainKey(legalize_name(item))) {
inputs.push_back(initializedTensors.EmitInitializerForInputTensor(
UnknownLoc(), builder_, legalize_name(item)));
} else if (frontend_symbols_.ContainKey(legalize_name(item))) {