@@ -545,16 +545,15 @@ permuted = permutedims(tile, (3, 1, 2)) # Shape (4, 2, 3)
545545
546546Permute a 2D tile, swapping its dimensions. Defaults to permutation `(2, 1)`.
547547
548- Differs from `transpose` in that the operation is not recursive. For tiles
549- of numeric element types, the two operations are equivalent.
548+ Equivalent to `transpose`.
550549
551550---
552551
553552 permutedims(tile::Tile{T, (N,)}) -> Tile{T, (1, N)}
554553
555554Reshape a 1D tile into a `1 × N` row tile.
556555
557- Differs from `transpose` in that the operation is not recursive .
556+ Equivalent to `transpose`.
558557"""
559558@generated function Base. permutedims (tile:: T ) where {T <: Tile }
560559 n = ndims (T)
@@ -573,10 +572,27 @@ end
573572 transpose(tile::Tile{T, (M, N)}) -> Tile{T, (N, M)}
574573
575574Transpose a 2D tile, swapping its dimensions.
576- Equivalent to `permute(tile, (2, 1))`.
575+
576+ ---
577+
578+ transpose(tile::Tile{T, (N,)}) -> Tile{T, (1, N)}
579+
580+ Reshape a 1D tile into a `1 × N` row tile.
581+
582+ Equivalent to single-arg `permutedims`.
577583"""
578- @inline Base. transpose (tile:: Tile{T} ) where {T} =
579- Intrinsics. transpose (tile)
584+ @generated function Base. transpose (tile:: T ) where {T <: Tile }
585+ n = ndims (T)
586+ first_dim = n >= 1 ? size (T, 1 ) : nothing
587+
588+ if n == 2
589+ return :(Intrinsics. permute (tile, (1 , 0 )))
590+ elseif n == 1
591+ return :(Intrinsics. reshape (tile, (1 , $ first_dim)))
592+ else
593+ return :(throw (ArgumentError (" transpose(tile) only works for 1D or 2D tiles" )))
594+ end
595+ end
580596
581597@inline Base. convert (:: Type{Tile{T2}} , tile:: Tile{T1, Shape} ) where {T1, T2, Shape} =
582598 map (T2, tile)
0 commit comments