From f29a2c55af463141fac7c92042bfdb9f00ba4ccd Mon Sep 17 00:00:00 2001 From: Kevin May Date: Thu, 14 Mar 2019 11:56:32 +0000 Subject: MLCE-91 LSTM doesn't support optional input * Add fix for optional NO_VALUE operands in ConversionUtils.hpp * Remove fail message for optional NO_VALUE in ConversionUtils.hpp * Add to existing tests and test helper to cover optional NO_VALUE Signed-off-by: Kevin May Change-Id: Icf36af1fc00d3fb33cdd77ff6d6618cc4700d3fd --- ConversionUtils.hpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'ConversionUtils.hpp') diff --git a/ConversionUtils.hpp b/ConversionUtils.hpp index c86ad93c..ca1f0aea 100644 --- a/ConversionUtils.hpp +++ b/ConversionUtils.hpp @@ -488,13 +488,16 @@ ConstTensorPin ConvertOperandToConstTensorPin(const Operand& operand, return ConstTensorPin(); } - if (operand.lifetime != OperandLifeTime::CONSTANT_COPY && operand.lifetime != OperandLifeTime::CONSTANT_REFERENCE) + if (!optional && + operand.lifetime != OperandLifeTime::CONSTANT_COPY && + operand.lifetime != OperandLifeTime::CONSTANT_REFERENCE && + operand.lifetime != OperandLifeTime::NO_VALUE) { Fail("%s: invalid operand lifetime: %s", __func__, toString(operand.lifetime).c_str()); return ConstTensorPin(); } - const void* const valueStart = GetOperandValueReadOnlyAddress(operand, model, data); + const void* const valueStart = GetOperandValueReadOnlyAddress(operand, model, data, optional); if (!valueStart) { if (optional) @@ -539,7 +542,8 @@ ConstTensorPin ConvertOperationInputToConstTensorPin(const HalOperation& operati } template -const void* GetOperandValueReadOnlyAddress(const Operand& operand, const HalModel& model, const ConversionData& data) +const void* GetOperandValueReadOnlyAddress(const Operand& operand, const HalModel& model, const ConversionData& data, + bool optional = false) { const void* valueStart = nullptr; @@ -557,6 +561,15 @@ const void* GetOperandValueReadOnlyAddress(const Operand& operand, const HalMode valueStart = GetMemoryFromPool(operand.location, data.m_MemPools); break; } + case OperandLifeTime::NO_VALUE: + { + // An optional input tensor with no values is not an error so should not register as a fail + if (optional) + { + valueStart = nullptr; + break; + } + } default: { // Unsupported/invalid (e.g. can't get value of an input to the model) -- cgit v1.2.1