From 545a508429afe1d22760563d252839e13ecd12a3 Mon Sep 17 00:00:00 2001 From: Kevin Cheng Date: Thu, 11 Nov 2021 01:36:33 +0000 Subject: Clean up constructor interface - replace string type constructor argument with "const string&" - replace vector type constructor argument with "const vector&" - 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 Change-Id: I7c739df54c37b7ba69ebb6e5af118f660c7c0623 --- include/tosa_serialization_handler.h | 40 ++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) (limited to 'include') 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* shape, DType dtype, const flatbuffers::Vector* data); - TosaSerializationTensor(std::string& name, + TosaSerializationTensor(const std::string& name, const std::vector& shape, DType dtype, const std::vector& data); @@ -148,6 +148,14 @@ public: { _name = name; } + void SetData(const std::vector& data) + { + _data = data; + } + void SetData(std::vector&& 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 input_tensor_names, - std::vector output_tensor_names); + const std::vector& input_tensor_names, + const std::vector& output_tensor_names); + TosaSerializationOperator(Op op, + Attribute attribute_type, + const TosaAttributeBase* attribute, + QuantInfo qinfo_type, + const TosaQuantInfoBase* qinfo, + std::vector&& input_tensor_names, + std::vector&& 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 operators, - std::vector tensors, - std::vector inputs, - std::vector outputs); + TosaSerializationBasicBlock(const std::string& name, + const std::vector& operators, + const std::vector& tensors, + const std::vector& inputs, + const std::vector& outputs); + TosaSerializationBasicBlock(std::string&& name, + std::vector&& operators, + std::vector&& tensors, + std::vector&& inputs, + std::vector&& outputs); ~TosaSerializationBasicBlock(); // accessor -- cgit v1.2.1