morousg / cvGPUSpeedup

A faster implementation of OpenCV-CUDA that uses OpenCV objects, and more!
Apache License 2.0
34 stars 5 forks source link

100 define an standard syntax for backwards vertical fusion #101

Closed morousg closed 2 months ago

morousg commented 2 months ago

We finally defined an stardard way to do Backwards Generic Vertical Fussion:

BackReadDeviceFunction: a Read DeviceFunction that has an instance (BackFunction) of a ReadDeviceFunction that will be used at some point of the ReadBackDeviceFunction implementation. That BackFunction can either be Read or ReadBack.

TernaryDeviceFunction: a non Read nor Write DeviceFunction, that has another non Read nor Write DeviceFunction instance (BackFunction) that will be used at some point of the TernaryDeviceFunction implementation.

Additionally, we created the utility function fuseDF, that allows to convert any DF sequence, into either a ReadDeviceFunction or a BinaryDeviceFunction, using internally the OperationTupleOperation.

This allows for the easy implementation of optimizations like clipping, when working with crop-resize in images, and we don't want to process all the source pixels. Plus, many times the images come in pixel formats that require less memory reads than RGB or RGBA, so we can only read the pixels we will need, in their original format, and in the same kernel, transform them into RGB/RGBA, interpolate, and do whatever we need with the resulting image (currently per pixel operations, but in the future we will be able to do things like reduction).

Other things that this will allow to do, is to have composable DeviceFunctions (TernaryDeviceFunctions) where part of the implementation can be defined with a seqüence/graph of DeviceFunctions.