MarkLogic 10 Product Documentation
ort:run

ort:run(
   $session as node,
   $inputs as node,
   [$options as map:map]
) as map:map

Summary

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

Parameters
$session An ort:session.
$inputs A map:map representing the input names and their values. Input names are obtained through the function ort:session-input-name, 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
log-verbosity-level xs: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 xs:string Any string Tag of this particular run of the session.

Example

  xquery version "1.0-ml";
  let $session := ort:session(fn:doc("testmodel.onnx"))
  let $input-count := ort:session-input-count($session)
  let $output-count := ort:session-output-count($session)
  let $input-names :=
    for $i in (0 to $input-count - 1) return ort:session-input-name($session,
$i) let $output-names := for $i in (0 to $output-count - 1) return
ort:session-output-name($session, $i) let $input-types := for $i in (0 to
$input-count - 1) return ort:session-input-type($session, $i) let $output-types
:= for $i in (0 to $output-count - 1) return ort:session-output-type($session,
$i)

  let $input-values :=
    for $i in (1 to $input-count)
    (: generate some arbitrary input data. :)
    let $data := (1 to fn:fold-left(function($a, $b) { $a * $b }, 1,
map:get($input-types, "shape"))) return ort:value($data, map:get($input-types,
"shape"), map:get($input-types, "tensor-type"))

  let $input-map := map:map()
  let $input-maps :=
    for $i in (1 to $input-count)
    return map:with($input-map, $input-names[$i], $input-values[$i])
  let $input-map := $input-maps[$input-count]
  return ort:run($session, $input-map)
  =>
  <map:map xmlns:map="http://marklogic.com/xdmp/map"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"> <map:entry key="output_0">
  <map:value xsi:type="ort:value"
xmlns:ort="http://marklogic.com/onnxruntime">OrtValue(Shape:[1, 1000, 1, 1],
Type: FLOAT)
  </map:value>
  </map:entry>
  </map:map>
Powered by MarkLogic Server | Terms of Use | Privacy Policy