Skip to content

Commit 6304e4d

Browse files
committed
rename to AbstractFactorObservation and FactorOperationalMemory -> FactorSolverCache
1 parent d0dbc75 commit 6304e4d

11 files changed

Lines changed: 100 additions & 92 deletions

File tree

src/Common.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
_getmodule(t::T) where {T} = T.name.module
44
_getname(t::T) where {T} = T.name.name
55

6-
function convertPackedType(t::Union{T, Type{T}}) where {T <: AbstractFactor}
6+
function convertPackedType(t::Union{T, Type{T}}) where {T <: AbstractFactorObservation}
77
return getfield(_getmodule(t), Symbol("Packed$(_getname(t))"))
88
end
9-
function convertStructType(::Type{PT}) where {PT <: AbstractPackedFactor}
9+
function convertStructType(::Type{PT}) where {PT <: AbstractPackedFactorObservation}
1010
# see #668 for expanded reasoning. PT may be ::UnionAll if the type is of template type.
1111
ptt = PT isa DataType ? PT.name.name : PT
1212
moduleName = PT isa DataType ? PT.name.module : Main

src/Deprecated.jl

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
## ================================================================================
22
## Deprecated in v0.27
33
##=================================================================================
4+
export AbstractFactor
5+
const AbstractFactor = AbstractFactorObservation
6+
7+
export AbstractPackedFactor
8+
const AbstractPackedFactor = AbstractPackedFactorObservation
9+
10+
export FactorOperationalMemory
11+
const FactorOperationalMemory = FactorSolverCache
412

513
@deprecate getNeighborhood(args...; kwargs...) listNeighborhood(args...; kwargs...)
614
@deprecate addBlob!(store::AbstractBlobstore, blobId::UUID, data, ::String) addBlob!(
@@ -204,7 +212,7 @@ function FactorCompute(
204212
variableOrder::Union{Vector{Symbol}, Tuple};
205213
observation = getFactorType(solverData),
206214
state::FactorState = FactorState(),
207-
workmem::Base.RefValue{<:FactorOperationalMemory} = Ref{FactorOperationalMemory}(),
215+
solvercache::Base.RefValue{<:FactorSolverCache} = Ref{FactorSolverCache}(),
208216
id::Union{UUID, Nothing} = nothing,
209217
smallData::Dict{Symbol, SmallDataTypes} = Dict{Symbol, SmallDataTypes}(),
210218
)
@@ -223,19 +231,19 @@ function FactorCompute(
223231
smallData,
224232
observation,
225233
state,
226-
workmem,
234+
solvercache,
227235
)
228236
end
229237

230238
function getSolverData(f::FactorCompute)
231239
return error(
232-
"getSolverData(f::FactorCompute) is obsolete, use getState, getObservation, or getWorkmem instead",
240+
"getSolverData(f::FactorCompute) is obsolete, use getState, getObservation, or getCache instead",
233241
)
234242
end
235243

236244
function setSolverData!(f::FactorCompute, data::GenericFunctionNodeData)
237245
return error(
238-
"setSolverData!(f::FactorCompute, data::GenericFunctionNodeData) is obsolete, use setState!, or setWorkmem! instead",
246+
"setSolverData!(f::FactorCompute, data::GenericFunctionNodeData) is obsolete, use setState!, or setCache! instead",
239247
)
240248
end
241249

@@ -244,7 +252,7 @@ end
244252
skipVersionCheck,
245253
)
246254

247-
@deprecate rebuildFactorMetadata!(args...; kwargs...) rebuildFactorWorkmem!(
255+
@deprecate rebuildFactorMetadata!(args...; kwargs...) rebuildFactorCache!(
248256
args...;
249257
kwargs...,
250258
)
@@ -257,7 +265,7 @@ function decodePackedType(
257265
varOrder::AbstractVector{Symbol},
258266
::Type{T},
259267
packeddata::GenericFunctionNodeData{PT},
260-
) where {T <: FactorOperationalMemory, PT}
268+
) where {T <: FactorSolverCache, PT}
261269
error("decodePackedType is obsolete")
262270
#
263271
# TODO, to solve IIF 1424

src/DistributedFactorGraphs.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,9 @@ export @format_str
248248
##------------------------------------------------------------------------------
249249
# Factor Data
250250
export GenericFunctionNodeData, PackedFunctionNodeData, FunctionNodeData
251-
export AbstractFactor, AbstractPackedFactor
251+
export AbstractFactorObservation, AbstractPackedFactorObservation
252252
export AbstractPrior, AbstractRelative, AbstractRelativeMinimize, AbstractManifoldMinimize
253-
export FactorOperationalMemory
253+
export FactorSolverCache
254254

255255
# accessors
256256
export getVariableOrder
@@ -286,7 +286,7 @@ export findClosestTimestamp, findVariableNearTimestamp
286286

287287
# Serialization
288288
export packVariable, unpackVariable, packFactor, unpackFactor
289-
export rebuildFactorWorkmem!
289+
export rebuildFactorCache!
290290
export @defVariable
291291

292292
# File import and export

src/FileDFG/services/FileDFG.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ function loadDFG!(
206206
# NOTE CREATES A NEW FactorCompute IF CCW TYPE CHANGES
207207
# @info "Rebuilding CCW's for the factors..."
208208
@showprogress 1 "Rebuilding factor working memory" for factor in factors
209-
rebuildFactorWorkmem!(dfgLoadInto, factor)
209+
rebuildFactorCache!(dfgLoadInto, factor)
210210
end
211211
end
212212

src/entities/DFGFactor.jl

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
## Abstract Types
33
##==============================================================================
44

5-
abstract type AbstractFactor end
6-
abstract type AbstractPackedFactor end
5+
abstract type AbstractPackedFactorObservation end
6+
abstract type AbstractFactorObservation end
77

8-
abstract type AbstractPrior <: AbstractFactor end
9-
abstract type AbstractRelative <: AbstractFactor end
8+
abstract type AbstractPrior <: AbstractFactorObservation end
9+
abstract type AbstractRelative <: AbstractFactorObservation end
1010
abstract type AbstractRelativeMinimize <: AbstractRelative end
1111
abstract type AbstractManifoldMinimize <: AbstractRelative end
1212

13-
# NOTE DF, Convolution is IIF idea, but DFG should know about "FactorOperationalMemory"
14-
# DF, IIF.CommonConvWrapper <: FactorOperationalMemory #
13+
# NOTE DF, Convolution is IIF idea, but DFG should know about "FactorSolverCache"
14+
# DF, IIF.CommonConvWrapper <: FactorSolverCache #
1515
# NOTE was `<: Function` as unnecessary
16-
abstract type FactorOperationalMemory end
16+
abstract type FactorSolverCache end
1717
# TODO to be removed from DFG,
18-
# we can add to IIF or have IIF.CommonConvWrapper <: FactorOperationalMemory directly
19-
# abstract type ConvolutionObject <: FactorOperationalMemory end
18+
# we can add to IIF or have IIF.CommonConvWrapper <: FactorSolverCache directly
19+
# abstract type ConvolutionObject <: FactorSolverCache end
2020

2121
##==============================================================================
2222
## GenericFunctionNodeData
@@ -29,13 +29,13 @@ Notes
2929
- S::Symbol
3030
3131
Designing (WIP)
32-
- T <: Union{FactorOperationalMemory, AbstractPackedFactor}
33-
- in IIF.CCW{T <: DFG.AbstractFactor}
34-
- in DFG.AbstractRelativeMinimize <: AbstractFactor
32+
- T <: Union{FactorSolverCache, AbstractPackedFactorObservation}
33+
- in IIF.CCW{T <: DFG.AbstractFactorObservation}
34+
- in DFG.AbstractRelativeMinimize <: AbstractFactorObservation
3535
- in Main.SomeFactor <: AbstractRelativeMinimize
3636
"""
3737
Base.@kwdef mutable struct GenericFunctionNodeData{
38-
T <: Union{<:AbstractPackedFactor, <:AbstractFactor, <:FactorOperationalMemory},
38+
T <: Union{<:AbstractPackedFactorObservation, <:AbstractFactorObservation, <:FactorSolverCache},
3939
}
4040
eliminated::Bool = false
4141
potentialused::Bool = false
@@ -59,9 +59,9 @@ end
5959
inflation::Float64 = 0.0
6060
end
6161

62-
# TODO should we move non FactorOperationalMemory to FactorCompute:
62+
# TODO should we move non FactorSolverCache to FactorCompute:
6363
# fnc, multihypo, nullhypo, inflation ?
64-
# that way we split solverData <: FactorOperationalMemory and constants
64+
# that way we split solverData <: FactorSolverCache and constants
6565
# TODO see if above ever changes?
6666

6767
## Constructors
@@ -70,19 +70,19 @@ end
7070
## PackedFunctionNodeData and FunctionNodeData
7171

7272
const PackedFunctionNodeData{T} =
73-
GenericFunctionNodeData{T} where {T <: AbstractPackedFactor}
73+
GenericFunctionNodeData{T} where {T <: AbstractPackedFactorObservation}
7474
function PackedFunctionNodeData(args...; kw...)
7575
return PackedFunctionNodeData{typeof(args[4])}(args...; kw...)
7676
end
7777

7878
const FunctionNodeData{T} = GenericFunctionNodeData{
7979
T,
80-
} where {T <: Union{<:AbstractFactor, <:FactorOperationalMemory}}
80+
} where {T <: Union{<:AbstractFactorObservation, <:FactorSolverCache}}
8181
FunctionNodeData(args...; kw...) = FunctionNodeData{typeof(args[4])}(args...; kw...)
8282

83-
# PackedFunctionNodeData(x2, x3, x4, x6::T, multihypo::Vector{Float64}=[], certainhypo::Vector{Int}=Int[], x9::Int=0) where T <: AbstractPackedFactor =
83+
# PackedFunctionNodeData(x2, x3, x4, x6::T, multihypo::Vector{Float64}=[], certainhypo::Vector{Int}=Int[], x9::Int=0) where T <: AbstractPackedFactorObservation =
8484
# GenericFunctionNodeData{T}(x2, x3, x4, x6, multihypo, certainhypo, x9)
85-
# FunctionNodeData(x2, x3, x4, x6::T, multihypo::Vector{Float64}=[], certainhypo::Vector{Int}=Int[], x9::Int=0) where T <: Union{AbstractFactor, FactorOperationalMemory} =
85+
# FunctionNodeData(x2, x3, x4, x6::T, multihypo::Vector{Float64}=[], certainhypo::Vector{Int}=Int[], x9::Int=0) where T <: Union{AbstractFactorObservation, FactorSolverCache} =
8686
# GenericFunctionNodeData{T}(x2, x3, x4, x6, multihypo, certainhypo, x9)
8787

8888
##==============================================================================
@@ -183,24 +183,24 @@ $(TYPEDEF)
183183
Abstract parent type for all InferenceTypes, which are the
184184
observation functions inside of factors.
185185
"""
186-
abstract type InferenceType <: AbstractPackedFactor end
186+
abstract type InferenceType <: AbstractPackedFactorObservation end
187187

188-
#TODO deprecate InferenceType in favor of AbstractPackedFactor v0.26
188+
#TODO deprecate InferenceType in favor of AbstractPackedFactorObservation v0.26
189189

190190
# this is the GenericFunctionNodeData for packed types
191191
#TODO deprecate FactorData in favor of FactorState (with no more distinction between packed and compute)
192-
const FactorData = PackedFunctionNodeData{AbstractPackedFactor}
192+
const FactorData = PackedFunctionNodeData{AbstractPackedFactorObservation}
193193

194194
# Packed Factor constructor
195195
function assembleFactorName(xisyms::Union{Vector{String}, Vector{Symbol}})
196196
return Symbol(xisyms..., "_f", randstring(4))
197197
end
198198

199-
getFncTypeName(fnc::AbstractPackedFactor) = split(string(typeof(fnc)), ".")[end]
199+
getFncTypeName(fnc::AbstractPackedFactorObservation) = split(string(typeof(fnc)), ".")[end]
200200

201201
function FactorDFG(
202202
xisyms::Vector{Symbol},
203-
fnc::AbstractPackedFactor;
203+
fnc::AbstractPackedFactorObservation;
204204
multihypo::Vector{Float64} = Float64[],
205205
nullhypo::Float64 = 0.0,
206206
solvable::Int = 1,
@@ -249,7 +249,7 @@ DevNotes
249249
Fields:
250250
$(TYPEDFIELDS)
251251
"""
252-
Base.@kwdef struct FactorCompute{FT <: AbstractFactor, N} <: AbstractDFGFactor
252+
Base.@kwdef struct FactorCompute{FT <: AbstractFactorObservation, N} <: AbstractDFGFactor
253253
"""The ID for the factor"""
254254
id::Union{UUID, Nothing} = nothing #TODO deprecate id
255255
"""Factor label, e.g. :x1f1.
@@ -281,9 +281,9 @@ Base.@kwdef struct FactorCompute{FT <: AbstractFactor, N} <: AbstractDFGFactor
281281
Accessors: [`getFactorState`](@ref)"""
282282
state::FactorState
283283
"""Temporary, non-persistent memory used internally by the solver for intermediate numerical computations and buffers.
284-
`workmem` is lazily allocated and only used during factor operations; it is not serialized or retained after solving.
285-
Accessors: [`getWorkmem`](@ref), [`setWorkmem!`](@ref)"""
286-
workmem::Base.RefValue{<:FactorOperationalMemory} #TODO easy of use vs. performance as container is abstract in any case.
284+
`solvercache` is lazily allocated and only used during factor operations; it is not serialized or retained after solving.
285+
Accessors: [`getCache`](@ref), [`setCache!`](@ref)"""
286+
solvercache::Base.RefValue{<:FactorSolverCache} #TODO easy of use vs. performance as container is abstract in any case.
287287
end
288288

289289
##------------------------------------------------------------------------------
@@ -293,9 +293,9 @@ end
293293
function FactorCompute(
294294
label::Symbol,
295295
variableOrder::Union{Vector{Symbol}, Tuple},
296-
observation::AbstractFactor,
296+
observation::AbstractFactorObservation,
297297
state::FactorState = FactorState(),
298-
_workmem = nothing;
298+
cache = nothing;
299299
tags::Set{Symbol} = Set{Symbol}(),
300300
timestamp::Union{DateTime, ZonedDateTime} = now(localzone()),
301301
solvable::Int = 1,
@@ -308,10 +308,10 @@ function FactorCompute(
308308
Base.depwarn("`FactorCompute` solverData is deprecated", :FactorCompute)
309309
end
310310

311-
if isnothing(_workmem)
312-
workmem = Ref{FactorOperationalMemory}()
311+
if isnothing(cache)
312+
solvercache = Ref{FactorSolverCache}()
313313
else
314-
workmem = Ref(_workmem)
314+
solvercache = Ref(cache)
315315
end
316316

317317
return FactorCompute(
@@ -325,7 +325,7 @@ function FactorCompute(
325325
smallData,
326326
observation,
327327
state,
328-
workmem,
328+
solvercache,
329329
)
330330
end
331331

@@ -341,7 +341,7 @@ function FactorCompute(
341341
smallData::Dict{Symbol, SmallDataTypes} = Dict{Symbol, SmallDataTypes}(),
342342
)
343343
Base.depwarn(
344-
"`FactorCompute` constructor with `GenericFunctionNodeData` is deprecated. observation, state, and workmem should be provided explicitly.",
344+
"`FactorCompute` constructor with `GenericFunctionNodeData` is deprecated. observation, state, and solvercache should be provided explicitly.",
345345
:FactorCompute,
346346
)
347347
observation = getFactorType(solverData)
@@ -355,18 +355,18 @@ function FactorCompute(
355355
solverData.inflation,
356356
)
357357

358-
if solverData.fnc isa FactorOperationalMemory
359-
workmem = solverData.fnc
358+
if solverData.fnc isa FactorSolverCache
359+
solvercache = solverData.fnc
360360
else
361-
workmem = nothing
361+
solvercache = nothing
362362
end
363363

364364
return FactorCompute(
365365
label,
366366
Tuple(variableOrder),
367367
observation,
368368
state,
369-
workmem;
369+
solvercache;
370370
id,
371371
timestamp,
372372
nstime,
@@ -381,7 +381,7 @@ function Base.getproperty(x::FactorCompute, f::Symbol)
381381
getfield(x, f)[]
382382
elseif f == :solverData
383383
error(
384-
"`solverData` is obsolete in `FactorCompute`. Use `getObservation`, `getState` or `getWorkmem` instead.",
384+
"`solverData` is obsolete in `FactorCompute`. Use `getObservation`, `getState` or `getCache` instead.",
385385
)
386386
elseif f == :_variableOrderSymbols
387387
[getfield(x, f)...]
@@ -395,7 +395,7 @@ function Base.setproperty!(x::FactorCompute, f::Symbol, val)
395395
getfield(x, f)[] = val
396396
elseif f == :solverData
397397
error(
398-
"`solverData` is obsolete in `FactorCompute`. Use `Observation`, `State` or `Workmem` instead.",
398+
"`solverData` is obsolete in `FactorCompute`. Use `Observation`, `State` or `Cache` instead.",
399399
)
400400
else
401401
setfield!(x, f, val)

src/services/AbstractDFG.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ getSolverParams(dfg::AbstractDFG) = dfg.solverParams
100100
"""
101101
$(SIGNATURES)
102102
103-
Method must be overloaded by the user for Serialization to work. E.g. IncrementalInference uses `CommonConvWrapper <: FactorOperationalMemory`.
103+
Method must be overloaded by the user for Serialization to work. E.g. IncrementalInference uses `CommonConvWrapper <: FactorSolverCache`.
104104
"""
105105
function getFactorOperationalMemoryType(dummy)
106106
return error(
107-
"Please extend your workspace with function getFactorOperationalMemoryType(<:AbstractParams) for your usecase, e.g. IncrementalInference uses `CommonConvWrapper <: FactorOperationalMemory`",
107+
"Please extend your workspace with function getFactorOperationalMemoryType(<:AbstractParams) for your usecase, e.g. IncrementalInference uses `CommonConvWrapper <: FactorSolverCache`",
108108
)
109109
end
110110
function getFactorOperationalMemoryType(dfg::AbstractDFG)
@@ -116,12 +116,12 @@ end
116116
117117
Method must be overloaded by the user for Serialization to work.
118118
"""
119-
function rebuildFactorWorkmem!(
119+
function rebuildFactorCache!(
120120
dfg::AbstractDFG{<:AbstractParams},
121121
factor::AbstractDFGFactor,
122122
neighbors = [],
123123
)
124-
return error("rebuildFactorWorkmem! is not implemented for $(typeof(dfg))")
124+
return error("rebuildFactorCache! is not implemented for $(typeof(dfg))")
125125
end
126126

127127
"""
@@ -769,7 +769,7 @@ function ls(dfg::G, ::Type{T}) where {G <: AbstractDFG, T <: InferenceVariable}
769769
return map(x -> x.label, vxx)
770770
end
771771

772-
function ls(dfg::G, ::Type{T}) where {G <: AbstractDFG, T <: AbstractFactor}
772+
function ls(dfg::G, ::Type{T}) where {G <: AbstractDFG, T <: AbstractFactorObservation}
773773
xx = getFactors(dfg)
774774
names = typeof.(getFactorType.(xx)) .|> nameof
775775
vxx = view(xx, names .== Symbol(T))
@@ -785,7 +785,7 @@ Example, list all the Point2Point2 factors in the factor graph `dfg`:
785785
Notes
786786
- Return `Vector{Symbol}`
787787
"""
788-
function lsf(dfg::G, ::Type{T}) where {G <: AbstractDFG, T <: AbstractFactor}
788+
function lsf(dfg::G, ::Type{T}) where {G <: AbstractDFG, T <: AbstractFactorObservation}
789789
return ls(dfg, T)
790790
end
791791

@@ -1283,7 +1283,7 @@ function existsPathOfFactorsType(
12831283
dfg::AbstractDFG,
12841284
from::Symbol,
12851285
to::Symbol,
1286-
ftype::AbstractFactor,
1286+
ftype::AbstractFactorObservation,
12871287
)
12881288
return error("WIP")
12891289
end

0 commit comments

Comments
 (0)