ONE - On-device Neural Engine
Loading...
Searching...
No Matches
tfldump::CustomOpPrinter Class Reference
Collaboration diagram for tfldump::CustomOpPrinter:

Public Member Functions

void options (const tflite::Operator *op, std::ostream &os) const override
 

Detailed Description

Definition at line 701 of file OpPrinter.cpp.

Member Function Documentation

◆ options()

void tfldump::CustomOpPrinter::options ( const tflite::Operator *  op,
std::ostream &  os 
) const
inlineoverridevirtual

Reimplemented from tfldump::OpPrinter.

Definition at line 704 of file OpPrinter.cpp.

705 {
706 if (op->custom_options_format() != tflite::CustomOptionsFormat::CustomOptionsFormat_FLEXBUFFERS)
707 {
708 os << " ";
709 os << "Unknown custom option format";
710 return;
711 }
712
713 const flatbuffers::Vector<uint8_t> *option_buf = op->custom_options();
714
715 if (option_buf == nullptr || option_buf->size() == 0)
716 {
717 os << "No attrs found." << std::endl;
718 return;
719 }
720
721 // printing attrs
722 // attrs of custom ops are encoded in flexbuffer format
723 auto attr_map = flexbuffers::GetRoot(option_buf->data(), option_buf->size()).AsMap();
724
725 os << " ";
726 auto keys = attr_map.Keys();
727 for (int i = 0; i < keys.size(); i++)
728 {
729 auto key = keys[i].ToString();
730 os << key << "(" << attr_map[key].ToString() << ") ";
731 }
732
733 // Note: attr in "Shape" type does not seem to be converted by tflite_convert.
734 // When the converted tflite file (with custom op) is opened with hexa editory,
735 // attrs names can be found but attr name in "Shape" type is not found.
736
737 os << std::endl;
738 }
uoffset_t size() const
const T * data() const
TypedVector Keys() const
Reference GetRoot(const uint8_t *buffer, size_t size)

References flexbuffers::Reference::AsMap(), flatbuffers::Vector< T >::data(), flexbuffers::GetRoot(), flexbuffers::Map::Keys(), and flatbuffers::Vector< T >::size().


The documentation for this class was generated from the following file: