Skip to content

Commit d984af9

Browse files
jmh5309il
authored andcommitted
Fix fastmath issues and other issues
1 parent a3b0786 commit d984af9

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

source/mir/ndslice/topology.d

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3070,7 +3070,7 @@ unittest
30703070
}
30713071

30723072
/// Transposed adjusted to ignore dim=0 and include universal
3073-
@fastmath private template adjTransposed(Dimensions...)
3073+
private template adjTransposed(Dimensions...)
30743074
if (Dimensions.length)
30753075
{
30763076
import mir.ndslice.slice : Slice, SliceKind;
@@ -3081,17 +3081,25 @@ unittest
30813081
alias adjTransposed = .adjTransposed!(staticMap!(toSize_t, Dimensions));
30823082
else
30833083
///
3084-
auto adjTransposed(SliceKind kind, size_t[] packs, Iterator)(Slice!(kind, packs, Iterator) slice)
3084+
@fastmath auto adjTransposed(SliceKind kind, size_t[] packs, Iterator)(Slice!(kind, packs, Iterator) slice)
30853085
{
30863086
import mir.ndslice.topology : ipack;
30873087
import mir.ndslice.internal : DimensionsCountCTError, DimensionCTError;
3088-
3088+
import mir.internal.utility : Iota;
3089+
30893090
mixin DimensionsCountCTError;
3090-
3091-
static if (Dimensions.length == 1 && Dimensions[0] == 0)
3091+
3092+
static if (Dimensions == Iota!(Dimensions.length))
30923093
{
30933094
return slice;
30943095
}
3096+
else static if (Dimensions[0] + 1 < packs[0] || packs.length > 1)
3097+
{
3098+
import mir.ndslice.topology : canonical;
3099+
import mir.ndslice.dynamic : transposed;
3100+
3101+
return slice.canonical.transposed!Dimensions;
3102+
}
30953103
else
30963104
{
30973105
import mir.ndslice.topology : universal;
@@ -3103,7 +3111,7 @@ unittest
31033111
}
31043112

31053113
///
3106-
@fastmath private auto adjTransposed(SliceKind kind, size_t[] packs, Iterator)
3114+
private auto adjTransposed(SliceKind kind, size_t[] packs, Iterator)
31073115
(Slice!(kind, packs, Iterator) slice)
31083116
{
31093117
return slice.adjTransposed!0;
@@ -3411,7 +3419,7 @@ unittest
34113419
}
34123420

34133421
// Ensure works on canonical packed slice
3414-
//@safe @nogc pure nothrow
3422+
@safe @nogc pure nothrow
34153423
unittest
34163424
{
34173425
import mir.ndslice.topology : iota, universal, flattened, reshape;
@@ -3523,7 +3531,7 @@ template byDim(Dimensions...)
35233531
alias byDim = .byDim!(staticMap!(toSize_t, Dimensions));
35243532
else
35253533
///
3526-
auto byDim(SliceKind kind, size_t[] packs, Iterator)
3534+
@fastmath auto byDim(SliceKind kind, size_t[] packs, Iterator)
35273535
(Slice!(kind, packs, Iterator) slice)
35283536
{
35293537
import mir.ndslice.topology : ipack;

0 commit comments

Comments
 (0)