Skip to content

Commit

Permalink
no threadedsparsearrays
Browse files Browse the repository at this point in the history
  • Loading branch information
thorek1 committed Nov 19, 2023
1 parent 97992bf commit 8b71c78
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
11 changes: 5 additions & 6 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
DynarePreprocessor_jll = "23afba7c-24e5-5ee2-bc2c-b42e07f0492a"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
ImplicitDifferentiation = "57b37032-215b-411a-8a7c-41a003a55207"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
Krylov = "ba0b0d4f-ebba-5204-a429-3ac8c609bfb7"
Expand All @@ -36,13 +37,8 @@ SpeedMapping = "f1835b91-879b-4a3f-a438-e4baacf14412"
Subscripts = "2b7f82d5-8785-4f63-971e-f18ddbeb808e"
SymPyPythonCall = "bc8888f7-b21e-4b7c-a06a-5d9c9496438c"
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
ThreadedSparseArrays = "59d54670-b8ac-4d81-ab7a-bb56233e17ab"
Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[weakdeps]
StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd"
Turing = "fce5fe82-541a-59a6-adf8-730c64b5f9a0"

[compat]
AbstractDifferentiation = "^0.5, 0.6"
Aqua = "^0.8"
Expand Down Expand Up @@ -88,7 +84,6 @@ Subscripts = "^0.1"
SymPyPythonCall = "^0.2"
Symbolics = "^5"
Test = "^1"
ThreadedSparseArrays = "^0.2"
Turing = "^0.29"
Unicode = "^1"
Zygote = "^0.6"
Expand All @@ -112,3 +107,7 @@ Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[targets]
test = ["Aqua", "JET", "CSV", "DataFrames", "DynamicPPL", "MCMCChains", "LineSearches", "Optim", "Test", "Turing", "FiniteDifferences", "Zygote", "Plots", "StatsPlots"]

[weakdeps]
StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd"
Turing = "fce5fe82-541a-59a6-adf8-730c64b5f9a0"
32 changes: 16 additions & 16 deletions src/MacroModelling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module MacroModelling

import DocStringExtensions: FIELDS, SIGNATURES, TYPEDEF, TYPEDSIGNATURES, TYPEDFIELDS
# import StatsFuns: normcdf
import ThreadedSparseArrays
# import ThreadedSparseArrays
using PrecompileTools
import SpecialFunctions: erfcinv, erfc
import SymPyPythonCall as SPyPyC
Expand Down Expand Up @@ -5277,7 +5277,7 @@ function solve_matrix_equation_forward(ABC::Vector{Float64};
if length(coords) == 1
lengthA = length(coords[1][1])
vA = ABC[1:lengthA]
A = sparse(coords[1]...,vA,dims[1]...) |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
A = sparse(coords[1]...,vA,dims[1]...)# |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
C = reshape(ABC[lengthA+1:end],dims[2]...)
if solver != :doubling
B = A'
Expand All @@ -5290,9 +5290,9 @@ function solve_matrix_equation_forward(ABC::Vector{Float64};
vB = ABC[lengthA .+ (1:lengthB)]
vC = ABC[lengthA + lengthB + 1:end]

A = sparse(coords[1]...,vA,dims[1]...) |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
B = sparse(coords[2]...,vB,dims[2]...) |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
C = sparse(coords[3]...,vC,dims[3]...) |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
A = sparse(coords[1]...,vA,dims[1]...)# |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
B = sparse(coords[2]...,vB,dims[2]...)# |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
C = sparse(coords[3]...,vC,dims[3]...)# |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
else
lengthA = dims[1][1] * dims[1][2]
A = reshape(ABC[1:lengthA],dims[1]...)
Expand Down Expand Up @@ -5385,10 +5385,10 @@ function solve_matrix_equation_conditions(ABC::Vector{<: Real},
if length(coords) == 1
lengthA = length(coords[1][1])
vA = ABC[1:lengthA]
A = sparse(coords[1]...,vA,dims[1]...) |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
A = sparse(coords[1]...,vA,dims[1]...)# |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
C = reshape(ABC[lengthA+1:end],dims[2]...)
if solver != :doubling
B = A' |> sparse |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
B = A' |> sparse# |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
end
elseif length(coords) == 3
lengthA = length(coords[1][1])
Expand All @@ -5398,9 +5398,9 @@ function solve_matrix_equation_conditions(ABC::Vector{<: Real},
vB = ABC[lengthA .+ (1:lengthB)]
vC = ABC[lengthA + lengthB + 1:end]

A = sparse(coords[1]...,vA,dims[1]...) |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
B = sparse(coords[2]...,vB,dims[2]...) |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
C = sparse(coords[3]...,vC,dims[3]...) |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
A = sparse(coords[1]...,vA,dims[1]...)# |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
B = sparse(coords[2]...,vB,dims[2]...)# |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
C = sparse(coords[3]...,vC,dims[3]...)# |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
else
lengthA = dims[1][1] * dims[1][2]
A = reshape(ABC[1:lengthA],dims[1]...)
Expand Down Expand Up @@ -5437,11 +5437,11 @@ function solve_matrix_equation_forward(abc::Vector{ℱ.Dual{Z,S,N}};
lengthA = length(coords[1][1])

vA = ABC[1:lengthA]
A = sparse(coords[1]...,vA,dims[1]...) |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
A = sparse(coords[1]...,vA,dims[1]...)# |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
# C = reshape(ABC[lengthA+1:end],dims[2]...)
droptol!(A,eps())

B = sparse(A') |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
B = sparse(A')# |> ThreadedSparseArrays.ThreadedSparseMatrixCSC

partials = zeros(dims[1][1] * dims[1][2] + dims[2][1] * dims[2][2], size(partial_values,2))
partials[vcat(coords[1][1] + (coords[1][2] .- 1) * dims[1][1], dims[1][1] * dims[1][2] + 1:end),:] = partial_values
Expand All @@ -5464,9 +5464,9 @@ function solve_matrix_equation_forward(abc::Vector{ℱ.Dual{Z,S,N}};
vB = ABC[lengthA .+ (1:lengthB)]
# vC = ABC[lengthA + lengthB + 1:end]

A = sparse(coords[1]...,vA,dims[1]...) |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
B = sparse(coords[2]...,vB,dims[2]...) |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
# C = sparse(coords[3]...,vC,dims[3]...) |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
A = sparse(coords[1]...,vA,dims[1]...)# |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
B = sparse(coords[2]...,vB,dims[2]...)# |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
# C = sparse(coords[3]...,vC,dims[3]...)# |> ThreadedSparseArrays.ThreadedSparseMatrixCSC

partials = spzeros(dims[1][1] * dims[1][2] + dims[2][1] * dims[2][2] + dims[3][1] * dims[3][2], size(partial_values,2))
partials[vcat(
Expand All @@ -5492,7 +5492,7 @@ function solve_matrix_equation_forward(abc::Vector{ℱ.Dual{Z,S,N}};
A = reshape(ABC[1:lengthA],dims[1]...) |> sparse
droptol!(A, eps())
# C = reshape(ABC[lengthA+1:end],dims[2]...)
B = sparse(A') |> ThreadedSparseArrays.ThreadedSparseMatrixCSC
B = sparse(A')# |> ThreadedSparseArrays.ThreadedSparseMatrixCSC

partials = partial_values

Expand Down

0 comments on commit 8b71c78

Please sign in to comment.