blob: 56997ad240f2bf1e118909697346e211f8549cb5 (
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
|
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
#include <armnn/Tensor.hpp>
#include "../ConversionUtils.hpp"
namespace armnn_driver
{
inline armnn::TensorShape FlattenFullyConnectedInput(const armnn::TensorShape& inputShape,
const armnn::TensorShape& weightsShape)
{
if (inputShape.GetNumDimensions() > 2U)
{
unsigned int totalInputElements = inputShape.GetNumElements();
unsigned int inputSize = weightsShape[1];
unsigned int batchSize = totalInputElements / inputSize;
if(totalInputElements % batchSize != 0)
{
throw std::runtime_error("Failed to deduce tensor shape");
}
return armnn::TensorShape({batchSize, inputSize});
}
else
{
return inputShape;
}
}
inline bool VerifyFullyConnectedShapes(const armnn::TensorShape& inputShape,
const armnn::TensorShape& weightsShape,
const armnn::TensorShape& outputShape,
bool transposeWeightMatrix)
{
unsigned int dimIdx = transposeWeightMatrix ? 0 : 1;
return (inputShape[0] == outputShape[0] && weightsShape[dimIdx] == outputShape[1]);
}
}
|