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
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 @@
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 @@
{
_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 @@
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 @@
}
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 @@
{
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