Fix reference model memory leaks for the following ops

- OpClamp
- OpArithmeticRightShift
- OpMul
- OpTable
- OpTranspose

Signed-off-by: Jerry Ge <jerry.ge@arm.com>
Change-Id: Icb84a8a17c298b471a635310454775977a9133cb
diff --git a/reference_model/src/ops/activation_funcs.cc b/reference_model/src/ops/activation_funcs.cc
index 09ef6f6..dc85088 100644
--- a/reference_model/src/ops/activation_funcs.cc
+++ b/reference_model/src/ops/activation_funcs.cc
@@ -56,6 +56,12 @@
 }
 
 template <int Rank, DType Dtype>
+OpClamp<Rank, Dtype>::~OpClamp()
+{
+    if (attribute) delete attribute;
+}
+
+template <int Rank, DType Dtype>
 int OpSigmoid<Rank, Dtype>::register_fcn()
 {
     switch (Dtype)
diff --git a/reference_model/src/ops/activation_funcs.h b/reference_model/src/ops/activation_funcs.h
index 4853971..9a697cd 100644
--- a/reference_model/src/ops/activation_funcs.h
+++ b/reference_model/src/ops/activation_funcs.h
@@ -1,5 +1,5 @@
 
-// Copyright (c) 2020, ARM Limited.
+// Copyright (c) 2020-2022, ARM Limited.
 //
 //    Licensed under the Apache License, Version 2.0 (the "License");
 //    you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@
         INIT_ATTRIBUTE(Clamp);
         register_fcn();
     }
+    virtual ~OpClamp();
     static constexpr int32_t QMin = GetQMin<Dtype>::value;
     static constexpr int32_t QMax = GetQMax<Dtype>::value;
     using InEigenType             = typename GetEigenType<Dtype>::type;
diff --git a/reference_model/src/ops/data_layout.cc b/reference_model/src/ops/data_layout.cc
index bffd659..b127cba 100644
--- a/reference_model/src/ops/data_layout.cc
+++ b/reference_model/src/ops/data_layout.cc
@@ -581,7 +581,9 @@
 
 template <int Rank, DType Dtype>
 OpTranspose<Rank, Dtype>::~OpTranspose()
-{}
+{
+    if (attribute) delete attribute;
+}
 
 template <int Rank, DType Dtype>
 int OpTranspose<Rank, Dtype>::checkTensorAttributes()
diff --git a/reference_model/src/ops/ewise_binary.cc b/reference_model/src/ops/ewise_binary.cc
index e4c0ee0..7d0c434 100644
--- a/reference_model/src/ops/ewise_binary.cc
+++ b/reference_model/src/ops/ewise_binary.cc
@@ -192,6 +192,12 @@
 }
 
 template <int Rank, DType Dtype>
+OpArithmeticRightShift<Rank, Dtype>::~OpArithmeticRightShift()
+{
+    if (attribute) delete attribute;
+}
+
+template <int Rank, DType Dtype>
 int OpBitwiseAnd<Rank, Dtype>::register_fcn()
 {
     switch (Dtype)
@@ -455,6 +461,12 @@
     return 0;
 }
 
+template <int Rank, DType InDtype, DType OutDtype>
+OpMul<Rank, InDtype, OutDtype>::~OpMul()
+{
+    if (attribute) delete attribute;
+}
+
 template <int Rank, DType Dtype>
 int OpPow<Rank, Dtype>::register_fcn()
 {
@@ -512,7 +524,9 @@
 
 template <int Rank, DType InDtype>
 OpTable<Rank, InDtype>::~OpTable()
-{}
+{
+    if (attribute) delete attribute;
+}
 
 template <int Rank, DType InDtype>
 int OpTable<Rank, InDtype>::checkTensorAttributes()
diff --git a/reference_model/src/ops/ewise_binary.h b/reference_model/src/ops/ewise_binary.h
index 6b0efaf..020ddb5 100644
--- a/reference_model/src/ops/ewise_binary.h
+++ b/reference_model/src/ops/ewise_binary.h
@@ -148,6 +148,7 @@
     using InEigenType  = typename GetEigenType<Dtype>::type;
     using OutEigenType = typename GetEigenType<Dtype>::type;
     virtual int register_fcn();
+    virtual ~OpArithmeticRightShift();
 
 protected:
     TosaArithmeticRightShiftAttribute* attribute;
@@ -163,6 +164,7 @@
         INIT_ATTRIBUTE(Mul);
         register_fcn();
     }
+    virtual ~OpMul();
     static constexpr int64_t QMin = GetQMin<OutDtype>::value;
     static constexpr int64_t QMax = GetQMax<OutDtype>::value;
     using InEigenType             = typename GetEigenType<InDtype>::type;