| 118 | // clang-format on |
| 119 | |
| 120 | TEST_P(OpCustomCrop, CustomCrop_packed) |
| 121 | { |
| 122 | cudaStream_t stream; |
| 123 | EXPECT_EQ(cudaSuccess, cudaStreamCreate(&stream)); |
| 124 | int inWidth = GetParamValue<0>(); |
| 125 | int inHeight = GetParamValue<1>(); |
| 126 | int outWidth = GetParamValue<2>(); |
| 127 | int outHeight = GetParamValue<3>(); |
| 128 | int cropWidth = GetParamValue<4>(); |
| 129 | int cropHeight = GetParamValue<5>(); |
| 130 | int cropX = GetParamValue<6>(); |
| 131 | int cropY = GetParamValue<7>(); |
| 132 | int numberOfImages = GetParamValue<8>(); |
| 133 | uint8_t cropVal = 0x56; |
| 134 | |
| 135 | nvcv::Tensor imgOut = nvcv::util::CreateTensor(numberOfImages, outWidth, outHeight, nvcv::FMT_RGBA8); |
| 136 | nvcv::Tensor imgIn = nvcv::util::CreateTensor(numberOfImages, inWidth, inHeight, nvcv::FMT_RGBA8); |
| 137 | |
| 138 | auto inData = imgIn.exportData<nvcv::TensorDataStridedCuda>(); |
| 139 | auto outData = imgOut.exportData<nvcv::TensorDataStridedCuda>(); |
| 140 | |
| 141 | ASSERT_NE(nullptr, inData); |
| 142 | ASSERT_NE(nullptr, outData); |
| 143 | |
| 144 | auto inAccess = nvcv::TensorDataAccessStridedImagePlanar::Create(*inData); |
| 145 | ASSERT_TRUE(inAccess); |
| 146 | |
| 147 | auto outAccess = nvcv::TensorDataAccessStridedImagePlanar::Create(*outData); |
| 148 | ASSERT_TRUE(outAccess); |
| 149 | |
| 150 | int inSampleStride = inAccess->numRows() * inAccess->rowStride(); |
| 151 | int outSampleStride = outAccess->numRows() * outAccess->rowStride(); |
| 152 | |
| 153 | int inBufSize = inSampleStride * inAccess->numSamples(); |
| 154 | int outBufSize = outSampleStride * outAccess->numSamples(); |
| 155 | |
| 156 | NVCVRectI crpRect = {cropX, cropY, cropWidth, cropHeight}; |
| 157 | |
| 158 | EXPECT_EQ(cudaSuccess, cudaMemset(inData->basePtr(), 0x00, inSampleStride * inAccess->numSamples())); |
| 159 | EXPECT_EQ(cudaSuccess, cudaMemset(outData->basePtr(), 0x00, outSampleStride * outAccess->numSamples())); |
| 160 | WriteData(*inAccess, cropVal, crpRect); // write data to be cropped |
| 161 | |
| 162 | std::vector<uint8_t> gold(outBufSize); |
| 163 | setGoldBuffer(gold, *outAccess, crpRect, cropVal); |
| 164 | |
| 165 | // run operator |
| 166 | cvcuda::CustomCrop cropOp; |
| 167 | |
| 168 | EXPECT_NO_THROW(cropOp(stream, imgIn, imgOut, crpRect)); |
| 169 | |
| 170 | // check cdata |
| 171 | std::vector<uint8_t> test(outBufSize); |
| 172 | std::vector<uint8_t> testIn(inBufSize); |
| 173 | |
| 174 | EXPECT_EQ(cudaSuccess, cudaStreamSynchronize(stream)); |
| 175 | EXPECT_EQ(cudaSuccess, cudaMemcpy(testIn.data(), inData->basePtr(), inBufSize, cudaMemcpyDeviceToHost)); |
| 176 | EXPECT_EQ(cudaSuccess, cudaMemcpy(test.data(), outData->basePtr(), outBufSize, cudaMemcpyDeviceToHost)); |
| 177 |
nothing calls this directly
no test coverage detected