diff --git a/src/backend/tensorflow/graph.jl b/src/backend/tensorflow/graph.jl index 71499ac8..63c4f4e2 100644 --- a/src/backend/tensorflow/graph.jl +++ b/src/backend/tensorflow/graph.jl @@ -27,9 +27,11 @@ graph(::typeof(max), x, dim=nothing) = TensorFlow.reduce_max(x;axis=dim) graph(::typeof(all), x, dim=nothing) = TensorFlow.reduce_all(x;axis=dim) graph(::typeof(any), x, dim=nothing) = TensorFlow.reduce_any(x;axis=dim) graph(::typeof(mean), x, dim=nothing) = TensorFlow.reduce_mean(x;axis=dim) +graph(::typeof(svd), x) = svd(x) for op in (*, .*, .+, .^, log, exp, ceil, floor, sqrt, abs, cos, - sin, tan, atan, asin, acos, tanh, lgamma, erf, erfc, real, imag, conj) + sin, tan, atan, asin, acos, tanh, lgamma, erf, erfc, real, imag, conj, + inv, det) @eval graph(::typeof($op), args...) = $op(args...) end diff --git a/test/backend/tensorflow.jl b/test/backend/tensorflow.jl index 00f45c95..178de761 100644 --- a/test/backend/tensorflow.jl +++ b/test/backend/tensorflow.jl @@ -23,4 +23,12 @@ test_anon(tf) @test run(sess, Y, Dict(X=>xs)) ≈ d(xs) end +@testset "Ops" begin + A = randn(Float32,(5,5)) + u,s,v = tf(@net x -> svd(x))(A) + @test A ≈ u*diagm(s)*transpose(v) + @test tf(@net x -> inv(x))(A) ≈ inv(A) + @test tf(@net x -> det(x))(A) ≈ det(A) +end + end