Skip to content

Commit f53359f

Browse files
authored
Adding support for Asin (#122)
1 parent d5772b8 commit f53359f

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

src/load.jl

+3
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ function load_node!(tape::Tape, ::OpConfig{:ONNX, :ConstantOfShape}, args::VarVe
9999
return push_call!(tape, makeshape, args...; attrs...)
100100
end
101101

102+
function load_node!(tape::Tape, ::OpConfig{:ONNX, :Asin}, args::VarVec, attrs::AttrDict)
103+
return push_call!(tape, _asin, args[1])
104+
end
102105

103106
function load_node!(tape::Tape, nd::NodeProto, backend::Symbol)
104107
args = [tape.c.name2var[name] for name in nd.input]

src/ops.jl

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ _cos(x) = cos.(x)
8888
_abs(x) = abs.(x)
8989
_acos(x) = acos.(x)
9090
_acosh(x) = acosh.(x)
91+
_asin(x) = asin.(x)
9192
mul(xs...) = .*(xs...)
9293
relu(x) = NNlib.relu.(x)
9394
leakyrelu(x;a = 0.01) = NNlib.leakyrelu.(x,a)

src/save.jl

+5
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ function save_node!(g::GraphProto, ::OpConfig{:ONNX, typeof(makeshape)}, op::Uml
176176
push!(g.node, nd)
177177
end
178178

179+
function save_node!(g::GraphProto, ::OpConfig{:ONNX, typeof(_asin)}, op::Umlaut.Call)
180+
nd = NodeProto("Asin", op)
181+
push!(g.node, nd)
182+
end
183+
179184
function save_node!(g::GraphProto, ::OpConfig{:ONNX, typeof(*)}, op::Umlaut.Call)
180185
nd = NodeProto(
181186
input=[onnx_name(v) for v in reverse(op.args)],

test/saveload.jl

+8
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ import ONNX: NodeProto, ValueInfoProto, AttributeProto, onnx_name
6060
ort_test(ONNX._acosh, A)
6161
end
6262

63+
@testset "Asin" begin
64+
# ONNXRunTime has no implementation for Asin(x::Float64), using Float32
65+
A = rand(Float32, 3, 4)
66+
# Asin defined for |A| <= 1
67+
A = A .% 1
68+
ort_test(ONNX._asin, A)
69+
end
70+
6371
@testset "Transpose" begin
6472
# ort_test() checks for expected output of functions, errors on Transpose
6573
# because of array shape; manually testing!

0 commit comments

Comments
 (0)