27 template <
typename CollectionType>
28 bool AreEqual(
const CollectionType& lhs,
const CollectionType& rhs)
30 if (lhs.size() != rhs.size())
35 auto lhs_it = std::find_if(lhs.begin(), lhs.end(), [&rhs](
auto& item)
37 return std::find(rhs.begin(), rhs.end(), item) == rhs.end();
40 return lhs_it == lhs.end();
44 template <
typename CollectionType>
45 bool Contains(
const CollectionType& collection,
const typename CollectionType::value_type& item)
47 return std::find(collection.begin(), collection.end(), item) != collection.end();
51 template <
typename MapType>
52 bool Contains(
const MapType& map,
const typename MapType::key_type& key)
54 return map.find(key) != map.end();
58 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
59 bool Compare(T a, T b,
float tolerance = 0.000001f)
66 return static_cast<bool>(a) == static_cast<bool>(b);
71 return std::fabs(static_cast<float>(a) - static_cast<float>(b)) <= tolerance;
74 template <
typename ConvolutionLayer>
77 layer->m_Weight = std::make_unique<armnn::ScopedTensorHandle>(weightInfo);
78 layer->m_Bias = std::make_unique<armnn::ScopedTensorHandle>(biasInfo);
80 layer->m_Weight->Allocate();
81 layer->m_Bias->Allocate();
95 unsigned int channels,
100 template<
typename DataType>
101 static std::vector<DataType> GenerateRandomData(
size_t size)
103 constexpr
bool isIntegerType = std::is_integral<DataType>::value;
105 typename std::conditional<isIntegerType,
106 std::uniform_int_distribution<DataType>,
107 std::uniform_real_distribution<DataType>>::type;
109 static constexpr
DataType lowerLimit = std::numeric_limits<DataType>::min();
110 static constexpr
DataType upperLimit = std::numeric_limits<DataType>::max();
112 static Distribution distribution(lowerLimit, upperLimit);
113 static std::default_random_engine generator;
115 std::vector<DataType> randomData(size);
116 generate(randomData.begin(), randomData.end(), []() {
return distribution(generator); });
armnn::SubgraphView::InputSlots CreateInputsFrom(const std::vector< armnn::Layer *> &layers)
armnn::SubgraphView::SubgraphViewPtr CreateSubgraphViewFrom(armnn::SubgraphView::InputSlots &&inputs, armnn::SubgraphView::OutputSlots &&outputs, armnn::SubgraphView::Layers &&layers)
armnn::IBackendInternalUniquePtr CreateBackendObject(const armnn::BackendId &backendId)
bool AreEqual(const CollectionType &lhs, const CollectionType &rhs)
armnn::TensorShape MakeTensorShape(unsigned int batches, unsigned int channels, unsigned int height, unsigned int width, armnn::DataLayout layout)
std::vector< OutputSlot * > OutputSlots
armnn::SubgraphView::OutputSlots CreateOutputsFrom(const std::vector< armnn::Layer *> &layers)
std::unique_ptr< SubgraphView > SubgraphViewPtr
bool Contains(const CollectionType &collection, const typename CollectionType::value_type &item)
std::vector< InputSlot * > InputSlots
void SetWeightAndBias(ConvolutionLayer *layer, const armnn::TensorInfo &weightInfo, const armnn::TensorInfo &biasInfo)
std::unique_ptr< IBackendInternal > IBackendInternalUniquePtr
std::list< Layer * > Layers
bool Compare(T a, T b, float tolerance=0.000001f)