Predict

Predict 1:

Syntax

Definition:

METHOD Predict : BOOL
VAR_INPUT
    pDataInp       : PVOID;
    nDataInpDim    : UDINT;
    fmtDataInpType : ETcMllDataType;
    pDataOut       : PVOID;
    nDataOutDim    : UDINT;
    fmtDataOutType : ETcMllDataType;
    nEngineId      : UDINT;
    nConcurrencyId : UDINT;
END_VAR

Predict 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

nEngineId

UDINT

Id 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.

Predict 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 Predict 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;
nCurrentEngineID : UDINT := 0;
nConcurrencyId : UDINT := 0;
fbprediction.Predict(
        pDataInp:=ADR(nInput) , 
        nDataInpDim:= nInputDim, 
        fmtDataInpType:= dtype, 
        pDataOut:=ADR(nOutput) , 
        nDataOutDim:= nOutputDim, 
        fmtDataOutType:= dtype, 
        nEngineId:= nCurrentEngineID, 
        nConcurrencyId:= nConcurrencyId );