| 176 | }; |
| 177 | |
| 178 | Tensor PillowResizeInto(Tensor &output, Tensor &input, nvcv::ImageFormat format, NVCVInterpolationType interp, |
| 179 | std::optional<Stream> pstream) |
| 180 | { |
| 181 | if (!pstream) |
| 182 | { |
| 183 | pstream = Stream::Current(); |
| 184 | } |
| 185 | auto in_access = nvcv::TensorDataAccessStridedImagePlanar::Create(input.exportData()); |
| 186 | auto out_access = nvcv::TensorDataAccessStridedImagePlanar::Create(output.exportData()); |
| 187 | if (!in_access || !out_access) |
| 188 | { |
| 189 | throw std::runtime_error("Incompatible input/output tensor layout"); |
| 190 | } |
| 191 | |
| 192 | // Use CreateOperatorEx to use the extended create operator function passing the specialized PyOperator above |
| 193 | // as template type, instead of the regular cvcuda::OP class used in the CreateOperator function. |
| 194 | auto pillowResize = CreateOperatorEx<PyOpPillowResize>(); |
| 195 | |
| 196 | ResourceGuard guard(*pstream); |
| 197 | guard.add(LockMode::LOCK_MODE_READ, {input}); |
| 198 | guard.add(LockMode::LOCK_MODE_WRITE, {output}); |
| 199 | guard.add(LockMode::LOCK_MODE_READWRITE, {*pillowResize}); |
| 200 | |
| 201 | pillowResize->submit(pstream->cudaHandle(), input, output, format, interp); |
| 202 | |
| 203 | return output; |
| 204 | } |
| 205 | |
| 206 | Tensor PillowResize(Tensor &input, const Shape &out_shape, nvcv::ImageFormat format, NVCVInterpolationType interp, |
| 207 | std::optional<Stream> pstream) |
no test coverage detected