Engee documentation

API

getindex(tape::Tape{ONNXCtx}, onnx_name::String)

Get operation on the tape using the name in ONNX graph

array(p::TensorProto, wrap=Array)

Return p as an Array of the correct type. Second argument can be used to change type of the returned array

attribute(p::AttributeProto)

Return attribute in p as a name => value pair.

from_nnlib(x)

Convert argument from NNlib-friendly to ONNX-friendly format. The reverse operation is available as from_onnx.

See also: from_onnx_conv, from_onnx_spatial, from_onnx_conv and similar.

from_nnlib_spatial(x, d)

Convert spatial attributes such as Conv’s stride or dilation from Julia to ONNX format.

x is a Julia values of that attribute d is the number of spatial dimensions

from_onnx(x)

The reverse of from_nnlib.

graphproto()

Return an ONNX.GraphProto with all fields initialized to empty arrays.

load(io::IO, model_args...; backends=[:ONNX], exec::Bool=true)
load(filename::String, model_args...; backends=[:ONNX], exec::Bool=true)

Load an ONNX model as a Umlaut.Tape. The way a particular ONNX node is deserialized is controlled by methods of load_node! dispatched by backend and node’s op_type.

backends parameter can be used to customize the loading process.

exec parameter instructs the loader to execute every added operation just after the addition, making the debugging easier. Default is true.

See also: save!

onnx_gather(data::AbstractArray, idxs::AbstractArray{Int}; dim=ndims(data))

Implemntation of ONNX’s Gather operation with 0-based indices. For a Julia-friendly version, see take.

push_call!(tape::Tape{ONNXCtx}, fn, args...; kwargs)

Shortcut for push!(tape, mkcall(fn, args..)) also handling keyword arguments and respecting ONNXCtx.exec setting.

rename_keys(dict::Dict, subs::Dict)

Create a copy of dict, replacing its keys according to mapping subs

save(io::IO, tape::Umlaut.Tape{ONNXCtx})
save(filename::String, tape::Umlaut.Tape{ONNXCtx})

Save tape as an ONNX model. The way a particular operation is serialized is controlled by methods of save_node!.

See also: load!

save_node!(g::GraphProto, op::Umlaut.Call)
save_node!(g::GraphProto, ::OpConfig{:Backend, Fn}, op::Umlaut.Call)

Serialize a single operation from a tape to graph.

take(data, idxs; dim=ndims(data))

Take elements from an array along an axis. For example, for a 4D data and dim=3, it is roughly equivalent to data[:, :, idxs, :], but allows multidimensional idxs. See numpy.take for a more detailed explanation of the concept.

In the context of ONNX, take is used to implement Gather operation. We do NOT record this function directly to the tape during loading though, but instead use a more ONNX-friendly wrapper onnx_gather().

in ONNX, Gather is different from GatherElements, GatherND and Julia’s NNlib.gather().
unpacked_vars(tape::Umlaut.Tape, op::Umlaut.Call)

For a multi-output call, find variables on the tape referring to elements of the output. Example:

import Umlaut: Tape, Input, mkcall

make_tuple(x) = (x, x + 1)

tape = Tape()
x = push!(tape, Input(1.0))
out = push!(tape, mkcall(make_tuple, x))
y1 = push!(tape, mkcall(getfield, out, 1))
y2 = push!(tape, mkcall(getfield, out, 2))

@assert unpacked_vars(tape, tape[out]) == [y1, y2]