generateDenseLayerWithAccuracy
fun generateDenseLayerWithAccuracy(node: GraphNode, addNode: GraphNode? = null, denseIndex: Int? = null): LayerCode(source)
Generates C code for Dense layer operations with exact numerical consistency. Follows existing DefaultCpuOps implementation patterns for matrix-vector multiplication.
The generated code implements: output = input * weight^T + bias This matches the Linear layer forward pass: input.matmul(weight.t()) + bias
Enhanced for numerical accuracy by:
Using consistent floating-point operations with DefaultCpuOps
Implementing proper accumulation order to minimize floating-point errors
Adding bounds checking for array access safety
Ensuring direct output writing optimization when possible
Return
LayerCode containing generated C code fragment
Parameters
node
GraphNode representing a Dense/Linear layer