Skip to content

Commit 92f9595

Browse files
authored
Merge pull request #467 from MoonCoral/master
Make unary "-" work with @tf
2 parents c5aa7a8 + f044718 commit 92f9595

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/ops/math.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ function Base.round(::Type{T}, value::AbstractTensor) where T
167167
end
168168

169169

170-
-(n::AbstractTensor) = negative(n)
170+
@op function -(n::AbstractTensor; kwargs...)
171+
negative(n; kwargs...)
172+
end
171173

172174
@op function Base.complex(x_r::AbstractTensor, x_i::AbstractTensor; kwargs...)
173175
Ops.complex(x_r, x_i; kwargs...)

test/meta.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ end
6060
end
6161
end
6262

63-
63+
@testset "Negating and @tf" begin
64+
a = constant(1)
65+
@tf b = -a
66+
@test true # Above line would have errored if unary - didn't work with @tf
67+
end
6468

6569
@testset "Naming Big Demo" begin
6670
let

0 commit comments

Comments
 (0)