aboutsummaryrefslogtreecommitdiff
path: root/reference_model
diff options
context:
space:
mode:
authorJerry Ge <jerry.ge@arm.com>2022-11-16 10:41:55 -0800
committerEric Kunze <eric.kunze@arm.com>2022-12-09 15:53:29 +0000
commita68274931b24625f5576ca9ee9d4268cd80fc7c8 (patch)
tree4f5b18eb703a9a5ab9462890df04b0117ce1f491 /reference_model
parent4160186b6ef5f0f9e34390b0a3bb1359e9266902 (diff)
downloadreference_model-a68274931b24625f5576ca9ee9d4268cd80fc7c8.tar.gz
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
Diffstat (limited to 'reference_model')
-rw-r--r--reference_model/src/ops/activation_funcs.cc6
-rw-r--r--reference_model/src/ops/activation_funcs.h3
-rw-r--r--reference_model/src/ops/data_layout.cc4
-rw-r--r--reference_model/src/ops/ewise_binary.cc16
-rw-r--r--reference_model/src/ops/ewise_binary.h2
5 files changed, 28 insertions, 3 deletions
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 @@ int OpClamp<Rank, Dtype>::register_fcn()
}
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 @@ public:
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 @@ OpTranspose<Rank, Dtype>::OpTranspose(SubgraphTraverser* sgt_,
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 @@ int OpArithmeticRightShift<Rank, Dtype>::register_fcn()
}
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 @@ int OpMul<Rank, InDtype, OutDtype>::register_fcn()
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 @@ OpTable<Rank, InDtype>::OpTable(SubgraphTraverser* sgt_,
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 @@ public:
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 @@ public:
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;