Skip to content

Commit

Permalink
[luci/import] Fix native_name with nullptr case (Samsung#7955)
Browse files Browse the repository at this point in the history
This commit fixes native_name methods in case of nullptr subgraph's name.

ONE-DCO-1.0-Signed-off-by: Maksim Bronnikov <[email protected]>
  • Loading branch information
m-bronnikov authored Nov 9, 2021
1 parent c0c2169 commit 4338bad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/luci/import/include/luci/Import/CircleReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ luci_quantparam(const circle::QuantizationParameters *quantization);
void copy_tensor_attributes(const circle::TensorT &tensor, CircleNode *node);
void copy_tensor_attributes(const circle::Tensor *tensor, CircleNode *node);

std::string fb_string2std_string(const flatbuffers::String *fb_str);

/**
* @brief Wrapper to use flatbuffers::Vector pointer as std::vector entity
*/
Expand Down Expand Up @@ -146,7 +148,7 @@ class CircleReader
CircleOperators native_operators() const { return wrap(_native_subgraph->operators()); }
VectorWrapper<int32_t> native_inputs() const { return wrap(_native_subgraph->inputs()); }
VectorWrapper<int32_t> native_outputs() const { return wrap(_native_subgraph->outputs()); }
std::string native_name() const { return _native_subgraph->name()->str(); }
std::string native_name() const { return fb_string2std_string(_native_subgraph->name()); }
circle::DataFormat native_data_format() const { return _native_subgraph->data_format(); }
CircleMetadataSet native_metadata() const { return wrap(_native_model->metadata()); }

Expand Down
5 changes: 5 additions & 0 deletions compiler/luci/import/src/CircleReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,11 @@ void copy_tensor_attributes(const circle::Tensor *tensor, CircleNode *node)
}
}

std::string fb_string2std_string(const flatbuffers::String *fb_str)
{
return fb_str == nullptr ? "" : fb_str->str();
}

circle::BuiltinOperator CircleReader::builtin_code(const circle::OperatorT &op) const
{
const auto &op_codes = opcodes();
Expand Down

0 comments on commit 4338bad

Please sign in to comment.