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

Function RunDecoding

dali/operators/decoder/numpy.cc:120–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120void RunDecoding(SampleView<CPUBackend> outputSample, ConstSampleView<CPUBackend> inputView,
121 const numpy::HeaderData &header) {
122 Tensor<CPUBackend> transposeBuffer;
123 if (header.fortran_order) {
124 transposeBuffer.Resize(outputSample.shape(), inputView.type());
125 auto transposeBufferView = SampleView<CPUBackend>(
126 transposeBuffer.raw_mutable_data(), transposeBuffer.shape(), transposeBuffer.type());
127 numpy::FromFortranOrder(std::move(transposeBufferView), inputView);
128 inputView = ConstSampleView<CPUBackend>(transposeBuffer.raw_data(), transposeBuffer.shape(),
129 transposeBuffer.type());
130 }
131
132 if (outputSample.type() != inputView.type()) {
133 // If the types do not match, we need to convert the data
134 TYPE_SWITCH(outputSample.type(), type2id, OType, NUMPY_ALLOWED_TYPES, (
135 TYPE_SWITCH(inputView.type(), type2id, IType, NUMPY_ALLOWED_TYPES, (
136 std::transform(inputView.data<IType>(),
137 inputView.data<IType>() + volume(inputView.shape()),
138 outputSample.mutable_data<OType>(), ConvertSat<OType, IType>);),
139 DALI_FAIL(make_string("Unsupported input type: ", inputView.type())););),
140 DALI_FAIL(make_string("Unsupported output type: ", outputSample.type())););
141 } else {
142 // If the types match, we can just copy the data
143 auto *out_ptr = outputSample.raw_mutable_data();
144 const auto *in_ptr = inputView.raw_data();
145 std::memcpy(out_ptr, in_ptr, header.nbytes());
146 }
147}
148
149
150void NumpyDecoder::RunImpl(Workspace &ws) {

Callers 1

RunImplMethod · 0.85

Calls 10

FromFortranOrderFunction · 0.85
volumeFunction · 0.85
raw_dataMethod · 0.80
transformFunction · 0.50
make_stringFunction · 0.50
ResizeMethod · 0.45
shapeMethod · 0.45
typeMethod · 0.45
raw_mutable_dataMethod · 0.45
nbytesMethod · 0.45

Tested by

no test coverage detected