MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / fill_random_tensor

Function fill_random_tensor

utils/Utils.h:786–811  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

784
785template <typename T, typename TensorType>
786void 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
813template <typename T, typename TensorType>
814void fill_random_tensor(TensorType &tensor,

Callers 5

mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
do_setupMethod · 0.85
do_setupMethod · 0.85

Calls 5

lowestFunction · 0.85
mapFunction · 0.85
unmapFunction · 0.85
infoMethod · 0.45
ptrMethod · 0.45

Tested by

no test coverage detected