Rgb2GrayScaleMatMul
class Rgb2GrayScaleMatMul(constCtx: ExecutionContext) : Model<FP16, Float, Tensor<FP16, Float>, Tensor<FP16, Float>> (source)
Color Space Transformation: RGB → Grayscale using direct tensor multiplication (no conv).
Implements the NumPy-equivalent operation per pixel: weights = 0.2989, 0.5870, 0.1140 gray = (H*W x 3) @ weights → reshape(H, W)
Here we avoid any convolution and compute a weighted sum across the channel dimension: (N,3,H,W) * (1,3,1,1) -> sum over channel dim (1) -> (N,1,H,W)
Expected input shape: (N, 3, H, W) Output shape: (N, 1, H, W)
Functions
Link copied to clipboard
open suspend override fun calculate(module: Module<FP16, Float>, inputValue: Tensor<FP16, Float>, executionContext: ExecutionContext, reportProgress: suspend (current: Int, total: Int, message: String?) -> Unit): Tensor<FP16, Float>
Implement this in your models. Call reportProgress whenever you want to emit a progress update.