PredictRef

PredictRef 1:

Syntax

Definition:

METHOD PredictRef : BOOL
VAR_INPUT
    pDataInp       : PVOID;
    nDataInpDim    : UDINT;
    fmtDataInpType : ETcMllDataType;
    pDataOut       : PVOID;
    nDataOutDim    : UDINT;
    fmtDataOutType : ETcMllDataType;
    sEngineRef     : T_MaxString;
    nConcurrencyId : UDINT;
END_VAR

PredictRef 2: Inputs

Name

Type

Description

pDataInp

PVOID

Pointer to the input data array (e.g. ARRAY[0..10] OF REAL in PLC)

nDataInpDim

UDINT

Number of inputs in the current vector

fmtDataInpType

ETcMllDataType

ETcMllDataType data type of input array

pDataOut

PVOID

Pointer to the output data array (e.g. ARRAY[0..10] OF REAL in PLC)

nDataOutDim

UDINT

Number of outputs in the current vector

fmtDataOutType

ETcMllDataType

ETcMllDataType data type of output array

sEngineRef

T_MaxString

Reference string of model engine (or parameter set) used for prediction, use default value 0 if there are no multi-engines used

nConcurrencyId

UDINT

Id of the processing thread. Important: Never have two concurrently processing threads use the same id.

PredictRef 3: Return value

BOOL

The method performs the inference of the loaded model with the given input data and stores the result in the output data. Use configure method to load a ML model description file before calling PredictRef method.

For the inputs and outputs a pointer, the number of inputs/outputs and the data type are needed.

Sample call:

dtype      : ETcMllDataType.E_MLLDT_FP32_REAL;
nInputDim  : UDINT := 3;
nOutputDim : UDINT := 2;
nInput     : ARRAY[1..3] OF REAL;
nOutput    : ARRAY[1..2] OF REAL;
sCurrentEngineRef: T_MaxString := 'EngineRef';
nConcurrencyId : UDINT := 0;
fbprediction.Predict(
        pDataInp:=ADR(nInput) , 
        nDataInpDim:= nInputDim, 
        fmtDataInpType:= dtype, 
        pDataOut:=ADR(nOutput) , 
        nDataOutDim:= nOutputDim, 
        fmtDataOutType:= dtype, 
        sEngineRef:= sCurrentEngineRef, 
        nConcurrencyId:= nConcurrencyId );