Internal API
Index
TensorInference.backward_tropical!TensorInference.parse_mar_solution_fileTensorInference.read_query_fileTensorInference.rescale_arrayTensorInference.tensor_from_dictTensorInference.tensor_to_dict
Types
TensorInference.Factor — Typestruct Factor{T, N}Fields
varsvals
Encodes a discrete function over the set of variables vars that maps each instantiation of vars into a nonnegative number in vals.
TensorInference.Samples — Typestruct Samples{L} <: AbstractVector{SubArray{Float64, 1, Matrix{Float64}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true}}Fields
samples::Matrix{Int64}labels::Vector
The sampled configurations are stored in samples, which is a vector of vector. labels is a vector of variable names for labeling configurations.
Functions
TensorInference.backward_tropical! — Methodbackward_tropical!(
ixs,
xs::Tuple,
iy,
y,
ymask,
size_dict
) -> Vector{Any}
The backward rule for tropical einsum.
ixsandxsare labels and tensor data for input tensors,iyandyare labels and tensor data for the output tensor,ymaskis the boolean mask for gradients,size_dictis a key-value map from tensor label to dimension size.
TensorInference.parse_mar_solution_file — Methodparse_mar_solution_file(
rawlines::Vector{String};
factor_eltype
) -> Vector{Vector{Float64}}
Parse the solution marginals of all variables from the UAI MAR solution file. The order of the variables is the same as in the model definition.
The UAI file formats are defined in: https://uaicompetition.github.io/uci-2022/file-formats/
TensorInference.read_query_file — Methodread_query_file(
query_filepath::AbstractString
) -> Vector{Int64}
Return the query variables in query_filepath. If the passed file path is an empty string, return an empty vector.
The UAI file formats are defined in: https://uaicompetition.github.io/uci-2022/file-formats/
TensorInference.rescale_array — Methodrescale_array(tensor::AbstractArray{T}) -> RescaledArray
Returns a rescaled array that equivalent to the input tensor.
TensorInference.tensor_from_dict — Methodtensor_from_dict(dict::Dict)Convert a dictionary back to a tensor.
Arguments
dict::Dict: The dictionary representation of a tensor
Returns
AbstractArray: The reconstructed tensor
Dictionary Structure Expected
"size": The dimensions of the tensor"complex": Boolean indicating if the tensor contains complex numbers"data": The tensor data as a flat array of real numbers
TensorInference.tensor_to_dict — Methodtensor_to_dict(tensor::AbstractArray{T}) where TConvert a tensor to a dictionary representation for JSON serialization.
Arguments
tensor::AbstractArray{T}: The tensor to convert
Returns
Dict: A dictionary containing tensor metadata and data
Dictionary Structure
"size": The dimensions of the tensor"complex": Boolean indicating if the tensor contains complex numbers"data": The tensor data as a flat array of real numbers