aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/WorkingMemHandle.cpp
blob: c1a48d482f0bf220b53bf79a102fd83993570edf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//

#include "backendsCommon/CpuTensorHandle.hpp"
#include "WorkingMemHandle.hpp"
#include "Network.hpp"

namespace armnn
{

namespace experimental
{

WorkingMemHandle::WorkingMemHandle(NetworkId networkId,
                                   std::vector<WorkingMemDescriptor> workingMemDescriptors,
                                   std::unordered_map<LayerGuid, WorkingMemDescriptor> workingMemDescriptorMap) :
    m_NetworkId(networkId),
    m_WorkingMemDescriptors(workingMemDescriptors),
    m_WorkingMemDescriptorMap(workingMemDescriptorMap),
    m_IsAllocated(false),
    m_Mutex()
{}

void WorkingMemHandle::FreeWorkingMemory()
{
    for (auto workingMemDescriptor : m_WorkingMemDescriptors)
    {
        for (auto input : workingMemDescriptor.m_Inputs)
        {
            if (input)
            {
                delete input;
                input = nullptr;
            }
        }
        for (auto output : workingMemDescriptor.m_Outputs)
        {
            if (output)
            {
                delete output;
                output = nullptr;
            }
        }
    }
}

} // end experimental namespace

} // end armnn namespace