Show / Hide Table of Contents

Delegate OrtValue.MapVisitor

A public delegate that will be invoked once with map keys and values. The delegate helps not to deal with the lifespan of intermediate OrtValues. Typically, when one uses GetValue() API, it creates a copy of OrtValue that points to the same buffer as keys or values. This API helps to deal with those temporary instances and avoid leaks.

According to ONNX standard map keys can be unmanaged types only (or strings). Those keys are contained in a single tensor within OrtValue keys. So you can query those directly from keys argument.

Map values, on the other hand, can be composite types. The values parameter can either contain a single tensor with unmanaged map values with the same number of elements as the keys, or it can be a sequence of OrtValues, each of those can be a composite type (tensor, sequence, map). If it is a sequence, then the number of elements must match the number of elements in keys.

Depending on the structure of the values, one will either directly query a single tensor from values, or will have to iterate over the sequence of OrtValues and visit each of those resulting in a recursive visitation.

Namespace: Microsoft.ML.OnnxRuntime
Assembly: Microsoft.ML.OnnxRuntime.dll
Syntax
public delegate void MapVisitor(OrtValue keys, OrtValue values);
Parameters
Type Name Description
OrtValue keys

This would always represent a tensor

OrtValue values

Can be any of the Onnx types, but they would all reduce to tensors eventually

  • Improve this Doc
  • View Source
In This Article
Back to top