Sha256: 25b05a1bec0b976de1d2abee745d048241c3ac9bf2d720fdc00e3976d0de115c

Contents?: true

Size: 1.72 KB

Versions: 2

Compression:

Stored size: 1.72 KB

Contents

module Xgb
  module FFI
    extend ::FFI::Library

    begin
      ffi_lib Xgb.ffi_lib
    rescue LoadError => e
      raise e if ENV["XGB_DEBUG"]
      raise LoadError, "Could not find XGBoost"
    end

    # https://github.com/dmlc/xgboost/blob/master/include/xgboost/c_api.h
    # keep same order

    # error
    attach_function :XGBGetLastError, %i[], :string

    # dmatrix
    attach_function :XGDMatrixCreateFromMat, %i[pointer uint64 uint64 float pointer], :int
    attach_function :XGDMatrixSetGroup, %i[pointer pointer uint64], :int
    attach_function :XGDMatrixNumRow, %i[pointer pointer], :int
    attach_function :XGDMatrixNumCol, %i[pointer pointer], :int
    attach_function :XGDMatrixSliceDMatrix, %i[pointer pointer uint64 pointer], :int
    attach_function :XGDMatrixFree, %i[pointer], :int
    attach_function :XGDMatrixSaveBinary, %i[pointer string int], :int
    attach_function :XGDMatrixSetFloatInfo, %i[pointer string pointer uint64], :int
    attach_function :XGDMatrixGetFloatInfo, %i[pointer string pointer pointer], :int

    # booster
    attach_function :XGBoosterCreate, %i[pointer int pointer], :int
    attach_function :XGBoosterUpdateOneIter, %i[pointer int pointer], :int
    attach_function :XGBoosterEvalOneIter, %i[pointer int pointer pointer uint64 pointer], :int
    attach_function :XGBoosterFree, %i[pointer], :int
    attach_function :XGBoosterSetParam, %i[pointer string string], :int
    attach_function :XGBoosterPredict, %i[pointer pointer int int pointer pointer], :int
    attach_function :XGBoosterLoadModel, %i[pointer string], :int
    attach_function :XGBoosterSaveModel, %i[pointer string], :int
    attach_function :XGBoosterDumpModelEx, %i[pointer string int string pointer pointer], :int
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
xgb-0.1.3 lib/xgb/ffi.rb
xgb-0.1.2 lib/xgb/ffi.rb