26 template <
typename CollectionType>
27 bool AreEqual(
const CollectionType& lhs,
const CollectionType& rhs)
29 if (lhs.size() != rhs.size())
34 auto lhs_it = std::find_if(lhs.begin(), lhs.end(), [&rhs](
auto& item)
36 return std::find(rhs.begin(), rhs.end(), item) == rhs.end();
39 return lhs_it == lhs.end();
43 template <
typename CollectionType>
44 bool Contains(
const CollectionType& collection,
const typename CollectionType::value_type& item)
46 return std::find(collection.begin(), collection.end(), item) != collection.end();
50 template <
typename MapType>
51 bool Contains(
const MapType& map,
const typename MapType::key_type& key)
53 return map.find(key) != map.end();
57 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
58 inline bool Compare(T a, T b,
float tolerance = 0.000001f)
65 return static_cast<bool>(a) == static_cast<bool>(b);
70 return std::fabs(static_cast<float>(a) - static_cast<float>(b)) <= tolerance;
73 template <
typename ConvolutionLayer>
76 layer->m_Weight = std::make_unique<armnn::ScopedTensorHandle>(weightInfo);
77 layer->m_Bias = std::make_unique<armnn::ScopedTensorHandle>(biasInfo);
79 layer->m_Weight->Allocate();
80 layer->m_Bias->Allocate();
83 std::vector<unsigned int> ignoreSlots = {});
86 std::vector<unsigned int> ignoreSlots = {});
97 unsigned int channels,
102 template<
typename DataType>
103 static std::vector<DataType> GenerateRandomData(
size_t size)
105 constexpr
bool isIntegerType = std::is_integral<DataType>::value;
107 typename std::conditional<isIntegerType,
108 std::uniform_int_distribution<DataType>,
109 std::uniform_real_distribution<DataType>>::type;
111 static constexpr
DataType lowerLimit = std::numeric_limits<DataType>::min();
112 static constexpr
DataType upperLimit = std::numeric_limits<DataType>::max();
114 static Distribution distribution(lowerLimit, upperLimit);
115 static std::default_random_engine generator;
117 std::vector<DataType> randomData(size);
118 generate(randomData.begin(), randomData.end(), []() {
return distribution(generator); });
bool Contains(const CollectionType &collection, const typename CollectionType::value_type &item)
std::vector< OutputSlot * > OutputSlots
bool Compare(T a, T b, float tolerance=0.000001f)
armnn::SubgraphView::InputSlots CreateInputsFrom(armnn::Layer *layer, std::vector< unsigned int > ignoreSlots={})
std::unique_ptr< SubgraphView > SubgraphViewPtr
armnn::TensorShape MakeTensorShape(unsigned int batches, unsigned int channels, unsigned int height, unsigned int width, armnn::DataLayout layout)
armnn::SubgraphView::SubgraphViewPtr CreateSubgraphViewFrom(armnn::SubgraphView::InputSlots &&inputs, armnn::SubgraphView::OutputSlots &&outputs, armnn::SubgraphView::Layers &&layers)
armnn::SubgraphView::OutputSlots CreateOutputsFrom(const std::vector< armnn::Layer *> &layers)
void SetWeightAndBias(ConvolutionLayer *layer, const armnn::TensorInfo &weightInfo, const armnn::TensorInfo &biasInfo)
std::vector< InputSlot * > InputSlots
armnn::IBackendInternalUniquePtr CreateBackendObject(const armnn::BackendId &backendId)
bool AreEqual(const CollectionType &lhs, const CollectionType &rhs)
std::unique_ptr< IBackendInternal > IBackendInternalUniquePtr
std::list< Layer * > Layers