aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/layers/PreCompiledLayer.cpp
blob: 75c1e46a84b2c1c34b89ebf2e0073009531f7c5f (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
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//

#include "PreCompiledLayer.hpp"

#include "LayerCloneBase.hpp"

#include <backendsCommon/Workload.hpp>

#include <armnn/TypesUtils.hpp>

namespace armnn
{

PreCompiledLayer::PreCompiledLayer(const PreCompiledDescriptor& param, const char* name)
    : LayerWithParameters(param.m_NumInputSlots, param.m_NumOutputSlots, LayerType::PreCompiled, param, name)
{}

PreCompiledLayer::~PreCompiledLayer()
{}

PreCompiledLayer* PreCompiledLayer::Clone(Graph& graph) const
{
    PreCompiledLayer* clone = CloneBase<PreCompiledLayer>(graph, m_Param, GetName());
    clone->m_PreCompiledObject.reset(const_cast<PreCompiledLayer*>(this)->m_PreCompiledObject.release());
    return clone;
}

std::unique_ptr<IWorkload> PreCompiledLayer::CreateWorkload(const armnn::IWorkloadFactory& factory) const
{
    PreCompiledQueueDescriptor descriptor;
    descriptor.m_PreCompiledObject = m_PreCompiledObject.get();
    SetAdditionalInfo(descriptor);

    return factory.CreatePreCompiled(descriptor, PrepInfoAndDesc(descriptor));
}

void PreCompiledLayer::ValidateTensorShapesFromInputs()
{

    // NOTE: since the PreCompiledLayer is an internal layer created from a valid SubgraphView,
    // we do not need to validate its input shapes
}

void PreCompiledLayer::SetPreCompiledObject(PreCompiledObjectPtr preCompiledObject)
{
    m_PreCompiledObject = std::move(preCompiledObject);
}

void PreCompiledLayer::Accept(ILayerVisitor& visitor) const
{
    IgnoreUnused(visitor);
    throw armnn::Exception("PreCompiledLayer should not appear in an input graph");
}

void PreCompiledLayer::ExecuteStrategy(IStrategy& strategy) const
{
    IgnoreUnused(strategy);
    throw armnn::Exception("FakeQuantizationLayer should not appear in an input graph");
}

} // namespace armnn