@@ -605,7 +605,7 @@ function calcZDim(cf::CalcFactor{T}) where {T <: AbstractFactor}
605605 M = getManifold (cf. factor)
606606 return manifold_dimension (M)
607607 catch
608- @warn " no method getManifold(::$T ), calcZDim will attempt legacy length(sample) method instead"
608+ @warn " no method getManifold(::$( string (T)) ), calcZDim will attempt legacy length(sample) method instead"
609609 end
610610 end
611611
@@ -626,22 +626,23 @@ function prepgenericconvolution(Xi::Vector{<:DFGVariable},
626626 multihypo:: Union{Nothing, Distributions.Categorical} = nothing ,
627627 nullhypo:: Real = 0.0 ,
628628 threadmodel= MultiThreaded,
629- inflation:: Real = 0.0 ) where {T <: FunctorInferenceType }
629+ inflation:: Real = 0.0 ,
630+ _blockRecursion:: Bool = false ) where {T <: AbstractFactor }
630631 #
631632 pttypes = getVariableType .(Xi) .| > getPointType
632633 PointType = 0 < length (pttypes) ? pttypes[1 ] : Vector{Float64}
633634 # FIXME stop using Any, see #1321
634- varParams = Vector {Vector{Any}} ()
635- maxlen, sfidx, mani = prepareparamsarray! (varParams , Xi, nothing , 0 ) # Nothing for init.
635+ varParamsAll = Vector {Vector{Any}} ()
636+ maxlen, sfidx, mani = prepareparamsarray! (varParamsAll , Xi, nothing , 0 ) # Nothing for init.
636637
637638 # standard factor metadata
638639 sflbl = 0 == length (Xi) ? :null : getLabel (Xi[end ])
639- fmd = FactorMetadata (Xi, getLabel .(Xi), varParams , sflbl, nothing )
640+ fmd = FactorMetadata (Xi, getLabel .(Xi), varParamsAll , sflbl, nothing )
640641
641642 # create a temporary CalcFactor object for extracting the first sample
642643 # TODO , deprecate this: guess measurement points type
643644 # MeasType = Vector{Float64} # FIXME use `usrfnc` to get this information instead
644- _cf = CalcFactor ( usrfnc, fmd, 0 , 1 , nothing , varParams ) # (Vector{MeasType}(),)
645+ _cf = CalcFactor ( usrfnc, fmd, 0 , 1 , nothing , varParamsAll ) # (Vector{MeasType}(),)
645646
646647 # get a measurement sample
647648 meas_single = sampleFactor (_cf, 1 )
@@ -662,19 +663,25 @@ function prepgenericconvolution(Xi::Vector{<:DFGVariable},
662663 varTypes:: Vector{DataType} = typeof .(getVariableType .(Xi))
663664 gradients = nothing
664665 # prepare new cached gradient lambdas (attempt)
665- # try
666- # measurement = tuple(((x->x[1]).(meas_single))...)
667- # pts = tuple(((x->x[1]).(varParams))...)
668- # gradients = FactorGradientsCached!(usrfnc, varTypes, measurement, pts);
669- # catch e
670- # @warn "Unable to create measurements and gradients for $usrfnc during prep of CCW, falling back on no-partial information assumption."
671- # end
666+ try
667+ if (! _blockRecursion) && usrfnc isa AbstractRelative
668+ # take first value from each measurement-tuple-element
669+ measurement_ = map (x-> x[1 ], meas_single)
670+ # take the first value from each variable param
671+ pts_ = map (x-> x[1 ], varParamsAll)
672+ # FIXME , only using first meas and params values at this time...
673+ # NOTE, must block recurions here, since FGC uses this function to calculate numerical gradients on a temp fg.
674+ gradients = FactorGradientsCached! (usrfnc, tuple (varTypes... ), measurement_, tuple (pts_... ), _blockRecursion= true );
675+ end
676+ catch e
677+ @warn " Unable to create measurements and gradients for $usrfnc during prep of CCW, falling back on no-partial information assumption."
678+ end
672679
673680 ccw = CommonConvWrapper (
674681 usrfnc,
675682 PointType[],
676683 zdim,
677- varParams ,
684+ varParamsAll ,
678685 fmd,
679686 specialzDim = hasfield (T, :zDim ),
680687 partial = ispartl,
@@ -707,15 +714,16 @@ function getDefaultFactorData(dfg::AbstractDFG,
707714 potentialused:: Bool = false ,
708715 edgeIDs = Int[],
709716 solveInProgress = 0 ,
710- inflation:: Real = getSolverParams (dfg). inflation ) where T <: FunctorInferenceType
717+ inflation:: Real = getSolverParams (dfg). inflation,
718+ _blockRecursion:: Bool = false ) where T <: FunctorInferenceType
711719 #
712720
713721 # prepare multihypo particulars
714722 # storeMH::Vector{Float64} = multihypo == nothing ? Float64[] : [multihypo...]
715723 mhcat, nh = parseusermultihypo (multihypo, nullhypo)
716724
717725 # allocate temporary state for convolutional operations (not stored)
718- ccw = prepgenericconvolution (Xi, usrfnc, multihypo= mhcat, nullhypo= nh, threadmodel= threadmodel, inflation= inflation)
726+ ccw = prepgenericconvolution (Xi, usrfnc, multihypo= mhcat, nullhypo= nh, threadmodel= threadmodel, inflation= inflation, _blockRecursion = _blockRecursion )
719727
720728 # and the factor data itself
721729 return FunctionNodeData {typeof(ccw)} (eliminated, potentialused, edgeIDs, ccw, multihypo, ccw. certainhypo, nullhypo, solveInProgress, inflation)
@@ -1188,7 +1196,8 @@ function DFG.addFactor!(dfg::AbstractDFG,
11881196 threadmodel= SingleThreaded,
11891197 suppressChecks:: Bool = false ,
11901198 inflation:: Real = getSolverParams (dfg). inflation,
1191- namestring:: Symbol = assembleFactorName (dfg, Xi) )
1199+ namestring:: Symbol = assembleFactorName (dfg, Xi),
1200+ _blockRecursion:: Bool = false )
11921201 #
11931202 # depcrecation
11941203
@@ -1199,7 +1208,8 @@ function DFG.addFactor!(dfg::AbstractDFG,
11991208 multihypo= multihypo,
12001209 nullhypo= nullhypo,
12011210 threadmodel= threadmodel,
1202- inflation= inflation)
1211+ inflation= inflation,
1212+ _blockRecursion= _blockRecursion)
12031213 newFactor = DFGFactor (Symbol (namestring),
12041214 varOrderLabels,
12051215 solverData;
0 commit comments