24 #ifndef __ARM_COMPUTE_MISC_UTILITY_H__ 25 #define __ARM_COMPUTE_MISC_UTILITY_H__ 38 template <std::size_t...>
43 template <std::size_t N, std::size_t... S>
44 struct index_sequence_generator : index_sequence_generator < N - 1, N - 1, S... >
48 template <std::size_t... S>
49 struct index_sequence_generator<0u, S...> : index_sequence<S...>
51 using type = index_sequence<S...>;
54 template <std::
size_t N>
55 using index_sequence_t =
typename index_sequence_generator<N>::type;
60 template <std::size_t... S,
62 typename T = std::array<typename std::iterator_traits<Iterator>::value_type,
sizeof...(S)>>
65 return T{ { first[S]... } };
69 template <std::
size_t N,
typename Iterator>
70 std::array<typename std::iterator_traits<Iterator>::value_type, N>
make_array(Iterator first, Iterator last)
84 inline T
clamp(
const T &n,
const T &lower,
const T &upper)
101 template <
typename F,
typename T,
typename... Ts>
102 inline void for_each(F &&func, T &&arg, Ts &&... args)
104 func(std::forward<T>(arg));
105 for_each(std::forward<F>(func), std::forward<Ts>(args)...);
112 template <
typename F,
typename T>
115 return std::forward<T>(value);
125 template <
typename F,
typename T,
typename U,
typename... Us>
126 inline auto foldl(F &&func, T &&initial, U &&value, Us &&... values) -> decltype(func(std::forward<T>(initial), std::forward<U>(value)))
128 return foldl(std::forward<F>(func), func(std::forward<T>(initial), std::forward<U>(value)), std::forward<Us>(values)...);
139 template <
typename T,
typename U>
142 const auto low =
static_cast<U
>(std::numeric_limits<T>::lowest());
144 return static_cast<T
>(
clamp(val, low, high));
153 template <
typename T>
156 std::vector<size_t> idx(v.size());
157 std::iota(idx.begin(), idx.end(), 0);
159 std::sort(idx.begin(), idx.end(),
160 [&v](
size_t i1,
size_t i2)
162 return v[i1] < v[i2];
168 inline bool endswith(
const std::string &filename,
const std::string &suffix)
170 if(filename.size() < suffix.size())
174 return std::equal(suffix.rbegin(), suffix.rend(), filename.rbegin());
fixed_point< T > min(fixed_point< T > x, fixed_point< T > y)
T clamp(const T &n, const T &lower, const T &upper)
Performs clamping among a lower and upper value.
T saturate_cast(U val)
Type cast with saturation.
This file contains all available output stages for GEMMLowp on OpenCL.
T && foldl(F &&, T &&value)
Base case of foldl.
bool endswith(const std::string &filename, const std::string &suffix)
void for_each(F &&)
Base case of for_each.
T make_array(Iterator first, index_sequence< S... >)
fixed_point< T > max(fixed_point< T > x, fixed_point< T > y)
Iterator updated by execute_window_loop for each window element.
std::array< typename std::iterator_traits< Iterator >::value_type, N > make_array(Iterator first, Iterator last)
std::vector< size_t > sort_indices(const std::vector< T > &v)
Perform an index sort of a given vector.