Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Rapidsai Cuml FIL Postproc Ops

From Leeroopedia
Revision as of 16:26, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Rapidsai_Cuml_FIL_Postproc_Ops.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Machine_Learning, Forest_Inference
Last Updated 2026-02-08 12:00 GMT

Overview

Defines enumerations for element-wise and row-wise post-processing operations applied to Forest Inference Library (FIL) model outputs.

Description

This header provides two enum types within the ML::fil namespace that control how raw tree ensemble outputs are post-processed before returning predictions:

  • row_op: Row-wise operations applied across all output columns of a single sample. Encoded as bit flags:
    • disable (0b00100000): No row-wise post-processing.
    • softmax (0b01000000): Apply softmax normalization across the row (used for multi-class classification).
    • max_index (0b10000000): Return the index of the maximum value in the row (argmax for class prediction).
  • element_op: Element-wise operations applied to each individual output value. Encoded as bit flags:
    • disable (0b00000000): No element-wise post-processing.
    • signed_square (0b00000001): Compute sign-preserving square (sign(x) * x^2).
    • hinge (0b00000010): Apply hinge function (max(0, x) or similar threshold).
    • sigmoid (0b00000100): Apply sigmoid (logistic) transformation.
    • exponential (0b00001000): Apply exponential transformation.
    • logarithm_one_plus_exp (0b00010000): Apply log(1 + exp(x)) (softplus).

The bit-flag encoding allows these operations to be combined and efficiently dispatched in GPU kernels.

Usage

Use these enums when configuring FIL inference to specify how raw tree ensemble scores should be transformed into final predictions. For example, use element_op::sigmoid for binary classification probabilities and row_op::softmax with row_op::max_index for multi-class classification.

Code Reference

Source Location

  • Repository: Rapidsai_Cuml
  • File: cpp/include/cuml/fil/postproc_ops.hpp

Signature

namespace ML {
namespace fil {

enum struct row_op : unsigned char {
  disable   = 0b00100000,
  softmax   = 0b01000000,
  max_index = 0b10000000
};

enum struct element_op : unsigned char {
  disable                = 0b00000000,
  signed_square          = 0b00000001,
  hinge                  = 0b00000010,
  sigmoid                = 0b00000100,
  exponential            = 0b00001000,
  logarithm_one_plus_exp = 0b00010000
};

}  // namespace fil
}  // namespace ML

Import

#include <cuml/fil/postproc_ops.hpp>

I/O Contract

Inputs

Name Type Required Description
(N/A -- these are enum definitions)

Outputs

Name Type Description
row_op enum struct (unsigned char) Enumerator value selecting the row-wise post-processing operation
element_op enum struct (unsigned char) Enumerator value selecting the element-wise post-processing operation

Enum Values

row_op

Enumerator Bit Pattern Description
disable 0b00100000 No row-wise operation
softmax 0b01000000 Softmax normalization across the row
max_index 0b10000000 Return index of the maximum value (argmax)

element_op

Enumerator Bit Pattern Description
disable 0b00000000 No element-wise operation
signed_square 0b00000001 Sign-preserving square transformation
hinge 0b00000010 Hinge (thresholding) transformation
sigmoid 0b00000100 Sigmoid (logistic) transformation
exponential 0b00001000 Exponential transformation
logarithm_one_plus_exp 0b00010000 Softplus: log(1 + exp(x))

Usage Examples

#include <cuml/fil/postproc_ops.hpp>

void configure_fil_postprocessing() {
    // For binary classification: apply sigmoid to raw scores
    auto elem_op = ML::fil::element_op::sigmoid;
    auto r_op    = ML::fil::row_op::disable;

    // For multi-class classification: apply softmax then argmax
    auto elem_op_multi = ML::fil::element_op::disable;
    auto r_op_multi    = ML::fil::row_op::softmax;
    // Or to get the predicted class index directly:
    auto r_op_argmax   = ML::fil::row_op::max_index;

    // Pass these enum values to FIL inference configuration...
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment