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

Method fill

utils/GraphUtils.cpp:680–705  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

678
679template <typename T, typename D>
680void RandomAccessor::fill(ITensor &tensor, D &&distribution)
681{
682 std::mt19937 gen(_seed);
683
684 if (tensor.info()->padding().empty() && (dynamic_cast<SubTensor *>(&tensor) == nullptr))
685 {
686 for (size_t offset = 0; offset < tensor.info()->total_size(); offset += tensor.info()->element_size())
687 {
688 const auto value = static_cast<T>(distribution(gen));
689 *reinterpret_cast<T *>(tensor.buffer() + offset) = value;
690 }
691 }
692 else
693 {
694 // If tensor has padding accessing tensor elements through execution window.
695 Window window;
696 window.use_tensor_dimensions(tensor.info()->tensor_shape());
697
698 execute_window_loop(window,
699 [&](const Coordinates &id)
700 {
701 const auto value = static_cast<T>(distribution(gen));
702 *reinterpret_cast<T *>(tensor.ptr_to_element(id)) = value;
703 });
704 }
705}
706
707bool RandomAccessor::access_tensor(ITensor &tensor)
708{

Callers 3

SubTensorInfoMethod · 0.45
TensorInfoMethod · 0.45
initMethod · 0.45

Calls 7

ptr_to_elementMethod · 0.80
emptyMethod · 0.45
paddingMethod · 0.45
infoMethod · 0.45
total_sizeMethod · 0.45
element_sizeMethod · 0.45
bufferMethod · 0.45

Tested by

no test coverage detected