|  | 
| 8 | 8 |         ), | 
| 9 | 9 |         T in (Float64, ComplexF64), | 
| 10 | 10 |         sz in [(3,), (3, 3), (3, 2, 1)] | 
|  | 11 | +println("starting unexported fnorm=$fnorm, T=$T, sz=$sz") | 
| 11 | 12 | 
 | 
| 12 | 13 |         x = randn(T, sz) | 
| 13 | 14 |         # finite differences is unstable if maxabs (minabs) values are not well | 
|  | 
| 37 | 38 |             @test rrule(fnorm, x)[2](Zero())[2] isa Zero | 
| 38 | 39 |         end | 
| 39 | 40 |         ndims(x) > 1 && @testset "non-strided" begin | 
|  | 41 | +println("... non-strided") | 
| 40 | 42 |             xp = if x isa Matrix | 
| 41 | 43 |                 view(x, [1,2,3], 1:3) | 
| 42 | 44 |             elseif x isa Array{T,3} | 
|  | 
| 51 | 53 |             rrule_test(fnorm, ȳ, (xp, x̄)) | 
| 52 | 54 |         end | 
| 53 | 55 |         T == Float64 && ndims(x) == 1 && @testset "Integer input" begin | 
|  | 56 | +println("... integer") | 
| 54 | 57 |             x = [1,2,3] | 
| 55 | 58 |             int_fwd, int_back = rrule(fnorm, x) | 
| 56 | 59 |             float_fwd, float_back = rrule(fnorm, float(x)) | 
|  | 
| 61 | 64 |     @testset "norm(x::Array{$T,$(length(sz))})" for | 
| 62 | 65 |         T in (Float64, ComplexF64), | 
| 63 | 66 |         sz in [(0,), (3,), (3, 3), (3, 2, 1)] | 
|  | 67 | +println("starting exported norm T=$T, sz=$sz") | 
| 64 | 68 | 
 | 
| 65 | 69 |         x = randn(T, sz) | 
| 66 | 70 | 
 | 
|  | 
| 84 | 88 |             @test rrule(norm, x)[2](Zero())[2] isa Zero | 
| 85 | 89 |         end | 
| 86 | 90 |         ndims(x) > 1 && @testset "non-strided" begin | 
|  | 91 | +println("... non-strided'") | 
| 87 | 92 |             xp = if x isa Matrix | 
| 88 | 93 |                 view(x, [1,2,3], 1:3) | 
| 89 | 94 |             elseif x isa Array{T,3} | 
|  | 
| 103 | 108 |         p in (1.0, 2.0, Inf, -Inf, 2.5), | 
| 104 | 109 |         T in (Float64, ComplexF64), | 
| 105 | 110 |         sz in (fnorm === norm ? [(0,), (3,), (3, 3), (3, 2, 1)] : [(3,), (3, 3), (3, 2, 1)]) | 
|  | 111 | +println("starting p-norm p=$p, T=$T, sz=$sz") | 
| 106 | 112 | 
 | 
| 107 | 113 |         x = randn(T, sz) | 
| 108 | 114 |         # finite differences is unstable if maxabs (minabs) values are not well | 
|  | 
| 142 | 148 |             @test unthunk(unthunk(int_back(1.0)[2])) ≈ unthunk(unthunk(float_back(1.0)[2])) | 
| 143 | 149 |         end | 
| 144 | 150 |     end | 
|  | 151 | +println("starting adjoint/transpose norm T=$T") | 
| 145 | 152 |     @testset "norm($fdual(::Vector{$T}), p)" for | 
| 146 | 153 |         T in (Float64, ComplexF64), | 
| 147 | 154 |         fdual in (adjoint, transpose) | 
|  | 
| 155 | 162 |     end | 
| 156 | 163 |     @testset "norm(x::$T, p)" for T in (Float64, ComplexF64) | 
| 157 | 164 |         @testset "p = $p" for p in (-1.0, 2.0, 2.5) | 
|  | 165 | +println("starting the other set of p-norm tests, p=$p, T=$T, sz=$sz") | 
| 158 | 166 |             test_frule(norm, randn(T), p) | 
| 159 | 167 |             test_rrule(norm, randn(T), p) | 
| 160 | 168 | 
 | 
| 161 | 169 |             _, back = rrule(norm, randn(T), p) | 
| 162 | 170 |             @test back(Zero()) == (NO_FIELDS, Zero(), Zero()) | 
| 163 | 171 |         end | 
| 164 | 172 |         @testset "p = 0" begin | 
|  | 173 | +println("starting 0-norm tests, T=$T, sz=$sz") | 
| 165 | 174 |             p = 0.0 | 
| 166 | 175 |             x = randn(T) | 
| 167 | 176 |             y = norm(x, p) | 
|  | 
0 commit comments