MCPcopy Create free account
hub / github.com/NVIDIA/DALI / CopyHelper

Function CopyHelper

dali/operators/reader/numpy_reader_op.cc:29–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27namespace dali {
28
29static void CopyHelper(SampleView<CPUBackend> output, ConstSampleView<CPUBackend> input,
30 ThreadPool &thread_pool, int min_blk_sz, int req_nblocks) {
31 auto *out_ptr = static_cast<uint8_t *>(output.raw_mutable_data());
32 const auto *in_ptr = static_cast<const uint8_t *>(input.raw_data());
33 auto nelements = input.shape().num_elements();
34 auto nbytes = nelements * TypeTable::GetTypeInfo(input.type()).size();
35 if (nelements <= min_blk_sz) {
36 thread_pool.AddWork([=](int tid) {
37 std::memcpy(out_ptr, in_ptr, nbytes);
38 }, nelements);
39 } else {
40 int64_t prev_b_start = 0;
41 for (int b = 0; b < req_nblocks; b++) {
42 int64_t b_start = prev_b_start;
43 int64_t b_end = prev_b_start = nbytes * (b + 1) / req_nblocks;
44 int64_t b_size = b_end - b_start;
45 thread_pool.AddWork([=](int tid) {
46 std::memcpy(out_ptr + b_start, in_ptr + b_start, b_size);
47 }, b_size);
48 }
49 }
50}
51
52static void SliceHelper(SampleView<CPUBackend> output, ConstSampleView<CPUBackend> input,
53 const CropWindow &roi, float fill_value, ThreadPool &thread_pool,

Callers 1

SlicePermuteHelperFunction · 0.85

Calls 8

GetTypeInfoFunction · 0.85
raw_dataMethod · 0.80
raw_mutable_dataMethod · 0.45
num_elementsMethod · 0.45
shapeMethod · 0.45
sizeMethod · 0.45
typeMethod · 0.45
AddWorkMethod · 0.45

Tested by

no test coverage detected