Class OnnxFeatureExtractor

java.lang.Object
com.helix.core.ml.OnnxFeatureExtractor

public class OnnxFeatureExtractor extends Object
Extracts and transforms runtime execution context features into native ONNX tensor buffers.

Validates schema alignment against OnnxModelDescriptor.inputFeatures(), safely coerces mixed numeric and boolean types into single-precision float representations, and constructs zero-copy 2D arrays ready for OnnxTensor allocation.

  • Constructor Details

    • OnnxFeatureExtractor

      public OnnxFeatureExtractor()
  • Method Details

    • extractFeatures

      public float[] extractFeatures(OnnxModelDescriptor descriptor, ExecutionContext context)
      Extracts an ordered feature vector for a single execution context.
      Parameters:
      descriptor - target ONNX model descriptor
      context - runtime evaluation context
      Returns:
      1D float array of model input features
      Throws:
      IllegalArgumentException - if a required feature is missing or cannot be coerced to float
    • extractBatchFeatures

      public float[][] extractBatchFeatures(OnnxModelDescriptor descriptor, List<ExecutionContext> contexts)
      Extracts an ordered 2D batch feature matrix for multiple execution contexts.
      Parameters:
      descriptor - target ONNX model descriptor
      contexts - list of execution contexts
      Returns:
      2D float array with shape [batch_size, feature_count]
    • createTensor

      public ai.onnxruntime.OnnxTensor createTensor(ai.onnxruntime.OrtEnvironment env, OnnxModelDescriptor descriptor, ExecutionContext context) throws ai.onnxruntime.OrtException
      Constructs a native OnnxTensor for a single-row inference request.
      Parameters:
      env - active ONNX Runtime environment
      descriptor - target ONNX model descriptor
      context - single evaluation context
      Returns:
      allocated native ONNX tensor buffer with shape [1, feature_count]
      Throws:
      ai.onnxruntime.OrtException - if native tensor allocation fails
    • createTensor

      public ai.onnxruntime.OnnxTensor createTensor(ai.onnxruntime.OrtEnvironment env, OnnxModelDescriptor descriptor, List<ExecutionContext> contexts) throws ai.onnxruntime.OrtException
      Constructs a native OnnxTensor for a batch inference request.
      Parameters:
      env - active ONNX Runtime environment
      descriptor - target ONNX model descriptor
      contexts - batch of evaluation contexts
      Returns:
      allocated native ONNX tensor buffer with shape [batch_size, feature_count]
      Throws:
      ai.onnxruntime.OrtException - if native tensor allocation fails