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

Public Member Functions

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

Detailed Description

Definition at line 723 of file OpPrinter.cpp.

Member Function Documentation

◆ options()

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

Reimplemented from circledump::OpPrinter.

Definition at line 726 of file OpPrinter.cpp.

727 {
728 if (op->custom_options_format() != circle::CustomOptionsFormat::CustomOptionsFormat_FLEXBUFFERS)
729 {
730 os << " ";
731 os << "Unknown custom option format";
732 return;
733 }
734
735 const flatbuffers::Vector<uint8_t> *option_buf = op->custom_options();
736
737 if (option_buf == nullptr || option_buf->size() == 0)
738 {
739 os << "No attrs found." << std::endl;
740 return;
741 }
742
743 // printing attrs
744 // attrs of custom ops are encoded in flexbuffer format
745 auto attr_map = flexbuffers::GetRoot(option_buf->data(), option_buf->size()).AsMap();
746
747 os << " ";
748 auto keys = attr_map.Keys();
749 for (int i = 0; i < keys.size(); i++)
750 {
751 auto key = keys[i].ToString();
752 os << key << "(" << attr_map[key].ToString() << ") ";
753 }
754
755 // Note: attr in "Shape" type does not seem to be converted by circle_convert.
756 // When the converted circle file (with custom op) is opened with hexa editory,
757 // attrs names can be found but attr name in "Shape" type is not found.
758
759 os << std::endl;
760 }
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: