| 784 | |
| 785 | template <typename T, typename TensorType> |
| 786 | void fill_random_tensor(TensorType &tensor, |
| 787 | std::random_device::result_type seed, |
| 788 | T lower_bound = std::numeric_limits<T>::lowest(), |
| 789 | T upper_bound = std::numeric_limits<T>::max()) |
| 790 | { |
| 791 | constexpr bool is_fp_16bit = std::is_same<T, half>::value || std::is_same<T, bfloat16>::value; |
| 792 | constexpr bool is_integral = std::is_integral<T>::value && !is_fp_16bit; |
| 793 | |
| 794 | using fp_dist_type = typename std::conditional<is_fp_16bit, arm_compute::utils::uniform_real_distribution_16bit<T>, |
| 795 | std::uniform_real_distribution<T>>::type; |
| 796 | using dist_type = typename std::conditional<is_integral, std::uniform_int_distribution<T>, fp_dist_type>::type; |
| 797 | |
| 798 | std::mt19937 gen(seed); |
| 799 | dist_type dist(lower_bound, upper_bound); |
| 800 | |
| 801 | map(tensor, true); |
| 802 | |
| 803 | Window window; |
| 804 | window.use_tensor_dimensions(tensor.info()->tensor_shape()); |
| 805 | |
| 806 | Iterator it(&tensor, window); |
| 807 | execute_window_loop( |
| 808 | window, [&](const Coordinates &) { *reinterpret_cast<T *>(it.ptr()) = dist(gen); }, it); |
| 809 | |
| 810 | unmap(tensor); |
| 811 | } |
| 812 | |
| 813 | template <typename T, typename TensorType> |
| 814 | void fill_random_tensor(TensorType &tensor, |