From 6dfb554e956994df48dda4673e4f588fbf68f838 Mon Sep 17 00:00:00 2001 From: Ali Hamdi Date: Fri, 9 Jun 2017 21:17:54 +0200 Subject: [PATCH] add diag --- src/backend/tensorflow/graph.jl | 2 +- test/backend/tensorflow.jl | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/tensorflow/graph.jl b/src/backend/tensorflow/graph.jl index 425fc578..32f1cf60 100644 --- a/src/backend/tensorflow/graph.jl +++ b/src/backend/tensorflow/graph.jl @@ -31,7 +31,7 @@ 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, - inv, det, transpose, permutedims, cat, length) + inv, det, transpose, permutedims, cat, length, diag) @eval graph(::typeof($op), args...) = $op(args...) end diff --git a/test/backend/tensorflow.jl b/test/backend/tensorflow.jl index 1d73cdb8..1a41e5d8 100644 --- a/test/backend/tensorflow.jl +++ b/test/backend/tensorflow.jl @@ -37,6 +37,8 @@ end A2 = randn(Float32,(4,1)) @test tf(@net (x,y) -> cat(2,x,y))(A1,A2) ≈ cat(2,A1,A2) @test tf(@net x -> length(x))(A1) == length(A1) + A = randn(Float32,(5,5)) + @test tf(@net x -> diag(x))(A) ≈ diag(A) end end