| 508 | |
| 509 | template <typename T, typename D> |
| 510 | void AssetsLibrary::fill_borders_with_garbage(T &&tensor, |
| 511 | D &&distribution, |
| 512 | std::random_device::result_type seed_offset) const |
| 513 | { |
| 514 | const PaddingSize padding_size = tensor.padding(); |
| 515 | |
| 516 | Window window; |
| 517 | window.set(0, Window::Dimension(-padding_size.left, tensor.shape()[0] + padding_size.right, 1)); |
| 518 | if (tensor.shape().num_dimensions() > 1) |
| 519 | { |
| 520 | window.set(1, Window::Dimension(-padding_size.top, tensor.shape()[1] + padding_size.bottom, 1)); |
| 521 | } |
| 522 | |
| 523 | std::mt19937 gen(_seed + seed_offset); |
| 524 | |
| 525 | execute_window_loop(window, |
| 526 | [&](const Coordinates &id) |
| 527 | { |
| 528 | TensorShape shape = tensor.shape(); |
| 529 | |
| 530 | // If outside of valid region |
| 531 | if (id.x() < 0 || id.x() >= static_cast<int>(shape.x()) || id.y() < 0 || |
| 532 | id.y() >= static_cast<int>(shape.y())) |
| 533 | { |
| 534 | using ResultType = typename std::remove_reference<D>::type::result_type; |
| 535 | const ResultType value = distribution(gen); |
| 536 | void *const out_ptr = tensor(id); |
| 537 | store_value_with_data_type(out_ptr, value, tensor.data_type()); |
| 538 | } |
| 539 | }); |
| 540 | } |
| 541 | |
| 542 | template <typename T, typename D> |
| 543 | void AssetsLibrary::fill_boxes(T &&tensor, D &&distribution, std::random_device::result_type seed_offset) const |
no test coverage detected