API
#
Base.getindex
— Method
getindex(tape::Tape{ONNXCtx}, onnx_name::String)
Get operation on the tape using the name in ONNX graph
#
ONNX.array
— Function
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
#
ONNX.attribute
— Method
attribute(p::AttributeProto)
Return attribute in p
as a name => value pair.
#
ONNX.from_nnlib_spatial
— Method
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
#
ONNX.graphproto
— Method
graphproto()
Return an ONNX.GraphProto
with all fields initialized to empty arrays.
#
ONNX.load
— Method
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.onnx_gather
— Method
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
.
#
ONNX.push_call!
— Method
push_call!(tape::Tape{ONNXCtx}, fn, args...; kwargs)
Shortcut for push!(tape, mkcall(fn, args..))
also handling keyword arguments and respecting ONNXCtx.exec
setting.
#
ONNX.rename_keys
— Method
rename_keys(dict::Dict, subs::Dict)
Create a copy of dict
, replacing its keys according to mapping subs
#
ONNX.save
— Method
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!
#
ONNX.save_node!
— Method
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.
#
ONNX.take
— Method
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() .
|
#
ONNX.unpacked_vars
— Method
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]