| 678 | |
| 679 | template <typename T, typename D> |
| 680 | void 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 | |
| 707 | bool RandomAccessor::access_tensor(ITensor &tensor) |
| 708 | { |
no test coverage detected