Absolute Difference and Addition not working properly on GPU
Hi,
I am using CLAbsoluteDifference and CLArithmeticAddition class from ComputeLibrary and testing it on different image sizes. I am having some issues with respect to both while running on GPU.
-
Absolute Difference output not proper for input type S16-S16 on CL: In my setup, I want to evaluate Absolute Difference for two input combinations : U8-U8 and S16-S16. Here, U8-U8 combination works properly and gives results as expected but S16-S16 combination output is not proper. Some of the points are coming properly in the output but some image columns are set to zeros and some others are going completely wrong. I have captured this in the attached files : AbsDiff_GPU_16x16.txt, AbsDiff_GPU_24x24.txt
-
CLArithmeticAddition ConvertPolicy::WRAP not working. I am trying to add two images of type U8-U8 for both overflow handling policies. Here, ConvertPolicy::SATURATE works fine. But ConvertPolicy::WRAP is also giving results same as ConvertPolicy::SATURATE itself. Please refer my results in Add_GPU_16x16_U8_U8_Wrap.txt
-
CLArithmeticAddition input combinations of U8-S16, S16-U8 and S16-S16 are not proper. This is not exactly similar to issue 1. The outputs are all going wrong. Please refer Add_GPU_16x16_S16_U8.txt, Add_GPU_16x16_U8_S16.txt and Add_GPU_16x16_S16_S16.txt files. The behaviour is similar for both convert policies.
The basic code flow in my algorithm is as below:
// Assign format for the input and output images format1 = Format::S16; format2 = Format::S16; format3 = Format::S16;
// Access schedule and initialise context & command queue
CLScheduler::get().default_init();
// Initiailise ACL images
src1.allocator()->init(TensorInfo(imageWidth, imageHeight, format1));
src2.allocator()->init(TensorInfo(imageWidth, imageHeight, format2));
dest.allocator()->init(TensorInfo(imageWidth, imageHeight, format3));
// Call ACL configure. Padding info updated inside images (accurate padding)
absDiff.configure(&src1, &src2, &dest);
// Allocate ACL images
src1.allocator()->allocate();
src2.allocator()->allocate();
dest.allocator()->allocate();
src1.map(true);
// Copy each row separately
src1.unmap();
src2.map(true);
// Copy each row separately
src2.unmap();
// Call ACL run
absDiff.run();
// Make sure all the OpenCL jobs are done executing
CLScheduler::get().sync();
dest.map(true);
// Copy each row separately
dest.unmap();
Are there any such known issues with convert policy or data types for CL? Please note that a similar code flow on NEON gives the expected output in all cases. Kindly let me know how I can fix this issue on CL.
AbsDiff_GPU_16x16.txt AbsDiff_GPU_24x24.txt Add_GPU_16x16_S16_S16.txt Add_GPU_16x16_S16_U8.txt Add_GPU_16x16_U8_S16.txt Add_GPU_16x16_U8_U8_Wrap.txt
Thanks, Rohit
Hello @rohit-unnimadhavan,
Can you also post the copy each row code?
Sure. This is how the code looks for dest Image.
// Copy each row separately
if(format3 == Format::U8) {
for (int y = 0; y < imageHeight; y++) {
memcpy((void *) ((uint8_t*)dstBase + y * imageWidth),
dest.buffer() + dest.info()->offset_element_in_bytes(Coordinates(0,y)),
imageWidth * sizeFormat3);
}
} else {
for (int y = 0; y < imageHeight; y++) {
memcpy((void *) ((int16_t*)dstBase + y * imageWidth),
dest.buffer() + dest.info()->offset_element_in_bytes(Coordinates(0,y)),
imageWidth * sizeFormat3);
}
}
I didn't include it earlier because of the length and because I was sure this was proper, as the same code works properly for NEON.
@rohit-unnimadhavan, I cannot reproduce anything locally for AbsoluteDifference. Everything seems to work fine. Can you check if you memcpy correctly in bytes? You can also print your tensor like:
void print_tensor(CLTensor& tensor)
{
tensor.map(true);
tensor.print(std::cout);
tensor.unmap();
}
....
// Print input tensors
print_tensor(src1);
print_tensor(src2);
// Run etc ...
// Print output tensor
print_tensor(dest);
Hi @rohit-unnimadhavan ,
maybe the issue is in the for loop of the copy per row.
Instead of:
memcpy((void *) ((uint8_t*)dstBase + y * imageWidth), dest.buffer() + dest.info()->offset_element_in_bytes(Coordinates(0,y)), imageWidth * sizeFormat3);
can you try:
memcpy((void *) ((uint8_t*)dstBase + y * imageWidth * sizeFormat3), dest.buffer() + dest.info()->offset_element_in_bytes(Coordinates(0,y)), imageWidth * sizeFormat3);
?
Hi @GeorgeARM ,
Sorry for the delay in reply.
I tried printing the tensors like you suggested and it seems the inputs are going properly and the output tensor itself is wrong. So, I think we can rule out the case of error while copying. I am attaching the log file for your reference.
Edit : Please note that I am printing the buffers in hex format from my application side.
Hi,
Is there any update to this issue?
I am attaching a sample code for Issue 2 (Wrap policy not working in CLArithmeticAddition for U8-U8). The code and the output are attached below. Could you please confirm whether the issue is reproduced at your end or not?
Also, the library is built on Linux platform using a proprietary toolchain. Could you please share the build details you are using?
Thanks, Rohit
Hello,
What platform are you trying to compile for? Is it targeting a Mali GPU? Does our validation suite fails if you run it on your platform?
Hi,
We are running this on a proprietary platform with non-Mali GPU. Based on the input for some other issues we raised in the page, we tried recreating the issue with one of the recommended toolchains. With gcc-linaro-4.9-2016.02-x86_64_aarch64-linux-gnu toolchain, we were able to see proper output for CLArithmeticAddition in U8-U8 wrap case. We will be taking this up with the platform vendor.
Thanks, Rohit
Closing this issue as it seems to be platform specific. Reopen if needed.