From 7559196ab979342cd7a62fe9ed0b74f0fe1c07d6 Mon Sep 17 00:00:00 2001 From: Ali Hamdi Date: Fri, 9 Jun 2017 21:42:38 +0200 Subject: [PATCH] add size --- src/backend/tensorflow/graph.jl | 2 ++ test/backend/tensorflow.jl | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/backend/tensorflow/graph.jl b/src/backend/tensorflow/graph.jl index 6c4ca052..2f0f21ad 100644 --- a/src/backend/tensorflow/graph.jl +++ b/src/backend/tensorflow/graph.jl @@ -28,6 +28,8 @@ 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) +graph(::typeof(size), x, dim) = TensorFlow.size(x,convert(Tensor{Int32}, dim)) +graph(::typeof(size), x) = TensorFlow.size(x) for op in (*, .*, .+, .^, log, exp, ceil, floor, sqrt, abs, cos, sin, tan, atan, asin, acos, tanh, lgamma, erf, erfc, real, imag, conj, diff --git a/test/backend/tensorflow.jl b/test/backend/tensorflow.jl index b0de468b..86867d31 100644 --- a/test/backend/tensorflow.jl +++ b/test/backend/tensorflow.jl @@ -41,6 +41,9 @@ end @test tf(@net x -> diag(x))(A) ≈ diag(A) A = randn(Float32,(5,)) @test tf(@net x -> diagm(x))(A) ≈ diagm(A) + A = randn(4,5) + @test tf(@net x -> size(x))(A) == [4,5] + @test tf(@net (x,y) -> size(x,y))(A,1) == 4 end end