Skip to content

Commit 0eae8ed

Browse files
committed
fix: we don't need diag specialization
1 parent 3462b27 commit 0eae8ed

File tree

1 file changed

+0
-21
lines changed

1 file changed

+0
-21
lines changed

src/stdlibs/LinearAlgebra.jl

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -269,27 +269,6 @@ function LinearAlgebra.norm(x::TracedRArray{T,N}, p::Real=2) where {T,N}
269269
return mapreduce(Base.Fix2(^, p), +, x)^(1 / p)
270270
end
271271

272-
function LinearAlgebra.diag(x::AnyTracedRArray{T,2}, k::Integer=0) where {T}
273-
y = materialize_traced_array(x)
274-
275-
rows, cols = size(y)
276-
(start_row, start_col) = k 0 ? (0, k) : (-k, 0)
277-
diag_length = min(rows - start_row, cols - start_col)
278-
279-
indices = stack((
280-
start_row:(start_row + diag_length - 1), start_col:(start_col + diag_length - 1)
281-
))
282-
indices .+= 1
283-
284-
# XXX: creating an empty array causes
285-
# terminate called after throwing an instance of 'xla::XlaRuntimeError'
286-
# what(): UNKNOWN: <unknown>:0: error: 'tensor.empty' op unsupported op for export to XLA
287-
# <unknown>:0: note: see current operation: %0 = "tensor.empty"() : () -> tensor<0xf64>
288-
length(indices) 0 && return TracedUtils.promote_to(TracedRArray{T,1}, T[])
289-
290-
return Ops.gather_getindex(y, TracedUtils.promote_to(TracedRArray{Int,2}, indices))
291-
end
292-
293272
function LinearAlgebra._diagm(
294273
shape, kv::Pair{<:Integer,<:AnyTracedRArray{T,1}}...
295274
) where {T}

0 commit comments

Comments
 (0)