diff options
author | Kevin Cheng <kevin.cheng@arm.com> | 2021-11-11 01:36:33 +0000 |
---|---|---|
committer | Kevin Cheng <kevin.cheng@arm.com> | 2021-11-11 16:56:17 -0800 |
commit | 545a508429afe1d22760563d252839e13ecd12a3 (patch) | |
tree | 38280879dbe9ab09387eb912d8248d8daa002acb /include | |
parent | 2752adbaab2ad4864e7d7831bf9fa87a70e797ed (diff) | |
download | serialization_lib-545a508429afe1d22760563d252839e13ecd12a3.tar.gz |
Clean up constructor interface
- replace string type constructor argument with "const string&"
- replace vector type constructor argument with "const vector<T>&"
- add rvalue reference constructor for TosaSerializationOperator and TosaSerializationBasicBlock
- add SetData() for TosaSerializationTensor, so tensor can be constructed first and data can be linked later
Signed-off-by: Kevin Cheng <kevin.cheng@arm.com>
Change-Id: I7c739df54c37b7ba69ebb6e5af118f660c7c0623
Diffstat (limited to 'include')
-rw-r--r-- | include/tosa_serialization_handler.h | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/include/tosa_serialization_handler.h b/include/tosa_serialization_handler.h index a60e506..b07fa3b 100644 --- a/include/tosa_serialization_handler.h +++ b/include/tosa_serialization_handler.h @@ -114,7 +114,7 @@ public: const flatbuffers::Vector<int32_t>* shape, DType dtype, const flatbuffers::Vector<uint8_t>* data); - TosaSerializationTensor(std::string& name, + TosaSerializationTensor(const std::string& name, const std::vector<int32_t>& shape, DType dtype, const std::vector<uint8_t>& data); @@ -148,6 +148,14 @@ public: { _name = name; } + void SetData(const std::vector<uint8_t>& data) + { + _data = data; + } + void SetData(std::vector<uint8_t>&& data) + { + _data = std::move(data); + } private: DType _dtype; /* data type enumeration, see tosa_isa_generated.h */ @@ -166,8 +174,15 @@ public: const TosaAttributeBase* attribute, QuantInfo qinfo_type, const TosaQuantInfoBase* qinfo, - std::vector<std::string> input_tensor_names, - std::vector<std::string> output_tensor_names); + const std::vector<std::string>& input_tensor_names, + const std::vector<std::string>& output_tensor_names); + TosaSerializationOperator(Op op, + Attribute attribute_type, + const TosaAttributeBase* attribute, + QuantInfo qinfo_type, + const TosaQuantInfoBase* qinfo, + std::vector<std::string>&& input_tensor_names, + std::vector<std::string>&& output_tensor_names); ~TosaSerializationOperator(); // accessor @@ -201,6 +216,10 @@ public: } private: + void InitializeAttributeQinfo(Attribute attribute_type, + const TosaAttributeBase* attribute, + QuantInfo qinfo_type, + const TosaQuantInfoBase* qinfo); Op _op; /* operator enum, see tosa_isa_generated.h for enumeration table */ Attribute _attribute_type; /* operator attribute enum, used for dynamic casting TosaAttributeBase class */ TosaAttributeBase* _attribute; /* real attribute class goes here */ @@ -214,11 +233,16 @@ class TosaSerializationBasicBlock { public: // constructor and destructor - TosaSerializationBasicBlock(std::string name, - std::vector<TosaSerializationOperator*> operators, - std::vector<TosaSerializationTensor*> tensors, - std::vector<std::string> inputs, - std::vector<std::string> outputs); + TosaSerializationBasicBlock(const std::string& name, + const std::vector<TosaSerializationOperator*>& operators, + const std::vector<TosaSerializationTensor*>& tensors, + const std::vector<std::string>& inputs, + const std::vector<std::string>& outputs); + TosaSerializationBasicBlock(std::string&& name, + std::vector<TosaSerializationOperator*>&& operators, + std::vector<TosaSerializationTensor*>&& tensors, + std::vector<std::string>&& inputs, + std::vector<std::string>&& outputs); ~TosaSerializationBasicBlock(); // accessor |