Loading TOC...

ort.run

ort.run(
   session as Node,
   inputs as Node,
   [options as Object]
) as Object

Summary

Perform inference of a session, based on supplied input values. Returns an Object of output names and their values.

Parameters
session An ort.session.
inputs A Map representing the input names and their values. Input names are obtained through the function ort.sessionInputName, input values are constructed using ort.Value.
options Options used to perform inference of the session. Possible values are:
Key Name Value Type Possible Values Details
logVerbosityLevel String VERBOSE, INFO, WARNING, ERROR, FATAL VERBOSE level logs of ort session will be logged when MarkLogic's log level is Fine or higher. WARNING level logs of ort session will be logged when MarkLogic's log level is Debug or higher. INFO level logs of ort session will be logged when MarkLogic's log level is Info or higher. ERROR level logs of ort session will be logged when MarkLogic's log level is Error or higher. FATAL level logs of ort session will be logged when MarkLogic's log level is Emergency or higher.
tag String Any string Tag of this particular run of the session.

Example

  const session = ort.session(cts.doc("testmodel.onnx"))
  const inputCount = ort.sessionInputCount(session)
  const outputCount = ort.sessionOutputCount(session)
  var inputNames = []
  var i,j
  for (i=0;i<inputCount;i++){
    inputNames.push(ort.sessionInputName(session, i))
  }
  var outputNames = []
  for (i=0;i<outputCount;i++){
    outputNames.push(ort.sessionOutputName(session, i))
  }
  var inputTypes = []
  for (i=0;i<inputCount;i++){
    inputTypes.push(ort.sessionInputType(session, i))
  }
  var outputTypes = []
  for (i=0;i<outputCount;i++){
    outputTypes.push(ort.sessionOutputType(session, i))
  }

  var inputValues = []
  for (i=0;i<inputCount;i++){
    var p = 1
    for(j=0;j<inputTypes[i]["shape"].length;j++){
      p *= inputTypes[i]["shape"][j]
    }
    var data = []
    for(j=0;j<p;j++){
      data.push(j);
    }
    inputValues.push(ort.value(data, inputTypes[i]["shape"], "float"))
  }
  var inputMap = {}
  for (i=0;i<inputCount;i++){
    inputMap[inputNames[i]] = inputValues[i]
  }
  ort.run(session, inputMap)
  =>
  {
  "output_0": "OrtValue(Shape:[1, 1000, 1, 1], Type: FLOAT)"
  }

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.