@@ -1006,30 +1006,6 @@ function __imfilter_inbounds!(r, out, A, kern, border, R, z)
1006
1006
out
1007
1007
end
1008
1008
1009
- # This is unfortunate, but specializing this saves an add in the inner
1010
- # loop and results in a modest performance improvement. It would be
1011
- # nice if LLVM did this automatically. (@polly?)
1012
- function __imfilter_inbounds! (r, out, A:: OffsetArray , kern:: OffsetArray , border, R, z)
1013
- off, k = CartesianIndex (kern. offsets), parent (kern)
1014
- o, O = safehead (off), safetail (off)
1015
- Rnew = CartesianIndices (map ((x,y)-> x.+ y, R. indices, Tuple (off)))
1016
- Rk = CartesianIndices (axes (k))
1017
- offA, pA = CartesianIndex (A. offsets), parent (A)
1018
- oA, OA = safehead (offA), safetail (offA)
1019
- for I in safetail (Rnew)
1020
- IA = I- OA
1021
- for i in safehead (Rnew)
1022
- tmp = z
1023
- iA = i- oA
1024
- @inbounds for J in safetail (Rk), j in safehead (Rk)
1025
- tmp += safe_for_prod (pA[iA+ j,IA+ J], tmp)* k[j,J]
1026
- end
1027
- @inbounds out[i- o,I- O] = tmp
1028
- end
1029
- end
1030
- out
1031
- end
1032
-
1033
1009
function _imfilter_inbounds! (r:: AbstractResource , out, A:: AbstractArray , kern:: ReshapedOneD , border:: NoPad , inds)
1034
1010
Rpre, ind, Rpost = iterdims (inds, kern)
1035
1011
k = kern. data
@@ -1042,64 +1018,21 @@ function _imfilter_inbounds!(r::AbstractResource, out, A::AbstractArray, kern::R
1042
1018
_imfilter_inbounds! (r, z, out, A, k, Rpre, ind, Rpost)
1043
1019
end
1044
1020
1045
- # Many of the following are unfortunate specializations
1046
- function _imfilter_inbounds! (r:: AbstractResource , z, out, A:: AbstractArray , k:: OffsetVector , Rpre:: CartesianIndices , ind, Rpost:: CartesianIndices )
1047
- _imfilter_inbounds! (r, z, out, A, parent (k), Rpre, ind, Rpost, k. offsets[1 ])
1048
- end
1049
-
1050
- function _imfilter_inbounds! (r:: AbstractResource , z, out, A:: AbstractArray , k:: AbstractVector , Rpre:: CartesianIndices , ind, Rpost:: CartesianIndices , koffset= 0 )
1051
- indsk = axes (k, 1 )
1052
- for Ipost in Rpost
1053
- for i in ind
1054
- ik = i+ koffset
1055
- for Ipre in Rpre
1056
- tmp = z
1057
- for j in indsk
1058
- @inbounds tmp += safe_for_prod (A[Ipre,ik+ j,Ipost], tmp)* k[j]
1059
- end
1060
- @inbounds out[Ipre,i,Ipost] = tmp
1061
- end
1062
- end
1063
- end
1064
- out
1065
- end
1066
-
1067
- function _imfilter_inbounds! (r:: AbstractResource , out, A:: OffsetArray , kern:: ReshapedVector , border:: NoPad , inds)
1068
- Rpre, ind, Rpost = iterdims (inds, kern)
1069
- k = kern. data
1070
- R, Rk = CartesianIndices (inds), CartesianIndices (axes (kern))
1071
- if isempty (R) || isempty (Rk)
1072
- return out
1073
- end
1074
- p = accumfilter (A[first (R)+ first (Rk)], first (k))
1075
- z = zero (typeof (p+ p))
1076
- Opre, o, Opost = KernelFactors. indexsplit (CartesianIndex (A. offsets), kern)
1077
- _imfilter_inbounds! (r, z, out, parent (A), k, Rpre, ind, Rpost, Opre, o, Opost)
1078
- end
1079
-
1080
- function _imfilter_inbounds! (r:: AbstractResource , z, out, A:: AbstractArray , k:: OffsetVector , Rpre:: CartesianIndices , ind, Rpost:: CartesianIndices , Opre, o, Opost)
1081
- _imfilter_inbounds! (r, z, out, A, parent (k), Rpre, ind, Rpost, Opre, o, Opost, k. offsets[1 ])
1082
- end
1083
-
1084
- function _imfilter_inbounds! (r:: AbstractResource , z, out, A:: AbstractArray , k:: AbstractVector , Rpre:: CartesianIndices , ind, Rpost:: CartesianIndices , Opre, o, Opost, koffset= 0 )
1021
+ function _imfilter_inbounds! (r:: AbstractResource , z, out, A:: AbstractArray , k:: AbstractVector , Rpre:: CartesianIndices , ind, Rpost:: CartesianIndices )
1085
1022
indsk = axes (k, 1 )
1086
1023
for Ipost in Rpost
1087
- IOpost = Ipost - Opost
1088
1024
for i in ind
1089
- io = i- o+ koffset
1090
1025
for Ipre in Rpre
1091
- IOpre = Ipre - Opre
1092
1026
tmp = z
1093
1027
for j in indsk
1094
- @inbounds tmp += safe_for_prod (A[IOpre,io + j,IOpost ], tmp)* k[j]
1028
+ @inbounds tmp += safe_for_prod (A[Ipre,i + j,Ipost ], tmp)* k[j]
1095
1029
end
1096
1030
@inbounds out[Ipre,i,Ipost] = tmp
1097
1031
end
1098
1032
end
1099
1033
end
1100
1034
out
1101
1035
end
1102
- # end unfortunate specializations
1103
1036
1104
1037
# # commented out because "virtual padding" is commented out
1105
1038
# function _imfilter_iter!(r::AbstractResource, out, padded, kernel::AbstractArray, iter)
0 commit comments