Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/load.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ function load_node!(tape::Tape, ::OpConfig{:ONNX, :Equal}, args::VarVec, attrs::
return push_call!(tape, _equal, args...)
end

function load_node!(tape::Tape, ::OpConfig{:ONNX, :Neg}, args::VarVec, attrs::AttrDict)
return push_call!(tape, neg, args[1])
end

function load_node!(tape::Tape, nd::NodeProto, backend::Symbol)
args = [tape.c.name2var[name] for name in nd.input]
attrs = convert(Dict{Symbol, Any}, Dict(nd.attribute))
Expand Down
1 change: 1 addition & 0 deletions src/ops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ end

add(xs...) = .+(xs...)
sub(xs...) = .-(xs...)
neg(x) = .-(x)
_sin(x) = sin.(x)
_cos(x) = cos.(x)
_abs(x) = abs.(x)
Expand Down
5 changes: 5 additions & 0 deletions src/save.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ function save_node!(g::GraphProto, ::OpConfig{:ONNX, typeof(_equal)}, op::Umlaut
push!(g.node, nd)
end

function save_node!(g::GraphProto, ::OpConfig{:ONNX, typeof(neg)}, op::Umlaut.Call)
nd = NodeProto("Neg", op)
push!(g.node, nd)
end

function save_node!(g::GraphProto, ::OpConfig{:ONNX, typeof(*)}, op::Umlaut.Call)
nd = NodeProto(
input=[onnx_name(v) for v in reverse(op.args)],
Expand Down
5 changes: 5 additions & 0 deletions test/saveload.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ import ONNX: NodeProto, ValueInfoProto, AttributeProto, onnx_name
ort_test(ONNX._equal, A, B)
end

@testset "Neg" begin
A = rand(3, 4)
ort_test(ONNX.neg, A)
end

@testset "Gemm" begin
A, B, C = (rand(3, 4), rand(3, 4), rand(3, 3))
ort_test(ONNX.onnx_gemm, A, B')
Expand Down
Loading