diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 99a51b1..6cfccde 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,8 +1,9 @@ steps: - label: ":julia: Run tests" + key: "test" plugins: - JuliaCI/julia#v1: - version: "1.8" + version: "1" - JuliaCI/julia-test#v1: coverage: false agents: @@ -12,10 +13,11 @@ steps: timeout_in_minutes: 30 - label: ":julia: Run benchmarks" + key: "benchmark" command: "julia --project=benchmark benchmark/runbenchmarks.jl" plugins: - JuliaCI/julia#v1: - version: "1.8" + version: "1" agents: os: "linux" queue: "juliaecosystem" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index eac0ea3..19a659f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,16 +1,21 @@ { - "name": "TaylorDiff.jl Development Container", - "image": "ghcr.io/julia-vscode/julia-devcontainer", - "customizations": { - "vscode": { - "extensions": [ - "julialang.language-julia", - "bungcip.better-toml" - ] - } - }, - "postCreateCommand": "julia -e 'using Pkg; Pkg.add([\"Revise\", \"TestEnv\", \"JuliaFormatter\", \"Cthulhu\"])'", - "hostRequirements": { - "cpus": 4 - } + "name": "TaylorDiff.jl Development Container", + "image": "mcr.microsoft.com/devcontainers/base:jammy", + "customizations": { + "vscode": { + "extensions": [ + "julialang.language-julia", + "tamasfe.even-better-toml" + ] + } + }, + "features": { + "ghcr.io/julialang/devcontainer-features/julia:1": { + "channel": "release" + } + }, + "postCreateCommand": "julia .devcontainer/postcreate.jl", + "hostRequirements": { + "cpus": 4 + } } diff --git a/.devcontainer/postcreate.jl b/.devcontainer/postcreate.jl new file mode 100644 index 0000000..d0baee6 --- /dev/null +++ b/.devcontainer/postcreate.jl @@ -0,0 +1,5 @@ +using Pkg +Pkg.add(["Revise", "TestEnv", "JuliaFormatter"]) + +Pkg.activate(".") +Pkg.instantiate() diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..700707c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" # Location of package manifests + schedule: + interval: "weekly" diff --git a/.github/workflows/Documentation.yml b/.github/workflows/Documentation.yml index 24caa72..aeac626 100644 --- a/.github/workflows/Documentation.yml +++ b/.github/workflows/Documentation.yml @@ -17,8 +17,8 @@ jobs: permissions: contents: write steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v2 with: version: '1' - uses: julia-actions/julia-buildpkg@v1 diff --git a/.github/workflows/FormatCheck.yml b/.github/workflows/FormatCheck.yml index c553354..4d1c83a 100644 --- a/.github/workflows/FormatCheck.yml +++ b/.github/workflows/FormatCheck.yml @@ -11,8 +11,8 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: julia-actions/setup-julia@v1 - - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v2 + - uses: actions/checkout@v4 - name: Install JuliaFormatter and format run: | julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))' diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml index 492d03a..dfdfc11 100644 --- a/.github/workflows/Test.yml +++ b/.github/workflows/Test.yml @@ -18,23 +18,22 @@ jobs: fail-fast: false matrix: version: - - '1.6' - - '1.8' + - '1' os: - ubuntu-latest arch: - x64 steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v2 with: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - - uses: julia-actions/cache@v1 + - uses: julia-actions/cache@v2 - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-runtest@v1 - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v2 + - uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} files: lcov.info diff --git a/Project.toml b/Project.toml index 7ad1b28..ccb5495 100644 --- a/Project.toml +++ b/Project.toml @@ -1,19 +1,31 @@ name = "TaylorDiff" uuid = "b36ab563-344f-407b-a36a-4f200bebf99c" authors = ["Songchen Tan "] -version = "0.2.1" +version = "0.2.4" [deps] ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2" ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" ChainRulesOverloadGeneration = "f51149dc-2911-5acf-81fc-2076a2a81d4f" SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b" +Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" +[weakdeps] +NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd" +SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" + +[extensions] +TaylorDiffNNlibExt = ["NNlib"] +TaylorDiffSFExt = ["SpecialFunctions"] + [compat] ChainRules = "1" ChainRulesCore = "1" ChainRulesOverloadGeneration = "0.1" -SymbolicUtils = "1" +NNlib = "0.9" +SpecialFunctions = "2" +SymbolicUtils = "2, 3" +Symbolics = "5.30.1, 6" Zygote = "0.6.55" julia = "1.6" diff --git a/README.md b/README.md index 0a0b781..25fa2ae 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ Stable Dev
- Build Status - - Benchmark Status + Build Status + + Benchmark Status
ColPrac: Contributor's Guide on Collaborative Practices for Community Packages SciML Code Style @@ -56,7 +56,7 @@ Please see our [documentation](https://juliadiff.org/TaylorDiff.jl) for more det - [TaylorSeries.jl](https://github.com/JuliaDiff/TaylorSeries.jl): a systematic treatment of Taylor polynomials in one and several variables, but its mutating and scalar code isn't great for speed and composability with other packages - [ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl): well-established and robust operator-overloading based forward-mode AD, where higher-order derivatives can be achieved by nesting first-order derivatives -- [Diffractor.jl](https://github.com/PumasAI/SimpleChains.jl): next-generation source-code transformation based forward-mode and reverse-mode AD, designed with support for higher-order derivatives in mind; but the higher-order functionality is currently only a proof-of-concept +- [Diffractor.jl](https://github.com/JuliaDiff/Diffractor.jl): next-generation source-code transformation based forward-mode and reverse-mode AD, designed with support for higher-order derivatives in mind; but the higher-order functionality is currently only a proof-of-concept - [`jax.jet`](https://jax.readthedocs.io/en/latest/jax.experimental.jet.html): an experimental (and unmaintained) implementation of Taylor-mode automatic differentiation in JAX, sharing the same underlying algorithm with this project ## Citation diff --git a/benchmark/Manifest.toml b/benchmark/Manifest.toml index 1e2e62d..73dc86b 100644 --- a/benchmark/Manifest.toml +++ b/benchmark/Manifest.toml @@ -1,31 +1,39 @@ # This file is machine-generated - editing it directly is not advised -julia_version = "1.8.4" +julia_version = "1.9.3" manifest_format = "2.0" -project_hash = "141466748547092db2659f061bcf16b16bf160f5" +project_hash = "b3e5f4cf27d760c93b2634d045748b8e8637f186" + +[[deps.ADTypes]] +git-tree-sha1 = "a4c8e0f8c09d4aa708289c1a5fc23e2d1970017a" +uuid = "47edcb42-4c32-4615-8424-f2b9edc5f35b" +version = "0.2.1" [[deps.AbstractFFTs]] -deps = ["ChainRulesCore", "LinearAlgebra"] -git-tree-sha1 = "69f7020bd72f069c219b5e8c236c1fa90d2cb409" +deps = ["LinearAlgebra"] +git-tree-sha1 = "d92ad398961a3ed262d8bf04a1a2b8340f915fef" uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c" -version = "1.2.1" +version = "1.5.0" +weakdeps = ["ChainRulesCore", "Test"] + + [deps.AbstractFFTs.extensions] + AbstractFFTsChainRulesCoreExt = "ChainRulesCore" + AbstractFFTsTestExt = "Test" [[deps.AbstractTrees]] git-tree-sha1 = "faa260e4cb5aba097a73fab382dd4b5819d8ec8c" uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" version = "0.4.4" -[[deps.Accessors]] -deps = ["Compat", "CompositionsBase", "ConstructionBase", "Dates", "InverseFunctions", "LinearAlgebra", "MacroTools", "Requires", "StaticArrays", "Test"] -git-tree-sha1 = "beabc31fa319f9de4d16372bff31b4801e43d32c" -uuid = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" -version = "0.1.28" - [[deps.Adapt]] -deps = ["LinearAlgebra"] -git-tree-sha1 = "0310e08cb19f5da31d08341c6120c047598f5b9c" +deps = ["LinearAlgebra", "Requires"] +git-tree-sha1 = "76289dc51920fdc6e0013c872ba9551d54961c24" uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" -version = "3.5.0" +version = "3.6.2" +weakdeps = ["StaticArrays"] + + [deps.Adapt.extensions] + AdaptStaticArraysExt = "StaticArrays" [[deps.ArgCheck]] git-tree-sha1 = "a3a402a35a2f7e0b87828ccabbd5ebfbebe356b4" @@ -37,10 +45,26 @@ uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" version = "1.1.1" [[deps.ArrayInterface]] -deps = ["Adapt", "LinearAlgebra", "Requires", "SnoopPrecompile", "SparseArrays", "SuiteSparse"] -git-tree-sha1 = "4d9946e51e24f5e509779e3e2c06281a733914c2" +deps = ["Adapt", "LinearAlgebra", "Requires", "SparseArrays", "SuiteSparse"] +git-tree-sha1 = "f83ec24f76d4c8f525099b2ac475fc098138ec31" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.1.0" +version = "7.4.11" + + [deps.ArrayInterface.extensions] + ArrayInterfaceBandedMatricesExt = "BandedMatrices" + ArrayInterfaceBlockBandedMatricesExt = "BlockBandedMatrices" + ArrayInterfaceCUDAExt = "CUDA" + ArrayInterfaceGPUArraysCoreExt = "GPUArraysCore" + ArrayInterfaceStaticArraysCoreExt = "StaticArraysCore" + ArrayInterfaceTrackerExt = "Tracker" + + [deps.ArrayInterface.weakdeps] + BandedMatrices = "aae01518-5342-5314-be14-df237901396f" + BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0" + CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" + GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" + StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" + Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" [[deps.Artifacts]] uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" @@ -58,10 +82,24 @@ uuid = "ab4f0b2a-ad5b-11e8-123f-65d77653426b" version = "0.4.2" [[deps.BangBang]] -deps = ["Compat", "ConstructionBase", "Future", "InitialValues", "LinearAlgebra", "Requires", "Setfield", "Tables", "ZygoteRules"] -git-tree-sha1 = "7fe6d92c4f281cf4ca6f2fba0ce7b299742da7ca" +deps = ["Compat", "ConstructionBase", "InitialValues", "LinearAlgebra", "Requires", "Setfield", "Tables"] +git-tree-sha1 = "e28912ce94077686443433c2800104b061a827ed" uuid = "198e06fe-97b7-11e9-32a5-e1d131e6ad66" -version = "0.3.37" +version = "0.3.39" + + [deps.BangBang.extensions] + BangBangChainRulesCoreExt = "ChainRulesCore" + BangBangDataFramesExt = "DataFrames" + BangBangStaticArraysExt = "StaticArrays" + BangBangStructArraysExt = "StructArrays" + BangBangTypedTablesExt = "TypedTables" + + [deps.BangBang.weakdeps] + ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" + DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" + StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" + StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a" + TypedTables = "9d95f2ec-7b3d-5a63-8d20-e2491e220bb9" [[deps.Base64]] uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" @@ -93,52 +131,46 @@ uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82" version = "0.4.2" [[deps.CUDA]] -deps = ["AbstractFFTs", "Adapt", "BFloat16s", "CEnum", "CUDA_Driver_jll", "CUDA_Runtime_Discovery", "CUDA_Runtime_jll", "CompilerSupportLibraries_jll", "ExprTools", "GPUArrays", "GPUCompiler", "LLVM", "LazyArtifacts", "Libdl", "LinearAlgebra", "Logging", "Preferences", "Printf", "Random", "Random123", "RandomNumbers", "Reexport", "Requires", "SparseArrays", "SpecialFunctions"] -git-tree-sha1 = "edff14c60784c8f7191a62a23b15a421185bc8a8" +deps = ["AbstractFFTs", "Adapt", "BFloat16s", "CEnum", "CUDA_Driver_jll", "CUDA_Runtime_Discovery", "CUDA_Runtime_jll", "ExprTools", "GPUArrays", "GPUCompiler", "KernelAbstractions", "LLVM", "LazyArtifacts", "Libdl", "LinearAlgebra", "Logging", "Preferences", "Printf", "Random", "Random123", "RandomNumbers", "Reexport", "Requires", "SparseArrays", "SpecialFunctions", "UnsafeAtomicsLLVM"] +git-tree-sha1 = "968c1365e2992824c3e7a794e30907483f8469a9" uuid = "052768ef-5323-5732-b1bb-66c8b64840ba" -version = "4.0.1" - -[[deps.CUDAKernels]] -deps = ["Adapt", "CUDA", "KernelAbstractions", "StaticArrays", "UnsafeAtomicsLLVM"] -git-tree-sha1 = "1680366a69e9c95744ef23a239e6cfe61cf2e1ca" -uuid = "72cfdca4-0801-4ab0-bf6a-d52aa10adc57" -version = "0.4.7" +version = "4.4.1" [[deps.CUDA_Driver_jll]] deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl", "Pkg"] -git-tree-sha1 = "75d7896d1ec079ef10d3aee8f3668c11354c03a1" +git-tree-sha1 = "498f45593f6ddc0adff64a9310bb6710e851781b" uuid = "4ee394cb-3365-5eb0-8335-949819d2adfc" -version = "0.2.0+0" +version = "0.5.0+1" [[deps.CUDA_Runtime_Discovery]] deps = ["Libdl"] -git-tree-sha1 = "58dd8ec29f54f08c04b052d2c2fa6760b4f4b3a4" +git-tree-sha1 = "bcc4a23cbbd99c8535a5318455dcf0f2546ec536" uuid = "1af6417a-86b4-443c-805f-a4643ffb695f" -version = "0.1.1" +version = "0.2.2" [[deps.CUDA_Runtime_jll]] -deps = ["Artifacts", "CUDA_Driver_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "Pkg", "TOML"] -git-tree-sha1 = "d3e6ccd30f84936c1a3a53d622d85d7d3f9b9486" +deps = ["Artifacts", "CUDA_Driver_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "TOML"] +git-tree-sha1 = "5248d9c45712e51e27ba9b30eebec65658c6ce29" uuid = "76a88914-d11a-5bdc-97e0-2f5a05c973a2" -version = "0.2.3+2" +version = "0.6.0+0" [[deps.CUDNN_jll]] -deps = ["Artifacts", "CUDA_Runtime_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "Pkg", "TOML"] -git-tree-sha1 = "57011df4fce448828165e566af9befa2ea94350a" +deps = ["Artifacts", "CUDA_Runtime_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "TOML"] +git-tree-sha1 = "75923dce4275ead3799b238e10178a68c07dbd3b" uuid = "62b44479-cb7b-5706-934f-f13b2eb2e645" -version = "8.6.0+3" +version = "8.9.4+0" [[deps.ChainRules]] deps = ["Adapt", "ChainRulesCore", "Compat", "Distributed", "GPUArraysCore", "IrrationalConstants", "LinearAlgebra", "Random", "RealDot", "SparseArrays", "Statistics", "StructArrays"] -git-tree-sha1 = "7d20c2fb8ab838e41069398685e7b6b5f89ed85b" +git-tree-sha1 = "f98ae934cd677d51d2941088849f0bf2f59e6f6e" uuid = "082447d4-558c-5d27-93f4-14fc19e9eca2" -version = "1.48.0" +version = "1.53.0" [[deps.ChainRulesCore]] deps = ["Compat", "LinearAlgebra", "SparseArrays"] -git-tree-sha1 = "c6d890a52d2c4d55d326439580c3b8d0875a77d9" +git-tree-sha1 = "e30f2f4e20f7f186dc36529910beaedc60cfa644" uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" -version = "1.15.7" +version = "1.16.0" [[deps.ChainRulesOverloadGeneration]] deps = ["ChainRulesCore"] @@ -147,16 +179,20 @@ uuid = "f51149dc-2911-5acf-81fc-2076a2a81d4f" version = "0.1.4" [[deps.ChangesOfVariables]] -deps = ["ChainRulesCore", "LinearAlgebra", "Test"] -git-tree-sha1 = "485193efd2176b88e6622a39a246f8c5b600e74e" +deps = ["LinearAlgebra", "Test"] +git-tree-sha1 = "2fba81a302a7be671aefe194f0525ef231104e7f" uuid = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0" -version = "0.1.6" +version = "0.1.8" +weakdeps = ["InverseFunctions"] + + [deps.ChangesOfVariables.extensions] + ChangesOfVariablesInverseFunctionsExt = "InverseFunctions" [[deps.CodecZlib]] deps = ["TranscodingStreams", "Zlib_jll"] -git-tree-sha1 = "9c209fb7536406834aa938fb149964b985de6c83" +git-tree-sha1 = "02aa26a4cf76381be7f66e020a3eddeb27b0a092" uuid = "944b1d66-785c-5afd-91f1-9de20f533193" -version = "0.7.1" +version = "0.7.2" [[deps.Combinatorics]] git-tree-sha1 = "08c8b6831dc00bfea825826be0bc8336fc369860" @@ -170,32 +206,53 @@ uuid = "bbf7d656-a473-5ed7-a52c-81e309532950" version = "0.3.0" [[deps.Compat]] -deps = ["Dates", "LinearAlgebra", "UUIDs"] -git-tree-sha1 = "61fdd77467a5c3ad071ef8277ac6bd6af7dd4c04" +deps = ["UUIDs"] +git-tree-sha1 = "e460f044ca8b99be31d35fe54fc33a5c33dd8ed7" uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "4.6.0" +version = "4.9.0" +weakdeps = ["Dates", "LinearAlgebra"] + + [deps.Compat.extensions] + CompatLinearAlgebraExt = "LinearAlgebra" [[deps.CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" -version = "1.0.1+0" - -[[deps.ComponentArrays]] -deps = ["ArrayInterface", "ChainRulesCore", "LinearAlgebra", "Requires", "StaticArrayInterface"] -git-tree-sha1 = "2736dee49260e412a352b2d0a37fb863f9a5b559" -uuid = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66" -version = "0.13.8" +version = "1.0.5+0" [[deps.CompositionsBase]] -git-tree-sha1 = "455419f7e328a1a2493cabc6428d79e951349769" +git-tree-sha1 = "802bb88cd69dfd1509f6670416bd4434015693ad" uuid = "a33af91c-f02d-484b-be07-31d278c5ca2b" -version = "0.1.1" +version = "0.1.2" +weakdeps = ["InverseFunctions"] + + [deps.CompositionsBase.extensions] + CompositionsBaseInverseFunctionsExt = "InverseFunctions" + +[[deps.ConcreteStructs]] +git-tree-sha1 = "f749037478283d372048690eb3b5f92a79432b34" +uuid = "2569d6c7-a4a2-43d3-a901-331e8e4be471" +version = "0.2.3" + +[[deps.ConcurrentUtilities]] +deps = ["Serialization", "Sockets"] +git-tree-sha1 = "5372dbbf8f0bdb8c700db5367132925c0771ef7e" +uuid = "f0e56b4a-5159-44fe-b623-3e5288b988bb" +version = "2.2.1" [[deps.ConstructionBase]] deps = ["LinearAlgebra"] -git-tree-sha1 = "89a9db8d28102b094992472d333674bd1a83ce2a" +git-tree-sha1 = "fe2838a593b5f776e1597e086dcd47560d94e816" uuid = "187b0558-2788-49d3-abe0-74a17ed4e7c9" -version = "1.5.1" +version = "1.5.3" + + [deps.ConstructionBase.extensions] + ConstructionBaseIntervalSetsExt = "IntervalSets" + ConstructionBaseStaticArraysExt = "StaticArrays" + + [deps.ConstructionBase.weakdeps] + IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953" + StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" [[deps.ContextVariablesX]] deps = ["Compat", "Logging", "UUIDs"] @@ -204,15 +261,15 @@ uuid = "6add18c4-b38d-439d-96f6-d6bc489c04c5" version = "0.1.3" [[deps.DataAPI]] -git-tree-sha1 = "e8119c1a33d267e16108be441a287a6981ba1630" +git-tree-sha1 = "8da84edb865b0b5b0100c0666a9bc9a0b71c553c" uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" -version = "1.14.0" +version = "1.15.0" [[deps.DataStructures]] deps = ["Compat", "InteractiveUtils", "OrderedCollections"] -git-tree-sha1 = "d1fff3a548102f48987a52a2e0d114fa97d730f0" +git-tree-sha1 = "3dbd312d370723b6bb43ba9d02fc36abade4518d" uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" -version = "0.18.13" +version = "0.18.15" [[deps.DataValueInterfaces]] git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6" @@ -230,7 +287,9 @@ version = "0.1.2" [[deps.DelimitedFiles]] deps = ["Mmap"] +git-tree-sha1 = "9e2f36d3c96a820c678f2f1f1782582fcf685bae" uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" +version = "1.9.1" [[deps.DiffResults]] deps = ["StaticArraysCore"] @@ -240,9 +299,9 @@ version = "1.1.0" [[deps.DiffRules]] deps = ["IrrationalConstants", "LogExpFunctions", "NaNMath", "Random", "SpecialFunctions"] -git-tree-sha1 = "a4ad7ef19d2cdc2eff57abbbe68032b1cd0bd8f8" +git-tree-sha1 = "23163d55f885173722d1e4cf0f6110cdbaf7e272" uuid = "b552c78f-8df3-52c6-915a-8e097449b14b" -version = "1.13.0" +version = "1.15.1" [[deps.Distributed]] deps = ["Random", "Serialization", "Sockets"] @@ -260,15 +319,21 @@ uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" version = "1.6.0" [[deps.DynamicPolynomials]] -deps = ["DataStructures", "Future", "LinearAlgebra", "MultivariatePolynomials", "MutableArithmetics", "Pkg", "Reexport", "Test"] -git-tree-sha1 = "8b84876e31fa39479050e2d3395c4b3b210db8b0" +deps = ["Future", "LinearAlgebra", "MultivariatePolynomials", "MutableArithmetics", "Pkg", "Reexport", "Test"] +git-tree-sha1 = "9b05a8bc04d7a9a9c7e9ee3b0fdf1584857b65dc" uuid = "7c1d4256-1411-5781-91ec-d7bc3513ac07" -version = "0.4.6" +version = "0.5.2" + +[[deps.ExceptionUnwrapping]] +deps = ["Test"] +git-tree-sha1 = "e90caa41f5a86296e014e148ee061bd6c3edec96" +uuid = "460bff9d-24e4-43bc-9d9f-a8973cb893f4" +version = "0.1.9" [[deps.ExprTools]] -git-tree-sha1 = "56559bbef6ca5ea0c0818fa5c90320398a6fbf8d" +git-tree-sha1 = "27415f162e6028e81c72b82ef756bf321213b6ec" uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04" -version = "0.1.8" +version = "0.1.10" [[deps.FLoops]] deps = ["BangBang", "Compat", "FLoopsBase", "InitialValues", "JuliaVariables", "MLStyle", "Serialization", "Setfield", "Transducers"] @@ -286,28 +351,39 @@ version = "0.1.1" uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" [[deps.FillArrays]] -deps = ["LinearAlgebra", "Random", "SparseArrays", "Statistics"] -git-tree-sha1 = "d3ba08ab64bdfd27234d3f61956c966266757fe6" +deps = ["LinearAlgebra", "Random"] +git-tree-sha1 = "a20eaa3ad64254c61eeb5f230d9306e937405434" uuid = "1a297f60-69ca-5386-bcde-b61e274b549b" -version = "0.13.7" +version = "1.6.1" +weakdeps = ["SparseArrays", "Statistics"] + + [deps.FillArrays.extensions] + FillArraysSparseArraysExt = "SparseArrays" + FillArraysStatisticsExt = "Statistics" [[deps.Flux]] -deps = ["Adapt", "CUDA", "ChainRulesCore", "Functors", "LinearAlgebra", "MLUtils", "MacroTools", "NNlib", "NNlibCUDA", "OneHotArrays", "Optimisers", "ProgressLogging", "Random", "Reexport", "SparseArrays", "SpecialFunctions", "Statistics", "StatsBase", "Zygote"] -git-tree-sha1 = "4ff3a1d7b0dd38f2fc38e813bc801f817639c1f2" +deps = ["Adapt", "CUDA", "ChainRulesCore", "Functors", "LinearAlgebra", "MLUtils", "MacroTools", "NNlib", "NNlibCUDA", "OneHotArrays", "Optimisers", "Preferences", "ProgressLogging", "Random", "Reexport", "SparseArrays", "SpecialFunctions", "Statistics", "Zygote", "cuDNN"] +git-tree-sha1 = "3e2c3704c2173ab4b1935362384ca878b53d4c34" uuid = "587475ba-b771-5e3f-ad9e-33799f191a9c" -version = "0.13.13" +version = "0.13.17" -[[deps.FoldsThreads]] -deps = ["Accessors", "FunctionWrappers", "InitialValues", "SplittablesBase", "Transducers"] -git-tree-sha1 = "eb8e1989b9028f7e0985b4268dabe94682249025" -uuid = "9c68100b-dfe1-47cf-94c8-95104e173443" -version = "0.1.1" + [deps.Flux.extensions] + AMDGPUExt = "AMDGPU" + FluxMetalExt = "Metal" + + [deps.Flux.weakdeps] + AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e" + Metal = "dde4c033-4e86-420c-a63e-0dd931031962" [[deps.ForwardDiff]] -deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "LinearAlgebra", "LogExpFunctions", "NaNMath", "Preferences", "Printf", "Random", "SpecialFunctions", "StaticArrays"] -git-tree-sha1 = "a69dd6db8a809f78846ff259298678f0d6212180" +deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "LinearAlgebra", "LogExpFunctions", "NaNMath", "Preferences", "Printf", "Random", "SpecialFunctions"] +git-tree-sha1 = "cf0fe81336da9fb90944683b8c41984b08793dad" uuid = "f6369f11-7733-5829-9624-2563aa707210" -version = "0.10.34" +version = "0.10.36" +weakdeps = ["StaticArrays"] + + [deps.ForwardDiff.extensions] + ForwardDiffStaticArraysExt = "StaticArrays" [[deps.FunctionWrappers]] git-tree-sha1 = "d62485945ce5ae9c0c48f124a84998d755bae00e" @@ -316,9 +392,9 @@ version = "1.1.3" [[deps.Functors]] deps = ["LinearAlgebra"] -git-tree-sha1 = "7ed0833a55979d3d2658a60b901469748a6b9a7c" +git-tree-sha1 = "9a68d75d466ccc1218d0552a8e1631151c569545" uuid = "d9f16b24-f501-4c13-a1f2-28368ffc5196" -version = "0.4.3" +version = "0.4.5" [[deps.Future]] deps = ["Random"] @@ -326,44 +402,39 @@ uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820" [[deps.GPUArrays]] deps = ["Adapt", "GPUArraysCore", "LLVM", "LinearAlgebra", "Printf", "Random", "Reexport", "Serialization", "Statistics"] -git-tree-sha1 = "a28f752ffab0ccd6660fc7af5ad1c9ad176f45f7" +git-tree-sha1 = "2e57b4a4f9cc15e85a24d603256fe08e527f48d1" uuid = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7" -version = "8.6.3" +version = "8.8.1" [[deps.GPUArraysCore]] deps = ["Adapt"] -git-tree-sha1 = "1cd7f0af1aa58abc02ea1d872953a97359cb87fa" +git-tree-sha1 = "2d6ca471a6c7b536127afccfa7564b5b39227fe0" uuid = "46192b85-c4d5-4398-a991-12ede77f4527" -version = "0.1.4" +version = "0.1.5" [[deps.GPUCompiler]] -deps = ["ExprTools", "InteractiveUtils", "LLVM", "Libdl", "Logging", "TimerOutputs", "UUIDs"] -git-tree-sha1 = "95185985a5d2388c6d0fedb06181ad4ddd40e0cb" +deps = ["ExprTools", "InteractiveUtils", "LLVM", "Libdl", "Logging", "Scratch", "TimerOutputs", "UUIDs"] +git-tree-sha1 = "72b2e3c2ba583d1a7aa35129e56cf92e07c083e3" uuid = "61eb1bfa-7361-4325-ad38-22787b887f55" -version = "0.17.2" +version = "0.21.4" [[deps.HTTP]] -deps = ["Base64", "CodecZlib", "Dates", "IniFile", "Logging", "LoggingExtras", "MbedTLS", "NetworkOptions", "OpenSSL", "Random", "SimpleBufferStream", "Sockets", "URIs", "UUIDs"] -git-tree-sha1 = "37e4657cd56b11abe3d10cd4a1ec5fbdb4180263" +deps = ["Base64", "CodecZlib", "ConcurrentUtilities", "Dates", "ExceptionUnwrapping", "Logging", "LoggingExtras", "MbedTLS", "NetworkOptions", "OpenSSL", "Random", "SimpleBufferStream", "Sockets", "URIs", "UUIDs"] +git-tree-sha1 = "cb56ccdd481c0dd7f975ad2b3b62d9eda088f7e2" uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" -version = "1.7.4" +version = "1.9.14" [[deps.IRTools]] deps = ["InteractiveUtils", "MacroTools", "Test"] -git-tree-sha1 = "2af2fe19f0d5799311a6491267a14817ad9fbd20" +git-tree-sha1 = "eac00994ce3229a464c2847e956d77a2c64ad3a5" uuid = "7869d1d1-7146-5819-86e3-90919afe41df" -version = "0.4.8" +version = "0.4.10" [[deps.IfElse]] git-tree-sha1 = "debdd00ffef04665ccbb3e150747a77560e8fad1" uuid = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173" version = "0.1.1" -[[deps.IniFile]] -git-tree-sha1 = "f550e6e32074c939295eb5ea6de31849ac2c9625" -uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f" -version = "0.5.1" - [[deps.InitialValues]] git-tree-sha1 = "4da0f88e9a39111c2fa3add390ab15f3a44f3ca3" uuid = "22cec73e-a1b8-11e9-2c92-598750a2cf9c" @@ -375,14 +446,14 @@ uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" [[deps.InverseFunctions]] deps = ["Test"] -git-tree-sha1 = "49510dfcb407e572524ba94aeae2fced1f3feb0f" +git-tree-sha1 = "68772f49f54b479fa88ace904f6127f0a3bb2e46" uuid = "3587e190-3f89-42d0-90ee-14403ec27112" -version = "0.1.8" +version = "0.1.12" [[deps.IrrationalConstants]] -git-tree-sha1 = "3868cac300a188a7c3a74f9abd930e52ce1a7a51" +git-tree-sha1 = "630b497eafcc20001bba38a4651b327dcfc491d2" uuid = "92d709cd-6900-40b7-9082-c6be49f344b6" -version = "0.2.1" +version = "0.2.2" [[deps.IteratorInterfaceExtensions]] git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856" @@ -390,16 +461,16 @@ uuid = "82899510-4779-5014-852e-03e436cf321d" version = "1.0.0" [[deps.JLLWrappers]] -deps = ["Preferences"] -git-tree-sha1 = "abc9885a7ca2052a736a600f7fa66209f96506e1" +deps = ["Artifacts", "Preferences"] +git-tree-sha1 = "7e5d6779a1e09a36db2a7b6cff50942a0a7d0fca" uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" -version = "1.4.1" +version = "1.5.0" [[deps.JSON]] deps = ["Dates", "Mmap", "Parsers", "Unicode"] -git-tree-sha1 = "3c837543ddb02250ef42f4738347454f95079d4e" +git-tree-sha1 = "31e996f0a15c7b280ba9f76636b3ff9e2ae58c9a" uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" -version = "0.21.3" +version = "0.21.4" [[deps.JuliaVariables]] deps = ["MLStyle", "NameResolution"] @@ -407,23 +478,34 @@ git-tree-sha1 = "49fb3cb53362ddadb4415e9b73926d6b40709e70" uuid = "b14d175d-62b4-44ba-8fb7-3064adc8c3ec" version = "0.2.4" +[[deps.JuliennedArrays]] +git-tree-sha1 = "4aeebbfcf0615641ec4b0782b73b638eeeabd62e" +uuid = "5cadff95-7770-533d-a838-a1bf817ee6e0" +version = "0.3.0" + [[deps.KernelAbstractions]] -deps = ["Adapt", "Atomix", "InteractiveUtils", "LinearAlgebra", "MacroTools", "SparseArrays", "StaticArrays", "UUIDs", "UnsafeAtomics", "UnsafeAtomicsLLVM"] -git-tree-sha1 = "cf9cae1c4c1ff83f6c02cfaf01698f05448e8325" +deps = ["Adapt", "Atomix", "InteractiveUtils", "LinearAlgebra", "MacroTools", "PrecompileTools", "Requires", "SparseArrays", "StaticArrays", "UUIDs", "UnsafeAtomics", "UnsafeAtomicsLLVM"] +git-tree-sha1 = "4c5875e4c228247e1c2b087669846941fb6e0118" uuid = "63c18a36-062a-441e-b654-da1e3ab1ce7c" -version = "0.8.6" +version = "0.9.8" + + [deps.KernelAbstractions.extensions] + EnzymeExt = "EnzymeCore" + + [deps.KernelAbstractions.weakdeps] + EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869" [[deps.LLVM]] deps = ["CEnum", "LLVMExtra_jll", "Libdl", "Printf", "Unicode"] -git-tree-sha1 = "df115c31f5c163697eede495918d8e85045c8f04" +git-tree-sha1 = "8695a49bfe05a2dc0feeefd06b4ca6361a018729" uuid = "929cbde3-209d-540e-8aea-75f648917ca0" -version = "4.16.0" +version = "6.1.0" [[deps.LLVMExtra_jll]] -deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl", "Pkg", "TOML"] -git-tree-sha1 = "7718cf44439c676bc0ec66a87099f41015a522d6" +deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl", "TOML"] +git-tree-sha1 = "c35203c1e1002747da220ffc3c0762ce7754b08c" uuid = "dad2f222-ce93-54a1-a47d-0025e8a3acab" -version = "0.0.16+2" +version = "0.0.23+0" [[deps.LabelledArrays]] deps = ["ArrayInterface", "ChainRulesCore", "ForwardDiff", "LinearAlgebra", "MacroTools", "PreallocationTools", "RecursiveArrayTools", "StaticArrays"] @@ -464,41 +546,103 @@ version = "1.10.2+0" uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" [[deps.LinearAlgebra]] -deps = ["Libdl", "libblastrampoline_jll"] +deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"] uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" [[deps.LogExpFunctions]] -deps = ["ChainRulesCore", "ChangesOfVariables", "DocStringExtensions", "InverseFunctions", "IrrationalConstants", "LinearAlgebra"] -git-tree-sha1 = "0a1b7c2863e44523180fdb3146534e265a91870b" +deps = ["DocStringExtensions", "IrrationalConstants", "LinearAlgebra"] +git-tree-sha1 = "7d6dd4e9212aebaeed356de34ccf262a3cd415aa" uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688" -version = "0.3.23" +version = "0.3.26" +weakdeps = ["ChainRulesCore", "ChangesOfVariables", "InverseFunctions"] + + [deps.LogExpFunctions.extensions] + LogExpFunctionsChainRulesCoreExt = "ChainRulesCore" + LogExpFunctionsChangesOfVariablesExt = "ChangesOfVariables" + LogExpFunctionsInverseFunctionsExt = "InverseFunctions" [[deps.Logging]] uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" [[deps.LoggingExtras]] deps = ["Dates", "Logging"] -git-tree-sha1 = "cedb76b37bc5a6c702ade66be44f831fa23c681e" +git-tree-sha1 = "0d097476b6c381ab7906460ef1ef1638fbce1d91" uuid = "e6f89c97-d47a-5376-807f-9c37f3926c36" -version = "1.0.0" +version = "1.0.2" [[deps.Lux]] -deps = ["Adapt", "CUDA", "ChainRulesCore", "ComponentArrays", "FillArrays", "Flux", "Functors", "LinearAlgebra", "LuxCore", "LuxLib", "Markdown", "NNlib", "Optimisers", "Random", "Requires", "Setfield", "SparseArrays", "Statistics", "Zygote", "cuDNN"] -git-tree-sha1 = "d41d84224efbcedc852bef0918df707f4804c132" +deps = ["ADTypes", "Adapt", "ChainRulesCore", "ConcreteStructs", "Functors", "LinearAlgebra", "LuxCore", "LuxDeviceUtils", "LuxLib", "Markdown", "Optimisers", "PackageExtensionCompat", "Random", "Reexport", "Setfield", "SparseArrays", "Statistics", "TruncatedStacktraces", "WeightInitializers"] +git-tree-sha1 = "78fecc38a73321df15161a481864fce75b66ae84" uuid = "b2108857-7c20-44ae-9111-449ecde12c47" -version = "0.4.39" +version = "0.5.4" + + [deps.Lux.extensions] + LuxComponentArraysExt = "ComponentArrays" + LuxComponentArraysReverseDiffExt = ["ComponentArrays", "ReverseDiff"] + LuxComponentArraysTrackerExt = ["ComponentArrays", "Tracker"] + LuxComponentArraysZygoteExt = ["ComponentArrays", "Zygote"] + LuxFluxTransformExt = "Flux" + LuxLuxAMDGPUExt = "LuxAMDGPU" + LuxLuxCUDAExt = "LuxCUDA" + LuxTrackerExt = "Tracker" + LuxZygoteExt = "Zygote" + + [deps.Lux.weakdeps] + ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66" + FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" + Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c" + LuxAMDGPU = "83120cb1-ca15-4f04-bf3b-6967d2e6b60b" + LuxCUDA = "d0bbae9a-e099-4d5b-a835-1c6931763bda" + ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" + Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" + Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" [[deps.LuxCore]] -deps = ["Functors", "Random", "Setfield"] -git-tree-sha1 = "34d9708958ef04bf2f5430f2231449620dd0acf7" +deps = ["DocStringExtensions", "Functors", "Random", "Setfield"] +git-tree-sha1 = "f2dafe0ddcecf06247b40dbf336acd14e0adce6d" uuid = "bb33d45b-7691-41d6-9220-0943567d0623" -version = "0.1.2" +version = "0.1.5" + +[[deps.LuxDeviceUtils]] +deps = ["Adapt", "ChainRulesCore", "Functors", "LuxCore", "PackageExtensionCompat", "Preferences", "Random", "SparseArrays"] +git-tree-sha1 = "e67d2206f6f05f534dccbed1df2b60e452ce4d0d" +uuid = "34f89e08-e1d5-43b4-8944-0b49ac560553" +version = "0.1.7" + + [deps.LuxDeviceUtils.extensions] + LuxDeviceUtilsComponentArraysExt = "ComponentArrays" + LuxDeviceUtilsFillArraysExt = "FillArrays" + LuxDeviceUtilsLuxAMDGPUExt = "LuxAMDGPU" + LuxDeviceUtilsLuxCUDAExt = "LuxCUDA" + LuxDeviceUtilsMetalExt = "Metal" + LuxDeviceUtilsZygoteExt = "Zygote" + + [deps.LuxDeviceUtils.weakdeps] + ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66" + FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" + LuxAMDGPU = "83120cb1-ca15-4f04-bf3b-6967d2e6b60b" + LuxCUDA = "d0bbae9a-e099-4d5b-a835-1c6931763bda" + Metal = "dde4c033-4e86-420c-a63e-0dd931031962" + Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" [[deps.LuxLib]] -deps = ["CUDA", "CUDAKernels", "ChainRulesCore", "ForwardDiff", "KernelAbstractions", "Markdown", "NNlib", "NNlibCUDA", "Random", "Requires", "Statistics"] -git-tree-sha1 = "f59e10e664104b37fe05a56eaaed8d296f2a4ac2" +deps = ["ChainRulesCore", "KernelAbstractions", "Markdown", "NNlib", "PackageExtensionCompat", "Random", "Reexport", "Statistics"] +git-tree-sha1 = "06e1f04441a8835413b48c84c016313c16e1687b" uuid = "82251201-b29d-42c6-8e01-566dec8acb11" -version = "0.1.9" +version = "0.3.2" + + [deps.LuxLib.extensions] + LuxLibForwardDiffExt = "ForwardDiff" + LuxLibLuxCUDAExt = "LuxCUDA" + LuxLibLuxCUDATrackerExt = ["LuxCUDA", "Tracker"] + LuxLibReverseDiffExt = "ReverseDiff" + LuxLibTrackerExt = "Tracker" + + [deps.LuxLib.weakdeps] + ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" + LuxCUDA = "d0bbae9a-e099-4d5b-a835-1c6931763bda" + ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" + Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" [[deps.MLStyle]] git-tree-sha1 = "bc38dff0548128765760c79eb7388a4b37fae2c8" @@ -506,16 +650,16 @@ uuid = "d8e11817-5142-5d16-987a-aa16d5891078" version = "0.4.17" [[deps.MLUtils]] -deps = ["ChainRulesCore", "Compat", "DataAPI", "DelimitedFiles", "FLoops", "FoldsThreads", "NNlib", "Random", "ShowCases", "SimpleTraits", "Statistics", "StatsBase", "Tables", "Transducers"] -git-tree-sha1 = "f69cdbb5b7c630c02481d81d50eac43697084fe0" +deps = ["ChainRulesCore", "Compat", "DataAPI", "DelimitedFiles", "FLoops", "NNlib", "Random", "ShowCases", "SimpleTraits", "Statistics", "StatsBase", "Tables", "Transducers"] +git-tree-sha1 = "3504cdb8c2bc05bde4d4b09a81b01df88fcbbba0" uuid = "f1d291b0-491e-4a28-83b9-f70985020b54" -version = "0.4.1" +version = "0.4.3" [[deps.MacroTools]] deps = ["Markdown", "Random"] -git-tree-sha1 = "42324d08725e200c23d4dfb549e0d5d89dede2d2" +git-tree-sha1 = "9ee1618cbf5240e6d4e0371d6f24065083f60c48" uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" -version = "0.5.10" +version = "0.5.11" [[deps.Markdown]] deps = ["Base64"] @@ -530,13 +674,13 @@ version = "1.1.7" [[deps.MbedTLS_jll]] deps = ["Artifacts", "Libdl"] uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" -version = "2.28.0+0" +version = "2.28.2+0" [[deps.MicroCollections]] deps = ["BangBang", "InitialValues", "Setfield"] -git-tree-sha1 = "4d5917a26ca33c66c8e5ca3247bd163624d35493" +git-tree-sha1 = "629afd7d10dbc6935ec59b32daeb33bc4460a42e" uuid = "128add7d-3638-4c79-886c-908ea0c25c34" -version = "0.1.3" +version = "0.1.4" [[deps.Missings]] deps = ["DataAPI"] @@ -549,25 +693,31 @@ uuid = "a63ad114-7e13-5084-954f-fe012c677804" [[deps.MozillaCACerts_jll]] uuid = "14a3606d-f60d-562e-9121-12d972cd8159" -version = "2022.2.1" +version = "2022.10.11" [[deps.MultivariatePolynomials]] deps = ["ChainRulesCore", "DataStructures", "LinearAlgebra", "MutableArithmetics"] -git-tree-sha1 = "eaa98afe2033ffc0629f9d0d83961d66a021dfcc" +git-tree-sha1 = "f9978f23952b52b8d958b72f8b5368f84254dc02" uuid = "102ac46a-7ee4-5c85-9060-abc95bfdeaa3" -version = "0.4.7" +version = "0.5.1" [[deps.MutableArithmetics]] deps = ["LinearAlgebra", "SparseArrays", "Test"] -git-tree-sha1 = "3295d296288ab1a0a2528feb424b854418acff57" +git-tree-sha1 = "5879579adbd9bc3017fe63c766371aace1a1d641" uuid = "d8a4904e-b15c-11e9-3269-09a3773c0cb0" -version = "1.2.3" +version = "1.3.1" [[deps.NNlib]] -deps = ["Adapt", "ChainRulesCore", "LinearAlgebra", "Pkg", "Random", "Requires", "Statistics"] -git-tree-sha1 = "33ad5a19dc6730d592d8ce91c14354d758e53b0e" +deps = ["Adapt", "Atomix", "ChainRulesCore", "GPUArraysCore", "KernelAbstractions", "LinearAlgebra", "Pkg", "Random", "Requires", "Statistics"] +git-tree-sha1 = "72240e3f5ca031937bd536182cb2c031da5f46dd" uuid = "872c559c-99b0-510c-b3b7-b6c96a88d5cd" -version = "0.8.19" +version = "0.8.21" + + [deps.NNlib.extensions] + NNlibAMDGPUExt = "AMDGPU" + + [deps.NNlib.weakdeps] + AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e" [[deps.NNlibCUDA]] deps = ["Adapt", "CUDA", "LinearAlgebra", "NNlib", "Random", "Statistics", "cuDNN"] @@ -593,14 +743,14 @@ version = "1.2.0" [[deps.OneHotArrays]] deps = ["Adapt", "ChainRulesCore", "Compat", "GPUArraysCore", "LinearAlgebra", "NNlib"] -git-tree-sha1 = "f511fca956ed9e70b80cd3417bb8c2dde4b68644" +git-tree-sha1 = "5e4029759e8699ec12ebdf8721e51a659443403c" uuid = "0b1bfda6-eb8a-41d2-88d8-f5af5cad476f" -version = "0.2.3" +version = "0.2.4" [[deps.OpenBLAS_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" -version = "0.3.20+0" +version = "0.3.21+4" [[deps.OpenLibm_jll]] deps = ["Artifacts", "Libdl"] @@ -609,15 +759,15 @@ version = "0.8.1+0" [[deps.OpenSSL]] deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"] -git-tree-sha1 = "6503b77492fd7fcb9379bf73cd31035670e3c509" +git-tree-sha1 = "51901a49222b09e3743c65b8847687ae5fc78eb2" uuid = "4d8831e6-92b7-49fb-bdf8-b643e874388c" -version = "1.3.3" +version = "1.4.1" [[deps.OpenSSL_jll]] -deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] -git-tree-sha1 = "9ff31d101d987eb9d66bd8b176ac7c277beccd09" +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "e78db7bd5c26fc5a6911b50a47ee302219157ea8" uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95" -version = "1.1.20+0" +version = "3.0.10+0" [[deps.OpenSpecFun_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] @@ -627,25 +777,36 @@ version = "0.5.5+0" [[deps.Optimisers]] deps = ["ChainRulesCore", "Functors", "LinearAlgebra", "Random", "Statistics"] -git-tree-sha1 = "e657acef119cc0de2a8c0762666d3b64727b053b" +git-tree-sha1 = "c1fc26bab5df929a5172f296f25d7d08688fd25b" uuid = "3bd65402-5787-11e9-1adc-39752487f4e2" -version = "0.2.14" +version = "0.2.20" [[deps.OrderedCollections]] -git-tree-sha1 = "85f8e6578bf1f9ee0d11e7bb1b1456435479d47c" +git-tree-sha1 = "2e73fe17cac3c62ad1aebe70d44c963c3cfdc3e3" uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" -version = "1.4.1" +version = "1.6.2" + +[[deps.PackageExtensionCompat]] +git-tree-sha1 = "f9b1e033c2b1205cf30fd119f4e50881316c1923" +uuid = "65ce6f38-6b18-4e1d-a461-8949797d7930" +version = "1.0.1" +weakdeps = ["Requires", "TOML"] [[deps.Parsers]] -deps = ["Dates", "SnoopPrecompile"] -git-tree-sha1 = "6f4fbcd1ad45905a5dee3f4256fabb49aa2110c6" +deps = ["Dates", "PrecompileTools", "UUIDs"] +git-tree-sha1 = "716e24b21538abc91f6205fd1d8363f39b442851" uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" -version = "2.5.7" +version = "2.7.2" + +[[deps.PartialFunctions]] +git-tree-sha1 = "b3901ea034cfd8aae57a2fa0dde0b0ea18bad1cb" +uuid = "570af359-4316-4cb7-8c74-252c00c2016b" +version = "1.1.1" [[deps.Pkg]] -deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] +deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -version = "1.8.0" +version = "1.9.2" [[deps.PkgBenchmark]] deps = ["BenchmarkTools", "Dates", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Pkg", "Printf", "TerminalLoggers", "UUIDs"] @@ -658,12 +819,22 @@ deps = ["Adapt", "ArrayInterface", "ForwardDiff", "Requires"] git-tree-sha1 = "f739b1b3cc7b9949af3b35089931f2b58c289163" uuid = "d236fae5-4411-538c-8e31-a6e3d9e00b46" version = "0.4.12" +weakdeps = ["ReverseDiff"] + + [deps.PreallocationTools.extensions] + PreallocationToolsReverseDiffExt = "ReverseDiff" + +[[deps.PrecompileTools]] +deps = ["Preferences"] +git-tree-sha1 = "03b4c25b43cb84cee5c90aa9b5ea0a78fd848d2f" +uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a" +version = "1.2.0" [[deps.Preferences]] deps = ["TOML"] -git-tree-sha1 = "47e5f437cc0e7ef2ce8406ce1e7e24d44915f88d" +git-tree-sha1 = "7eb1686b4f04b82f96ed7a4ea5890a4f0c7a09f1" uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.3.0" +version = "1.4.0" [[deps.PrettyPrint]] git-tree-sha1 = "632eb4abab3449ab30c5e1afaa874f0b98b586e4" @@ -694,9 +865,9 @@ uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [[deps.Random123]] deps = ["Random", "RandomNumbers"] -git-tree-sha1 = "7a1a306b72cfa60634f03a911405f4e64d1b718b" +git-tree-sha1 = "552f30e847641591ba3f39fd1bed559b9deb0ef3" uuid = "74087812-796a-5b5d-8853-05524746bad3" -version = "1.6.0" +version = "1.6.1" [[deps.RandomNumbers]] deps = ["Random", "Requires"] @@ -711,16 +882,26 @@ uuid = "c1ae055f-0cd5-4b69-90a6-9a35b1a98df9" version = "0.1.0" [[deps.RecipesBase]] -deps = ["SnoopPrecompile"] -git-tree-sha1 = "261dddd3b862bd2c940cf6ca4d1c8fe593e457c8" +deps = ["PrecompileTools"] +git-tree-sha1 = "5c3d09cc4f31f5fc6af001c250bf1278733100ff" uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" -version = "1.3.3" +version = "1.3.4" [[deps.RecursiveArrayTools]] -deps = ["Adapt", "ArrayInterface", "ChainRulesCore", "DocStringExtensions", "FillArrays", "GPUArraysCore", "IteratorInterfaceExtensions", "LinearAlgebra", "RecipesBase", "Requires", "StaticArraysCore", "Statistics", "SymbolicIndexingInterface", "Tables", "ZygoteRules"] -git-tree-sha1 = "3dcb2a98436389c0aac964428a5fa099118944de" +deps = ["Adapt", "ArrayInterface", "DocStringExtensions", "GPUArraysCore", "IteratorInterfaceExtensions", "LinearAlgebra", "RecipesBase", "Requires", "StaticArraysCore", "Statistics", "SymbolicIndexingInterface", "Tables"] +git-tree-sha1 = "7ed35fb5f831aaf09c2d7c8736d44667a1afdcb0" uuid = "731186ca-8d62-57ce-b412-fbd966d074cd" -version = "2.38.0" +version = "2.38.7" + + [deps.RecursiveArrayTools.extensions] + RecursiveArrayToolsMeasurementsExt = "Measurements" + RecursiveArrayToolsTrackerExt = "Tracker" + RecursiveArrayToolsZygoteExt = "Zygote" + + [deps.RecursiveArrayTools.weakdeps] + Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7" + Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" + Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" [[deps.Reexport]] git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b" @@ -735,14 +916,20 @@ version = "1.3.0" [[deps.ReverseDiff]] deps = ["ChainRulesCore", "DiffResults", "DiffRules", "ForwardDiff", "FunctionWrappers", "LinearAlgebra", "LogExpFunctions", "MacroTools", "NaNMath", "Random", "SpecialFunctions", "StaticArrays", "Statistics"] -git-tree-sha1 = "afc870db2b2c2df1ba3f7b199278bb071e4f6f90" +git-tree-sha1 = "d1235bdd57a93bd7504225b792b867e9a7df38d5" uuid = "37e2e3b7-166d-5795-8a7a-e32c996b4267" -version = "1.14.4" +version = "1.15.1" [[deps.SHA]] uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" version = "0.7.0" +[[deps.Scratch]] +deps = ["Dates"] +git-tree-sha1 = "30449ee12237627992a99d5e30ae63e4d78cd24a" +uuid = "6c6a2e73-6563-6170-7368-637461726353" +version = "1.2.0" + [[deps.Serialization]] uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" @@ -768,30 +955,34 @@ git-tree-sha1 = "5d7e3f4e11935503d3ecaf7186eac40602e7d231" uuid = "699a6c99-e7fa-54fc-8d76-47d257e15c1d" version = "0.9.4" -[[deps.SnoopPrecompile]] -deps = ["Preferences"] -git-tree-sha1 = "e760a70afdcd461cf01a575947738d359234665c" -uuid = "66db9d55-30c0-4569-8b51-7e840670fc0c" -version = "1.0.3" +[[deps.SliceMap]] +deps = ["ForwardDiff", "JuliennedArrays", "StaticArrays", "Tracker", "ZygoteRules"] +git-tree-sha1 = "f988004407ccf6c398a87914eafdd8bc9109e533" +uuid = "82cb661a-3f19-5665-9e27-df437c7e54c8" +version = "0.2.7" [[deps.Sockets]] uuid = "6462fe0b-24de-5631-8697-dd941f90decc" [[deps.SortingAlgorithms]] deps = ["DataStructures"] -git-tree-sha1 = "a4ada03f999bd01b3a25dcaa30b2d929fe537e00" +git-tree-sha1 = "c60ec5c62180f27efea3ba2908480f8055e17cee" uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c" -version = "1.1.0" +version = "1.1.1" [[deps.SparseArrays]] -deps = ["LinearAlgebra", "Random"] +deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" [[deps.SpecialFunctions]] -deps = ["ChainRulesCore", "IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"] -git-tree-sha1 = "ef28127915f4229c971eb43f3fc075dd3fe91880" +deps = ["IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"] +git-tree-sha1 = "e2cfc4012a19088254b3950b85c3c1d8882d864d" uuid = "276daf66-3868-5448-9aa4-cd146d93841b" -version = "2.2.0" +version = "2.3.1" +weakdeps = ["ChainRulesCore"] + + [deps.SpecialFunctions.extensions] + SpecialFunctionsChainRulesCoreExt = "ChainRulesCore" [[deps.SplittablesBase]] deps = ["Setfield", "Test"] @@ -799,71 +990,69 @@ git-tree-sha1 = "e08a62abc517eb79667d0a29dc08a3b589516bb5" uuid = "171d559e-b47b-412a-8079-5efa626c420e" version = "0.1.15" -[[deps.Static]] -deps = ["IfElse"] -git-tree-sha1 = "d0435ba43ab5ad1cbb5f0d286ca4ba67029ed3ee" -uuid = "aedffcd0-7271-4cad-89d0-dc628f76c6d3" -version = "0.8.4" - -[[deps.StaticArrayInterface]] -deps = ["ArrayInterface", "Compat", "IfElse", "LinearAlgebra", "Requires", "SnoopPrecompile", "SparseArrays", "Static", "SuiteSparse"] -git-tree-sha1 = "5589ab073f8a244d2530b36478f53806f9106002" -uuid = "0d7ed370-da01-4f52-bd93-41d350b8b718" -version = "1.2.1" - [[deps.StaticArrays]] -deps = ["LinearAlgebra", "Random", "StaticArraysCore", "Statistics"] -git-tree-sha1 = "2d7d9e1ddadc8407ffd460e24218e37ef52dd9a3" +deps = ["LinearAlgebra", "Random", "StaticArraysCore"] +git-tree-sha1 = "9cabadf6e7cd2349b6cf49f1915ad2028d65e881" uuid = "90137ffa-7385-5640-81b9-e52037218182" -version = "1.5.16" +version = "1.6.2" +weakdeps = ["Statistics"] + + [deps.StaticArrays.extensions] + StaticArraysStatisticsExt = "Statistics" [[deps.StaticArraysCore]] -git-tree-sha1 = "6b7ba252635a5eff6a0b0664a41ee140a1c9e72a" +git-tree-sha1 = "36b3d696ce6366023a0ea192b4cd442268995a0d" uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" -version = "1.4.0" +version = "1.4.2" [[deps.Statistics]] deps = ["LinearAlgebra", "SparseArrays"] uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" +version = "1.9.0" [[deps.StatsAPI]] deps = ["LinearAlgebra"] -git-tree-sha1 = "f9af7f195fb13589dd2e2d57fdb401717d2eb1f6" +git-tree-sha1 = "45a7769a04a3cf80da1c1c7c60caf932e6f4c9f7" uuid = "82ae8749-77ed-4fe6-ae5f-f523153014b0" -version = "1.5.0" +version = "1.6.0" [[deps.StatsBase]] deps = ["DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"] -git-tree-sha1 = "d1bf48bfcc554a3761a133fe3a9bb01488e06916" +git-tree-sha1 = "75ebe04c5bed70b91614d684259b661c9e6274a4" uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" -version = "0.33.21" +version = "0.34.0" [[deps.StructArrays]] deps = ["Adapt", "DataAPI", "GPUArraysCore", "StaticArraysCore", "Tables"] -git-tree-sha1 = "b03a3b745aa49b566f128977a7dd1be8711c5e71" +git-tree-sha1 = "521a0e828e98bb69042fec1809c1b5a680eb7389" uuid = "09ab397b-f2b6-538f-b94a-2f83cf4a842a" -version = "0.6.14" +version = "0.6.15" [[deps.SuiteSparse]] deps = ["Libdl", "LinearAlgebra", "Serialization", "SparseArrays"] uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" +[[deps.SuiteSparse_jll]] +deps = ["Artifacts", "Libdl", "Pkg", "libblastrampoline_jll"] +uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" +version = "5.10.1+6" + [[deps.SymbolicIndexingInterface]] deps = ["DocStringExtensions"] -git-tree-sha1 = "6b764c160547240d868be4e961a5037f47ad7379" +git-tree-sha1 = "f8ab052bfcbdb9b48fad2c80c873aa0d0344dfe5" uuid = "2efcf032-c050-4f8e-a9bb-153293bab1f5" -version = "0.2.1" +version = "0.2.2" [[deps.SymbolicUtils]] deps = ["AbstractTrees", "Bijections", "ChainRulesCore", "Combinatorics", "ConstructionBase", "DataStructures", "DocStringExtensions", "DynamicPolynomials", "IfElse", "LabelledArrays", "LinearAlgebra", "MultivariatePolynomials", "NaNMath", "Setfield", "SparseArrays", "SpecialFunctions", "StaticArrays", "TimerOutputs", "Unityper"] -git-tree-sha1 = "ca0dbe8434ace322cea02fc8cce0dea8d5308e87" +git-tree-sha1 = "9704a1d0ecbbf5d65700418dcf1bb4c680c790bb" uuid = "d1185830-fcd6-423d-90d6-eec64667417b" -version = "1.0.3" +version = "1.2.0" [[deps.TOML]] deps = ["Dates"] uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" -version = "1.0.0" +version = "1.0.3" [[deps.TableTraits]] deps = ["IteratorInterfaceExtensions"] @@ -873,32 +1062,38 @@ version = "1.0.1" [[deps.Tables]] deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "OrderedCollections", "TableTraits", "Test"] -git-tree-sha1 = "c79322d36826aa2f4fd8ecfa96ddb47b174ac78d" +git-tree-sha1 = "1544b926975372da01227b382066ab70e574a3ec" uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" -version = "1.10.0" +version = "1.10.1" [[deps.Tar]] deps = ["ArgTools", "SHA"] uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" -version = "1.10.1" +version = "1.10.0" [[deps.TaylorDiff]] deps = ["ChainRules", "ChainRulesCore", "ChainRulesOverloadGeneration", "SymbolicUtils", "Zygote"] -path = ".." +git-tree-sha1 = "5d7a5fa2e46e068ef8b591c3fcf147a927601181" uuid = "b36ab563-344f-407b-a36a-4f200bebf99c" version = "0.2.1" [[deps.TaylorSeries]] deps = ["LinearAlgebra", "Markdown", "Requires", "SparseArrays"] -git-tree-sha1 = "31834a05c8a9d52d7f56b23ae7ad1c3b72a4f1bf" +git-tree-sha1 = "50718b4fc1ce20cecf28d85215028c78b4d875c2" uuid = "6aa5eb33-94cf-58f4-a9d0-e4b2c4fc25ea" -version = "0.13.2" +version = "0.15.2" + + [deps.TaylorSeries.extensions] + TaylorSeriesIAExt = "IntervalArithmetic" + + [deps.TaylorSeries.weakdeps] + IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253" [[deps.TerminalLoggers]] deps = ["LeftChildRightSiblingTrees", "Logging", "Markdown", "Printf", "ProgressLogging", "UUIDs"] -git-tree-sha1 = "f53e34e784ae771eb9ccde4d72e578aa453d0554" +git-tree-sha1 = "f133fab380933d042f6796eda4e130272ba520ca" uuid = "5d786b92-1e48-4d6f-9151-6b4477ca9bed" -version = "0.1.6" +version = "0.1.7" [[deps.Test]] deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] @@ -906,26 +1101,58 @@ uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [[deps.TimerOutputs]] deps = ["ExprTools", "Printf"] -git-tree-sha1 = "f2fd3f288dfc6f507b0c3a2eb3bac009251e548b" +git-tree-sha1 = "f548a9e9c490030e545f72074a41edfd0e5bcdd7" uuid = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f" -version = "0.5.22" +version = "0.5.23" + +[[deps.Tracker]] +deps = ["Adapt", "DiffRules", "ForwardDiff", "Functors", "LinearAlgebra", "LogExpFunctions", "MacroTools", "NNlib", "NaNMath", "Optimisers", "Printf", "Random", "Requires", "SpecialFunctions", "Statistics"] +git-tree-sha1 = "92364c27aa35c0ee36e6e010b704adaade6c409c" +uuid = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" +version = "0.2.26" + + [deps.Tracker.extensions] + TrackerPDMatsExt = "PDMats" + + [deps.Tracker.weakdeps] + PDMats = "90014a1f-27ba-587c-ab20-58faa44d9150" [[deps.TranscodingStreams]] deps = ["Random", "Test"] -git-tree-sha1 = "94f38103c984f89cf77c402f2a68dbd870f8165f" +git-tree-sha1 = "9a6ae7ed916312b41236fcef7e0af564ef934769" uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" -version = "0.9.11" +version = "0.9.13" [[deps.Transducers]] -deps = ["Adapt", "ArgCheck", "BangBang", "Baselet", "CompositionsBase", "DefineSingletons", "Distributed", "InitialValues", "Logging", "Markdown", "MicroCollections", "Requires", "Setfield", "SplittablesBase", "Tables"] -git-tree-sha1 = "c42fa452a60f022e9e087823b47e5a5f8adc53d5" +deps = ["Adapt", "ArgCheck", "BangBang", "Baselet", "CompositionsBase", "ConstructionBase", "DefineSingletons", "Distributed", "InitialValues", "Logging", "Markdown", "MicroCollections", "Requires", "Setfield", "SplittablesBase", "Tables"] +git-tree-sha1 = "53bd5978b182fa7c57577bdb452c35e5b4fb73a5" uuid = "28d57a85-8fef-5791-bfe6-a80928e7c999" -version = "0.4.75" +version = "0.4.78" + + [deps.Transducers.extensions] + TransducersBlockArraysExt = "BlockArrays" + TransducersDataFramesExt = "DataFrames" + TransducersLazyArraysExt = "LazyArrays" + TransducersOnlineStatsBaseExt = "OnlineStatsBase" + TransducersReferenceablesExt = "Referenceables" + + [deps.Transducers.weakdeps] + BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e" + DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" + LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02" + OnlineStatsBase = "925886fa-5bf2-5e8e-b522-a9147a512338" + Referenceables = "42d2dcc6-99eb-4e98-b66c-637b7d73030e" + +[[deps.TruncatedStacktraces]] +deps = ["InteractiveUtils", "MacroTools", "Preferences"] +git-tree-sha1 = "ea3e54c2bdde39062abf5a9758a23735558705e1" +uuid = "781d530d-4396-4725-bb49-402e4bee1e77" +version = "1.4.0" [[deps.URIs]] -git-tree-sha1 = "074f993b0ca030848b897beff716d93aca60f06a" +git-tree-sha1 = "b7a5e99f24892b6824a954199a45e9ffcc1c70f0" uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" -version = "1.4.2" +version = "1.5.0" [[deps.UUIDs]] deps = ["Random", "SHA"] @@ -936,9 +1163,9 @@ uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" [[deps.Unityper]] deps = ["ConstructionBase"] -git-tree-sha1 = "d5f4ec8c22db63bd3ccb239f640e895cfde145aa" +git-tree-sha1 = "21c8fc7cd598ef49f11bc9e94871f5d7740e34b9" uuid = "a7c27f48-0311-42f6-a7f8-2c11e75eb415" -version = "0.1.2" +version = "0.1.5" [[deps.UnsafeAtomics]] git-tree-sha1 = "6331ac3440856ea1988316b46045303bef658278" @@ -947,37 +1174,53 @@ version = "0.2.1" [[deps.UnsafeAtomicsLLVM]] deps = ["LLVM", "UnsafeAtomics"] -git-tree-sha1 = "33af9d2031d0dc09e2be9a0d4beefec4466def8e" +git-tree-sha1 = "323e3d0acf5e78a56dfae7bd8928c989b4f3083e" uuid = "d80eeb9a-aca5-4d75-85e5-170c8b632249" -version = "0.1.0" +version = "0.1.3" + +[[deps.WeightInitializers]] +deps = ["PartialFunctions", "Random", "SpecialFunctions", "Statistics"] +git-tree-sha1 = "214ad59a8ece2118a1e70a07a32cef784a5c0704" +uuid = "d49dbf32-c5c2-4618-8acc-27bb2598ef2d" +version = "0.1.1" [[deps.Zlib_jll]] deps = ["Libdl"] uuid = "83775a58-1f1d-513f-b197-d71354ab007a" -version = "1.2.12+3" +version = "1.2.13+0" [[deps.Zygote]] -deps = ["AbstractFFTs", "ChainRules", "ChainRulesCore", "DiffRules", "Distributed", "FillArrays", "ForwardDiff", "GPUArrays", "GPUArraysCore", "IRTools", "InteractiveUtils", "LinearAlgebra", "LogExpFunctions", "MacroTools", "NaNMath", "Random", "Requires", "SparseArrays", "SpecialFunctions", "Statistics", "ZygoteRules"] -git-tree-sha1 = "e1af683167eea952684188f5e1e29b9cabc2e5f9" +deps = ["AbstractFFTs", "ChainRules", "ChainRulesCore", "DiffRules", "Distributed", "FillArrays", "ForwardDiff", "GPUArrays", "GPUArraysCore", "IRTools", "InteractiveUtils", "LinearAlgebra", "LogExpFunctions", "MacroTools", "NaNMath", "PrecompileTools", "Random", "Requires", "SparseArrays", "SpecialFunctions", "Statistics", "ZygoteRules"] +git-tree-sha1 = "e2fe78907130b521619bc88408c859a472c4172b" uuid = "e88e6eb3-aa80-5325-afca-941959d7151f" -version = "0.6.55" +version = "0.6.63" + + [deps.Zygote.extensions] + ZygoteColorsExt = "Colors" + ZygoteDistancesExt = "Distances" + ZygoteTrackerExt = "Tracker" + + [deps.Zygote.weakdeps] + Colors = "5ae59095-9a9b-59fe-a467-6f913c188581" + Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7" + Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" [[deps.ZygoteRules]] -deps = ["MacroTools"] -git-tree-sha1 = "8c1a8e4dfacb1fd631745552c8db35d0deb09ea0" +deps = ["ChainRulesCore", "MacroTools"] +git-tree-sha1 = "977aed5d006b840e2e40c0b48984f7463109046d" uuid = "700de1a5-db45-46bc-99cf-38207098b444" -version = "0.2.2" +version = "0.2.3" [[deps.cuDNN]] deps = ["CEnum", "CUDA", "CUDNN_jll"] -git-tree-sha1 = "c0ffcb38d1e8c0bbcd3dab2559cf9c369130b2f2" +git-tree-sha1 = "ee79f97d07bf875231559f9b3f2649f34fac140b" uuid = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd" -version = "1.0.1" +version = "1.1.0" [[deps.libblastrampoline_jll]] -deps = ["Artifacts", "Libdl", "OpenBLAS_jll"] +deps = ["Artifacts", "Libdl"] uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" -version = "5.1.1+0" +version = "5.8.0+0" [[deps.nghttp2_jll]] deps = ["Artifacts", "Libdl"] diff --git a/benchmark/Project.toml b/benchmark/Project.toml index 8d59d32..4f8d0e5 100644 --- a/benchmark/Project.toml +++ b/benchmark/Project.toml @@ -8,9 +8,11 @@ JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" Lux = "b2108857-7c20-44ae-9111-449ecde12c47" PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d" ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" +SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" TaylorDiff = "b36ab563-344f-407b-a36a-4f200bebf99c" TaylorSeries = "6aa5eb33-94cf-58f4-a9d0-e4b2c4fc25ea" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" +SliceMap = "82cb661a-3f19-5665-9e27-df437c7e54c8" [compat] Zygote = "0.6.55" diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index a575a26..7226ee2 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -15,6 +15,6 @@ scalar = create_benchmark_scalar_function(sin, 0.1) mlp = create_benchmark_mlp((2, 16), [2.0, 3.0], [1.0, 1.0]) const SUITE = BenchmarkGroup("scalar" => scalar, - "mlp" => mlp, - "taylor_expansion" => taylor_expansion, - "pinn" => pinn) + "mlp" => mlp, + "taylor_expansion" => taylor_expansion, + "pinn" => pinn) diff --git a/benchmark/helper.jl b/benchmark/helper.jl index c9f0a97..f73e53a 100644 --- a/benchmark/helper.jl +++ b/benchmark/helper.jl @@ -10,7 +10,7 @@ dict(x) = Dict(name => lower(getfield(x, name)) for name in fieldnames(typeof(x) lower(results::BenchmarkResults) = dict(results) function lower(group::BenchmarkGroup) Dict(:tags => group.tags, - :data => Dict(key => lower(value) for (key, value) in group.data)) + :data => Dict(key => lower(value) for (key, value) in group.data)) end lower(trial::Trial) = lower(minimum(trial)) lower(estimate::TrialEstimate) = dict(estimate) @@ -26,7 +26,7 @@ struct Buildkite <: ContextProvider end function provide_context(::Buildkite) getenv(name::String) = String(strip(ENV[name])) BenchmarkContext(now(), # datetime - getenv("BUILDKITE_COMMIT"), # commit - getenv("BUILDKITE_BRANCH"), # branch - getenv("BUILDKITE_TAG")) + getenv("BUILDKITE_COMMIT"), # commit + getenv("BUILDKITE_BRANCH"), # branch + getenv("BUILDKITE_TAG")) end diff --git a/benchmark/mlp.jl b/benchmark/mlp.jl index 9b09880..aba9952 100644 --- a/benchmark/mlp.jl +++ b/benchmark/mlp.jl @@ -1,5 +1,5 @@ function create_benchmark_mlp(mlp_conf::Tuple{Int, Int}, x::Vector{T}, - l::Vector{T}) where {T <: Number} + l::Vector{T}) where {T <: Number} input, hidden = mlp_conf W₁, W₂, b₁, b₂ = rand(hidden, input), rand(1, hidden), rand(hidden), rand(1) σ = exp @@ -21,6 +21,6 @@ function create_benchmark_mlp(mlp_conf::Tuple{Int, Int}, x::Vector{T}, taylordiff[index] = @benchmarkable derivative($mlp, $x, $l, $N) end return BenchmarkGroup(["vector"], - "forwarddiff" => forwarddiff, - "taylordiff" => taylordiff) + "forwarddiff" => forwarddiff, + "taylordiff" => taylordiff) end diff --git a/benchmark/pinn.jl b/benchmark/pinn.jl index 40608ae..6aeba9a 100644 --- a/benchmark/pinn.jl +++ b/benchmark/pinn.jl @@ -2,9 +2,9 @@ const input = 2 const hidden = 16 model = Chain(Dense(input => hidden, exp), - Dense(hidden => hidden, exp), - Dense(hidden => 1), - first) + Dense(hidden => hidden, exp), + Dense(hidden => 1), + first) trial(model, x) = x[1] * (1 - x[1]) * x[2] * (1 - x[2]) * model(x) x = rand(Float32, input) @@ -26,10 +26,10 @@ function loss_by_taylordiff(model, x) end pinn_t = BenchmarkGroup("primal" => (@benchmarkable loss_by_taylordiff($model, $x)), - "gradient" => (@benchmarkable gradient(loss_by_taylordiff, $model, - $x))) + "gradient" => (@benchmarkable gradient(loss_by_taylordiff, $model, + $x))) pinn_f = BenchmarkGroup("primal" => (@benchmarkable loss_by_finitediff($model, $x)), - "gradient" => (@benchmarkable gradient($loss_by_finitediff, $model, - $x))) + "gradient" => (@benchmarkable gradient($loss_by_finitediff, $model, + $x))) pinn = BenchmarkGroup(["vector", "physical"], "taylordiff" => pinn_t, - "finitediff" => pinn_f) + "finitediff" => pinn_f) diff --git a/benchmark/runbenchmarks.jl b/benchmark/runbenchmarks.jl index dcc8de3..517b7d9 100644 --- a/benchmark/runbenchmarks.jl +++ b/benchmark/runbenchmarks.jl @@ -10,10 +10,11 @@ using HTTP: put include("helper.jl") -context = provide_context(Buildkite()) +context = provide_context(Dummy()) results = benchmarkpkg(TaylorDiff) (; benchmarkgroup, benchmarkconfig) = results reconstructed = Dict("context" => context, - "suite" => benchmarkgroup, - "config" => benchmarkconfig) -put("https://benchmark.tansongchen.com/TaylorDiff.jl"; body = json(reconstructed)) + "suite" => benchmarkgroup, + "config" => benchmarkconfig) +put("https://benchmark-data.tansongchen.workers.dev/TaylorDiff.jl"; + body = json(reconstructed)) diff --git a/benchmark/scalar.jl b/benchmark/scalar.jl index be38516..7ac47c3 100644 --- a/benchmark/scalar.jl +++ b/benchmark/scalar.jl @@ -17,6 +17,6 @@ function create_benchmark_scalar_function(f::F, x::T) where {F, T <: Number} taylordiff_group[index] = @benchmarkable derivative($f, $x, $N) end return BenchmarkGroup(["scalar"], - "forwarddiff" => forwarddiff_group, - "taylordiff" => taylordiff_group) + "forwarddiff" => forwarddiff_group, + "taylordiff" => taylordiff_group) end diff --git a/benchmark/taylor_expansion.jl b/benchmark/taylor_expansion.jl index 4556edd..68b5db1 100644 --- a/benchmark/taylor_expansion.jl +++ b/benchmark/taylor_expansion.jl @@ -13,8 +13,8 @@ p ./= sum(p) t_ts = Taylor1(eltype(p), m) t_td = TaylorScalar{eltype(p), m + 1}(0.0, 1.0) taylor_expansion = BenchmarkGroup(["scalar", "very-high-order"], - "taylorseries" => (@benchmarkable my_calculation($t_ts, - $p, $α, - $s)), - "taylordiff" => (@benchmarkable my_calculation($t_td, $p, - $α, $s))) + "taylorseries" => (@benchmarkable my_calculation($t_ts, + $p, $α, + $s)), + "taylordiff" => (@benchmarkable my_calculation($t_td, $p, + $α, $s))) diff --git a/docs/make.jl b/docs/make.jl index 0be3136..a315434 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -4,20 +4,20 @@ using Documenter DocMeta.setdocmeta!(TaylorDiff, :DocTestSetup, :(using TaylorDiff); recursive = true) makedocs(; - modules = [TaylorDiff], - authors = "Songchen Tan and contributors", - repo = "https://github.com/JuliaDiff/TaylorDiff.jl/blob/{commit}{path}#{line}", - sitename = "TaylorDiff.jl", - format = Documenter.HTML(; - prettyurls = get(ENV, "CI", "false") == "true", - canonical = "https://juliadiff.org/TaylorDiff.jl", - edit_link = "main", - assets = String[]), - pages = [ - "Home" => "index.md", - "API" => "api.md", - ]) + modules = [TaylorDiff], + authors = "Songchen Tan and contributors", + repo = "https://github.com/JuliaDiff/TaylorDiff.jl/blob/{commit}{path}#{line}", + sitename = "TaylorDiff.jl", + format = Documenter.HTML(; + prettyurls = get(ENV, "CI", "false") == "true", + canonical = "https://juliadiff.org/TaylorDiff.jl", + edit_link = "main", + assets = String[]), + pages = [ + "Home" => "index.md", + "API" => "api.md" + ]) deploydocs(; - repo = "github.com/JuliaDiff/TaylorDiff.jl", - devbranch = "main") + repo = "github.com/JuliaDiff/TaylorDiff.jl", + devbranch = "main") diff --git a/docs/src/index.md b/docs/src/index.md index 9616aab..a1ea97c 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -42,7 +42,7 @@ Please see our [documentation](https://juliadiff.org/TaylorDiff.jl) for more det - [TaylorSeries.jl](https://github.com/JuliaDiff/TaylorSeries.jl): a systematic treatment of Taylor polynomials in one and several variables, but its mutating and scalar code isn't great for speed and composability with other packages - [ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl): well-established and robust operator-overloading based forward-mode AD, where higher-order derivatives can be achieved by nesting first-order derivatives -- [Diffractor.jl](https://github.com/PumasAI/SimpleChains.jl): next-generation source-code transformation based forward-mode and reverse-mode AD, designed with support for higher-order derivatives in mind; but the higher-order functionality is currently only a proof-of-concept +- [Diffractor.jl](https://github.com/JuliaDiff/Diffractor.jl): next-generation source-code transformation based forward-mode and reverse-mode AD, designed with support for higher-order derivatives in mind; but the higher-order functionality is currently only a proof-of-concept - [`jax.jet`](https://jax.readthedocs.io/en/latest/jax.experimental.jet.html): an experimental (and unmaintained) implementation of Taylor-mode automatic differentiation in JAX, sharing the same underlying algorithm with this project ## Citation diff --git a/examples/halley.ipynb b/examples/halley.ipynb new file mode 100644 index 0000000..0033fdf --- /dev/null +++ b/examples/halley.ipynb @@ -0,0 +1,264 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# The Jacobian- and Hessian-free Halley's Method\n", + "\n", + "Say we have a system of $n$ equations with $n$ unknowns\n", + "\n", + "$$\n", + "f(x)=0\n", + "$$\n", + "\n", + "and $f\\in \\mathbb R^n\\to\\mathbb R^n$ is sufficiently smooth.\n", + "\n", + "Given a initial guess $x_0$, Halley's method specifies a series of points approximating the solution, where each iteration is\n", + "\n", + "$$\n", + "x^{(i+1)}=x^{(i)}+\\frac{a^{(i)}a^{(i)}}{a^{(i)}+b^{(i)}/2}\n", + "$$\n", + "\n", + "where the vector multiplication and division $ab, a/b$ is defined in Banach algebra, and the vectors $a^{(i)}, b^{(i)}$ are defined as\n", + "\n", + "$$\n", + "J(x^{(i)})a^{(i)} = -f(x^{(i)})\n", + "$$\n", + "\n", + "and\n", + "\n", + "$$\n", + "J(x^{(i)})b^{(i)} = H(x^{(i)})a^{(i)}a^{(i)}\n", + "$$\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The full Jacobian (a matrix) and full Hessian (a 3-tensor) representation can be avoided by using forward-mode automatic differentiation. It is well known that a forward evaluation on a dual number $(x, v)$ gives the Jacobian-vector product,\n", + "\n", + "$$\n", + "f(x,v)=(f(x),Jv)\n", + "$$\n", + "\n", + "and similarly a forward evaluation on a second order Taylor expansion gives the Hessian-vector-vector product,\n", + "\n", + "$$\n", + "f(x,v,0)=f(x,Jv,Hvv)\n", + "$$\n", + "\n", + "Below, we demonstrate this possibility with TaylorDiff.jl." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Jacobian-free Newton Krylov\n", + "\n", + "To get started we first get familiar with the JFNK:" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "newton (generic function with 1 method)" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# The Jacobi- and Hessian-free Halley method for solving nonlinear equations\n", + "\n", + "using TaylorDiff\n", + "using LinearAlgebra\n", + "using LinearSolve\n", + "\n", + "function newton(f, x0, p; tol=1e-10, maxiter=100)\n", + " x = x0\n", + " for i in 1:maxiter\n", + " fx = f(x, p)\n", + " error = norm(fx)\n", + " println(\"Iteration $i: x = $x, f(x) = $fx, error = $error\")\n", + " if error < tol\n", + " return x\n", + " end\n", + " get_derivative = (v, u, a, b) -> v .= derivative(x -> f(x, p), x, u, 1)\n", + " operator = FunctionOperator(get_derivative, similar(x), similar(x))\n", + " problem = LinearProblem(operator, -fx)\n", + " sol = solve(problem, KrylovJL_GMRES())\n", + " x += sol.u\n", + " end\n", + " return x\n", + "end" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Jacobian- and Hessian-free Halley\n", + "\n", + "This naturally follows, only difference is replacing the rhs by Hessian-vector-vector product:" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "halley (generic function with 1 method)" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "function halley(f, x0, p; tol=1e-10, maxiter=100)\n", + " x = x0\n", + " for i in 1:maxiter\n", + " fx = f(x, p)\n", + " error = norm(fx)\n", + " println(\"Iteration $i: x = $x, f(x) = $fx, error = $error\")\n", + " if error < tol\n", + " return x\n", + " end\n", + " get_derivative = (v, u, a, b) -> v .= derivative(x -> f(x, p), x, u, 1)\n", + " operator = FunctionOperator(get_derivative, similar(x), similar(x))\n", + " problem = LinearProblem(operator, -fx)\n", + " a = solve(problem, KrylovJL_GMRES()).u\n", + " Haa = derivative(x -> f(x, p), x, a, 2)\n", + " problem2 = LinearProblem(operator, Haa)\n", + " b = solve(problem2, KrylovJL_GMRES()).u\n", + " x += (a .* a) ./ (a .+ b ./ 2)\n", + " end\n", + " return x\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "f (generic function with 1 method)" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# Testing with simple examples:\n", + "\n", + "f(x, p) = x .* x - p" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Iteration 1: x = [1.0, 1.0], f(x) = [-1.0, -1.0], error = 1.4142135623730951\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Iteration 2: x = [1.5, 1.5], f(x) = [0.25, 0.25], error = 0.3535533905932738\n", + "Iteration 3: x = [1.4166666666666667, 1.4166666666666667], f(x) = [0.006944444444444642, 0.006944444444444642], error = 0.009820927516480105\n", + "Iteration 4: x = [1.4142156862745099, 1.4142156862745099], f(x) = [6.007304882871267e-6, 6.007304882871267e-6], error = 8.495612038666664e-6\n", + "Iteration 5: x = [1.4142135623746899, 1.4142135623746899], f(x) = [4.510614104447086e-12, 4.510614104447086e-12], error = 6.378971641140442e-12\n" + ] + }, + { + "data": { + "text/plain": [ + "2-element Vector{Float64}:\n", + " 1.4142135623746899\n", + " 1.4142135623746899" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "newton(f, [1., 1.], [2., 2.])" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Iteration 1: x = [1.0, 1.0], f(x) = [-1.0, -1.0], error = 1.4142135623730951\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Iteration 2: x = [1.4000000000000001, 1.4000000000000001], f(x) = [-0.03999999999999959, -0.03999999999999959], error = 0.05656854249492323\n", + "Iteration 3: x = [1.4142131979695431, 1.4142131979695431], f(x) = [-1.0306887576749801e-6, -1.0306887576749801e-6], error = 1.4576140196894333e-6\n", + "Iteration 4: x = [1.414213562373142, 1.414213562373142], f(x) = [1.3278267374516872e-13, 1.3278267374516872e-13], error = 1.877830580585795e-13\n" + ] + }, + { + "data": { + "text/plain": [ + "2-element Vector{Float64}:\n", + " 1.414213562373142\n", + " 1.414213562373142" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "halley(f, [1., 1.], [2., 2.])" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Julia 1.10.1", + "language": "julia", + "name": "julia-1.10" + }, + "language_info": { + "file_extension": ".jl", + "mimetype": "application/julia", + "name": "julia", + "version": "1.10.1" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/examples/halley.jl b/examples/halley.jl new file mode 100644 index 0000000..9b9d054 --- /dev/null +++ b/examples/halley.jl @@ -0,0 +1,46 @@ +# The Jacobi- and Hessian-free Halley method for solving nonlinear equations + +using TaylorDiff +using LinearAlgebra +using LinearSolve + +function newton(f, x0, p; tol = 1e-10, maxiter = 100) + x = x0 + for i in 1:maxiter + fx = f(x, p) + error = norm(fx) + println("Iteration $i: x = $x, f(x) = $fx, error = $error") + if error < tol + return x + end + get_derivative = (v, u, a, b) -> v .= derivative(x -> f(x, p), x, u, 1) + operator = FunctionOperator(get_derivative, similar(x), similar(x)) + problem = LinearProblem(operator, -fx) + sol = solve(problem, KrylovJL_GMRES()) + x += sol.u + end + return x +end + +function halley(f, x0, p; tol = 1e-10, maxiter = 100) + x = x0 + for i in 1:maxiter + fx = f(x, p) + error = norm(fx) + println("Iteration $i: x = $x, f(x) = $fx, error = $error") + if error < tol + return x + end + get_derivative = (v, u, a, b) -> v .= derivative(x -> f(x, p), x, u, 1) + operator = FunctionOperator(get_derivative, similar(x), similar(x)) + problem = LinearProblem(operator, -fx) + a = solve(problem, KrylovJL_GMRES()).u + Haa = derivative(x -> f(x, p), x, a, 2) + problem2 = LinearProblem(operator, Haa) + b = solve(problem2, KrylovJL_GMRES()).u + x += (a .* a) ./ (a .+ b ./ 2) + end + return x +end + +f(x, p) = x .* x - p diff --git a/examples/integration.jl b/examples/integration.jl new file mode 100644 index 0000000..25c09b6 --- /dev/null +++ b/examples/integration.jl @@ -0,0 +1,109 @@ +using TaylorDiff +using TaylorSeries +using TaylorIntegration: jetcoeffs! +using BenchmarkTools + +""" +No magic, just a type-stable way to generate a new object since TaylorScalar is immutable +""" +function update_coefficient(x::TaylorScalar{T, N}, index::Integer, value::T) where {T, N} + return TaylorScalar(ntuple(i -> (i == index ? value : x.value[i]), Val{N}())) +end + +""" +Computes the taylor integration of order N - 1, i.e. N = order + 1 + +eqsdiff: RHS +t: constructed by TaylorScalar{T, N}(t0, 1), which means unit perturbation +x0: initial value +""" +function jetcoeffs_taylordiff(eqsdiff::Function, t::TaylorScalar{T, N}, x0::U, + params) where + {T <: Real, U <: Number, N} + x = TaylorScalar{U, N}(x0) # x.values[1] is defined, others are 0 + for index in 1:(N - 1) # computes x.values[index + 1] + f = eqsdiff(x, params, t) + df = TaylorDiff.extract_derivative(f, index) + x = update_coefficient(x, index + 1, df) + end + x +end + +""" +Computes the taylor integration of order N - 1, i.e. N = order + 1 + +eqsdiff!: RHS, in non-allocation form +t: constructed by TaylorScalar{T, N}(t0, 1), which means unit perturbation +x0: initial value +""" +function jetcoeffs_array_taylordiff( + eqsdiff!::Function, t::TaylorScalar{T, N}, x0::AbstractArray{U, D}, + params) where + {T <: Real, U <: Number, N, D} + x = map(TaylorScalar{U, N}, x0) # x.values[1] is defined, others are 0 + f = similar(x) + for index in 1:(N - 1) # computes x.values[index + 1] + eqsdiff!(f, x, params, t) + df = TaylorDiff.extract_derivative.(f, index) + x = update_coefficient.(x, index + 1, df) + end + x +end + +""" +In TaylorDiff.jl, the polynomial coefficients are just the n-th order derivatives, +not normalized by n!. So to compare with TaylorSeries.jl, one need to normalize +""" +function normalize_taylordiff_coeffs(t::TaylorScalar) + return [x / factorial(i - 1) for (i, x) in enumerate(t.value)] +end + +function scalar_test() + rhs(x, p, t) = x * x + + x0 = 0.1 + t0 = 0.0 + order = 6 + N = 7 # N = order + 1 + + # TaylorIntegration test + t = t0 + Taylor1(typeof(t0), order) + x = Taylor1(x0, order) + @btime jetcoeffs!($rhs, $t, $x, nothing) + + # TaylorDiff test + td = TaylorScalar{typeof(t0), N}(t0, one(t0)) + @btime jetcoeffs_taylordiff($rhs, $td, $x0, nothing) + + result = jetcoeffs_taylordiff(rhs, td, x0, nothing) + normalized = normalize_taylordiff_coeffs(result) + @assert x.coeffs ≈ normalized +end + +function array_test() + function lorenz(du, u, p, t) + du[1] = 10.0(u[2] - u[1]) + du[2] = u[1] * (28.0 - u[3]) - u[2] + du[3] = u[1] * u[2] - (8 / 3) * u[3] + return nothing + end + u0 = [1.0; 0.0; 0.0] + t0 = 0.0 + order = 6 + N = 7 + # TaylorIntegration test + t = t0 + Taylor1(typeof(t0), order) + u = [Taylor1(x, order) for x in u0] + du = similar(u) + uaux = similar(u) + @btime jetcoeffs!($lorenz, $t, $u, $du, $uaux, nothing) + + # TaylorDiff test + td = TaylorScalar{typeof(t0), N}(t0, one(t0)) + @btime jetcoeffs_array_taylordiff($lorenz, $td, $u0, nothing) + result = jetcoeffs_array_taylordiff(lorenz, td, u0, nothing) + normalized = normalize_taylordiff_coeffs.(result) + for i in eachindex(u) + @assert u[i].coeffs ≈ normalized[i] + end +end diff --git a/examples/ode.jl b/examples/ode.jl new file mode 100644 index 0000000..86ca42e --- /dev/null +++ b/examples/ode.jl @@ -0,0 +1,45 @@ +using ADTypes +using DifferentiationInterface +using ModelingToolkit, DifferentialEquations +using TaylorDiff, ForwardDiff +using Enzyme, Zygote, ReverseDiff +using SciMLSensitivity + +@parameters a +@variables t x1(t) +D = Differential(t) +states = [x1] +parameters = [a] + +@named pre_model = ODESystem([D(x1) ~ a * x1], t, states, parameters) +model = structural_simplify(pre_model) + +ic = Dict(x1 => 1.0) +p_true = Dict(a => 2.0) + +problem = ODEProblem{true, SciMLBase.FullSpecialize}(model, ic, [0.0, 1.0], p_true) +soln = ModelingToolkit.solve(problem, Tsit5(), abstol = 1e-12, reltol = 1e-12) +display(soln(0.5, idxs = [x1])) + +function different_time(new_ic, new_params, new_t) + #newprob = ODEProblem{true, SciMLBase.FullSpecialize}(model, new_ic, [0.0, new_t*2], new_params) + #newprob = remake(problem, u0=new_ic, tspan = [0.0, new_t], p = new_params) + newprob = remake(problem, u0 = new_ic, tspan = [0.0, new_t], p = new_params) + newprob = remake(newprob, u0 = typeof(new_t).(newprob.u0)) + new_soln = ModelingToolkit.solve(newprob, Tsit5(), abstol = 1e-12, reltol = 1e-12) + return (soln(new_t, idxs = [x1])) +end + +function just_t(new_t) + return different_time(ic, p_true, new_t)[1] +end +display(different_time(ic, p_true, 2e-5)) +display(just_t(0.5)) + +#display(ForwardDiff.derivative(just_t,1.0)) +display(TaylorDiff.derivative(just_t, 1.0, 1)) #isnan error +#display(value_and_gradient(just_t, AutoForwardDiff(), 1.0)) +#display(value_and_gradient(just_t, AutoReverseDiff(), 1.0)) +#display(value_and_gradient(just_t, AutoEnzyme(Enzyme.Reverse), 1.0)) +#display(value_and_gradient(just_t, AutoEnzyme(Enzyme.Forward), 1.0)) +#display(value_and_gradient(just_t, AutoZygote(), 1.0)) diff --git a/ext/TaylorDiffNNlibExt.jl b/ext/TaylorDiffNNlibExt.jl new file mode 100644 index 0000000..02e728e --- /dev/null +++ b/ext/TaylorDiffNNlibExt.jl @@ -0,0 +1,18 @@ +module TaylorDiffNNlibExt + +using TaylorDiff +import NNlib: oftf +import NNlib: sigmoid_fast, tanh_fast, rrelu, leakyrelu + +@inline sigmoid_fast(t::TaylorScalar) = one(t) / (one(t) + exp(-t)) + +@inline tanh_fast(t::TaylorScalar) = tanh(t) + +@inline function rrelu(t::TaylorScalar{T, N}, + l = oftf(t, 1 / 8), + u = oftf(t, 1 / 3)) where {T, N} + a = (u - l) * rand(float(T)) + l + return leakyrelu(t, a) +end + +end diff --git a/ext/TaylorDiffSFExt.jl b/ext/TaylorDiffSFExt.jl new file mode 100644 index 0000000..41a1d16 --- /dev/null +++ b/ext/TaylorDiffSFExt.jl @@ -0,0 +1,34 @@ +module TaylorDiffSFExt +using TaylorDiff, SpecialFunctions +using Symbolics: @variables +using SymbolicUtils, SymbolicUtils.Code +using SymbolicUtils: Pow +using TaylorDiff: value, raise +using ChainRules, ChainRulesCore + +dummy = (NoTangent(), 1) +@variables z +# logerfc, logerfcx, erfinv, gamma, digamma, trigamma +for func in (erf, erfc, erfcinv, erfcx, erfi) + F = typeof(func) + # base case + @eval function (op::$F)(t::TaylorScalar{T, 2}) where {T} + t0, t1 = value(t) + TaylorScalar{T, 2}(frule((NoTangent(), t1), op, t0)) + end + der = frule(dummy, func, z)[2] + term, raiser = der isa Pow && der.exp == -1 ? (der.base, raiseinv) : (der, raise) + # recursion by raising + @eval @generated function (op::$F)(t::TaylorScalar{T, N}) where {T, N} + der_expr = $(QuoteNode(toexpr(term))) + f = $func + quote + $(Expr(:meta, :inline)) + z = TaylorScalar{T, N - 1}(t) + df = $der_expr + $$raiser($f(value(t)[1]), df, t) + end + end +end + +end diff --git a/src/chainrules.jl b/src/chainrules.jl index 0784edb..fd327c6 100644 --- a/src/chainrules.jl +++ b/src/chainrules.jl @@ -6,7 +6,7 @@ function contract(a::TaylorScalar{T, N}, b::TaylorScalar{S, N}) where {T, S, N} mapreduce(*, +, value(a), value(b)) end -function rrule(::Type{TaylorScalar{T, N}}, v::NTuple{N, T}) where {N, T <: Number} +function rrule(::Type{TaylorScalar{T, N}}, v::NTuple{N, T}) where {N, T} taylor_scalar_pullback(t̄) = NoTangent(), value(t̄) return TaylorScalar(v), taylor_scalar_pullback end @@ -22,7 +22,7 @@ function rrule(::typeof(value), t::TaylorScalar{T, N}) where {N, T} end function rrule(::typeof(extract_derivative), t::TaylorScalar{T, N}, - i::Integer) where {N, T <: Number} + i::Integer) where {N, T} function extract_derivative_pullback(d̄) NoTangent(), TaylorScalar{T, N}(ntuple(j -> j === i ? d̄ : zero(T), Val(N))), NoTangent() @@ -30,26 +30,41 @@ function rrule(::typeof(extract_derivative), t::TaylorScalar{T, N}, return extract_derivative(t, i), extract_derivative_pullback end -function rrule(::typeof(*), A::Matrix{S}, - t::Vector{TaylorScalar{T, N}}) where {N, S <: Number, T} +function rrule(::typeof(*), A::AbstractMatrix{S}, + t::AbstractVector{TaylorScalar{T, N}}) where {N, S, T} project_A = ProjectTo(A) function gemv_pullback(x̄) - NoTangent(), @thunk(project_A(contract.(x̄, transpose(t)))), @thunk(transpose(A)*x̄) + x̂ = reinterpret(reshape, T, x̄) + t̂ = reinterpret(reshape, T, t) + NoTangent(), @thunk(project_A(transpose(x̂) * t̂)), @thunk(transpose(A)*x̄) end return A * t, gemv_pullback end -@adjoint function +(t::Vector{TaylorScalar{T, N}}, v::Vector{T}) where {N, T <: Number} +function rrule(::typeof(*), A::AbstractMatrix{S}, + B::AbstractMatrix{TaylorScalar{T, N}}) where {N, S, T} + project_A = ProjectTo(A) + project_B = ProjectTo(B) + function gemm_pullback(x̄) + X̄ = unthunk(x̄) + NoTangent(), + @thunk(project_A(X̄ * transpose(B))), + @thunk(project_B(transpose(A) * X̄)) + end + return A * B, gemm_pullback +end + +@adjoint function +(t::Vector{TaylorScalar{T, N}}, v::Vector{T}) where {N, T} project_v = ProjectTo(v) t + v, x̄ -> (x̄, project_v(x̄)) end -@adjoint function +(v::Vector{T}, t::Vector{TaylorScalar{T, N}}) where {N, T <: Number} +@adjoint function +(v::Vector{T}, t::Vector{TaylorScalar{T, N}}) where {N, T} project_v = ProjectTo(v) v + t, x̄ -> (project_v(x̄), x̄) end -(project::ProjectTo{T})(dx::TaylorScalar{T, N}) where {N, T <: Number} = primal(dx) +(project::ProjectTo{T})(dx::TaylorScalar{T, N}) where {N, T} = primal(dx) # Not-a-number patches @@ -63,7 +78,7 @@ accum_sum(xs::AbstractArray{T}; dims = :) where {T <: TaylorScalar} = sum(xs, di TaylorNumeric{T <: TaylorScalar} = Union{T, AbstractArray{<:T}} -@adjoint function broadcasted(::typeof(+), xs::Union{Numeric, TaylorNumeric}...) +@adjoint function broadcasted(::typeof(+), xs::TaylorNumeric...) broadcast(+, xs...), ȳ -> (nothing, map(x -> unbroadcast(x, ȳ), xs)...) end @@ -72,8 +87,8 @@ struct TaylorOneElement{T, N, I, A} <: AbstractArray{T, N} ind::I axes::A function TaylorOneElement(val::T, ind::I, - axes::A) where {T <: TaylorScalar, I <: NTuple{N, Int}, - A <: NTuple{N, AbstractUnitRange}} where {N} + axes::A) where {T <: TaylorScalar, I <: NTuple{N, Int}, + A <: NTuple{N, AbstractUnitRange}} where {N} new{T, N, I, A}(val, ind, axes) end end @@ -106,13 +121,13 @@ function rrule(::typeof(*), x::TaylorScalar, y::TaylorScalar) function times_pullback2(Ω̇) ΔΩ = unthunk(Ω̇) return (NoTangent(), ProjectTo(x)(mul_adjoint(ΔΩ, y)), - ProjectTo(y)(mul_adjoint(ΔΩ, x))) + ProjectTo(y)(mul_adjoint(ΔΩ, x))) end return x * y, times_pullback2 end function rrule(::typeof(*), x::TaylorScalar, y::TaylorScalar, z::TaylorScalar, - more::TaylorScalar...) + more::TaylorScalar...) Ω2, back2 = rrule(*, x, y) Ω3, back3 = rrule(*, Ω2, z) Ω4, back4 = rrule(*, Ω3, more...) diff --git a/src/codegen.jl b/src/codegen.jl index 5cee5ff..8c61711 100644 --- a/src/codegen.jl +++ b/src/codegen.jl @@ -1,45 +1,29 @@ +using ChainRules using ChainRulesCore +using Symbolics: @variables using SymbolicUtils, SymbolicUtils.Code -using SymbolicUtils: BasicSymbolic, Pow +using SymbolicUtils: Pow -@scalar_rule +(x::BasicSymbolic) true -@scalar_rule -(x::BasicSymbolic) -1 -@scalar_rule deg2rad(x::BasicSymbolic) deg2rad(one(x)) -@scalar_rule rad2deg(x::BasicSymbolic) rad2deg(one(x)) -@scalar_rule asin(x::BasicSymbolic) inv(sqrt(1 - x^2)) -@scalar_rule acos(x::BasicSymbolic) inv(-sqrt(1 - x^2)) -@scalar_rule atan(x::BasicSymbolic) inv(-(1 + x^2)) -@scalar_rule acot(x::BasicSymbolic) inv(-(1 + x^2)) -@scalar_rule acsc(x::BasicSymbolic) inv(x^2 * -sqrt(1 - x^-2)) -@scalar_rule asec(x::BasicSymbolic) inv(x^2 * sqrt(1 - x^-2)) -@scalar_rule log(x::BasicSymbolic) inv(x) -@scalar_rule log10(x::BasicSymbolic) inv(log(10.0) * x) -@scalar_rule log1p(x::BasicSymbolic) inv(x + 1) -@scalar_rule log2(x::BasicSymbolic) inv(log(2.0) * x) -@scalar_rule sinh(x::BasicSymbolic) cosh(x) -@scalar_rule cosh(x::BasicSymbolic) sinh(x) -@scalar_rule tanh(x::BasicSymbolic) 1-Ω^2 -@scalar_rule acosh(x::BasicSymbolic) inv(sqrt(x - 1) * sqrt(x + 1)) -@scalar_rule acoth(x::BasicSymbolic) inv(1 - x^2) -@scalar_rule acsch(x::BasicSymbolic) inv(x^2 * -sqrt(1 + x^-2)) -@scalar_rule asech(x::BasicSymbolic) inv(x * -sqrt(1 - x^2)) -@scalar_rule asinh(x::BasicSymbolic) inv(sqrt(x^2 + 1)) -@scalar_rule atanh(x::BasicSymbolic) inv(1 - x^2) +func_list = ( + +, -, deg2rad, rad2deg, + sinh, cosh, tanh, + asin, acos, atan, asec, acsc, acot, + log, log10, log1p, log2, + asinh, acosh, atanh, asech, acsch, + acoth, + abs, sign) dummy = (NoTangent(), 1) -@syms t₁ -for func in (+, -, deg2rad, rad2deg, - sinh, cosh, tanh, - asin, acos, atan, asec, acsc, acot, - log, log10, log1p, log2, - asinh, acosh, atanh, asech, acsch, acoth) +@variables z +for func in func_list F = typeof(func) # base case @eval function (op::$F)(t::TaylorScalar{T, 2}) where {T} t0, t1 = value(t) - TaylorScalar{T, 2}(frule((NoTangent(), t1), op, t0)) + f0, f1 = frule((NoTangent(), t1), op, t0) + TaylorScalar{T, 2}(f0, zero_tangent(f0) + f1) end - der = frule(dummy, func, t₁)[2] + der = frule(dummy, func, z)[2] term, raiser = der isa Pow && der.exp == -1 ? (der.base, raiseinv) : (der, raise) # recursion by raising @eval @generated function (op::$F)(t::TaylorScalar{T, N}) where {T, N} @@ -47,9 +31,10 @@ for func in (+, -, deg2rad, rad2deg, f = $func quote $(Expr(:meta, :inline)) - t₁ = TaylorScalar{T, N - 1}(t) - df = $der_expr - $$raiser($f(value(t)[1]), df, t) + z = TaylorScalar{T, N - 1}(t) + f0 = $f(value(t)[1]) + df = zero_tangent(z) + $der_expr + $$raiser(f0, df, t) end end end diff --git a/src/derivative.jl b/src/derivative.jl index b035ee8..9b49b09 100644 --- a/src/derivative.jl +++ b/src/derivative.jl @@ -1,38 +1,74 @@ -export derivative +export derivative, derivative!, derivatives, make_seed """ - derivative(f, x::T, order::Int64) - derivative(f, x::T, ::Val{N}) + derivative(f, x, l, ::Val{N}) + derivative(f!, y, x, l, ::Val{N}) -Computes `order`-th derivative of `f` w.r.t. `x`. +Computes `order`-th directional derivative of `f` w.r.t. vector `x` in direction `l`. +""" +function derivative end - derivative(f, x::Vector{T}, l::Vector{T}, order::Int64) - derivative(f, x::Vector{T}, l::Vector{T}, ::Val{N}) +""" + derivative!(result, f, x, l, ::Val{N}) + derivative!(result, f!, y, x, l, ::Val{N}) -Computes `order`-th directional derivative of `f` w.r.t. `x` in direction `l`. +In-place derivative calculation APIs. `result` is expected to be pre-allocated and have the same shape as `y`. """ -function derivative end +function derivative! end -@inline function derivative(f, x::T, order::Int64) where {T <: Number} - derivative(f, x, Val{order + 1}()) -end +""" + derivatives(f, x, l, ::Val{N}) + derivatives(f!, y, x, l, ::Val{N}) + +Computes all derivatives of `f` at `x` up to order `N - 1`. +""" +function derivatives end -@inline function derivative(f, x::Vector{T}, l::Vector{T}, - order::Int64) where {T <: Number} - derivative(f, x, l, Val{order + 1}()) +# Convenience wrapper for adding unit seed to the input + +@inline derivative(f, x, order::Int64) = derivative(f, x, one(eltype(x)), order) + +# Convenience wrappers for converting orders to value types +# and forward work to core APIs + +@inline derivative(f, x, l, order::Int64) = derivative(f, x, l, Val{order + 1}()) +@inline derivative(f!, y, x, l, order::Int64) = derivative(f!, y, x, l, Val{order + 1}()) +@inline derivative!(result, f, x, l, order::Int64) = derivative!( + result, f, x, l, Val{order + 1}()) +@inline derivative!(result, f!, y, x, l, order::Int64) = derivative!( + result, f!, y, x, l, Val{order + 1}()) + +# Core APIs + +# Added to help Zygote infer types +@inline function make_seed(x::T, l::S, ::Val{N}) where {T <: Real, S <: Real, N} + TaylorScalar{T, N}(x, convert(T, l)) end -@inline function derivative(f, x::T, ::Val{N}) where {T <: Number, N} - t = TaylorScalar{T, N}(x, one(x)) - return extract_derivative(f(t), N) +@inline function make_seed(x::AbstractArray{T}, l, vN::Val{N}) where {T <: Real, N} + broadcast(make_seed, x, l, vN) end -# Need to rewrite like this to help Zygote infer types -make_taylor(t0::T, t1::T, ::Val{N}) where {T, N} = TaylorScalar{T, N}(t0, t1) +# `derivative` API: computes the `N - 1`-th derivative of `f` at `x` +@inline derivative(f, x, l, vN::Val{N}) where {N} = extract_derivative( + derivatives(f, x, l, vN), N) +@inline derivative(f!, y, x, l, vN::Val{N}) where {N} = extract_derivative( + derivatives(f!, y, x, l, vN), N) +@inline derivative!(result, f, x, l, vN::Val{N}) where {N} = extract_derivative!( + result, derivatives(f, x, l, vN), N) +@inline derivative!(result, f!, y, x, l, vN::Val{N}) where {N} = extract_derivative!( + result, derivatives(f!, y, x, l, vN), N) + +# `derivatives` API: computes all derivatives of `f` at `x` up to order `N - 1` + +# Out-of-place function +@inline derivatives(f, x, l, vN::Val{N}) where {N} = f(make_seed(x, l, vN)) -@inline function derivative(f, x::Vector{T}, l::Vector{T}, - vN::Val{N}) where {T <: Number, N} - t = map((t0, t1) -> make_taylor(t0, t1, vN), x, l) # i.e. map(TaylorScalar{T, N}, x, l) - return extract_derivative(f(t), N) +# In-place function +@inline function derivatives(f!, y::AbstractArray{T}, x, l, vN::Val{N}) where {T, N} + buffer = similar(y, TaylorScalar{T, N}) + f!(buffer, make_seed(x, l, vN)) + map!(primal, y, buffer) + return buffer end diff --git a/src/primitive.jl b/src/primitive.jl index da8b3eb..17b94a4 100644 --- a/src/primitive.jl +++ b/src/primitive.jl @@ -1,6 +1,6 @@ import Base: abs, abs2 import Base: exp, exp2, exp10, expm1, log, log2, log10, log1p, inv, sqrt, cbrt -import Base: sin, cos, tan, cot, sec, csc, sinh, cosh, tanh, coth, sech, csch +import Base: sin, cos, tan, cot, sec, csc, sinh, cosh, tanh, coth, sech, csch, sinpi, cospi import Base: asin, acos, atan, acot, asec, acsc, asinh, acosh, atanh, acoth, asech, acsch import Base: sinc, cosc import Base: +, -, *, /, \, ^, >, <, >=, <=, == @@ -62,13 +62,13 @@ for func in (:sin, :cos) end for i in 2:N ex = :($ex; - $(Symbol('s', i)) = +($([:($(binomial(i - 2, j - 1)) * - $(Symbol('c', j)) * - v[$(i + 1 - j)]) for j in 1:(i - 1)]...))) + $(Symbol('s', i)) = +($([:($(binomial(i - 2, j - 1)) * + $(Symbol('c', j)) * + v[$(i + 1 - j)]) for j in 1:(i - 1)]...))) ex = :($ex; - $(Symbol('c', i)) = +($([:($(-binomial(i - 2, j - 1)) * - $(Symbol('s', j)) * - v[$(i + 1 - j)]) for j in 1:(i - 1)]...))) + $(Symbol('c', i)) = +($([:($(-binomial(i - 2, j - 1)) * + $(Symbol('s', j)) * + v[$(i + 1 - j)]) for j in 1:(i - 1)]...))) end if $(QuoteNode(func)) == :sin ex = :($ex; TaylorScalar($([Symbol('s', i) for i in 1:N]...))) @@ -81,21 +81,18 @@ for func in (:sin, :cos) end end -# Binary +@inline sinpi(t::TaylorScalar) = sin(π * t) +@inline cospi(t::TaylorScalar) = cos(π * t) -@inline +(a::Number, b::TaylorScalar) = TaylorScalar((a + value(b)[1]), tail(value(b))...) -@inline -(a::Number, b::TaylorScalar) = TaylorScalar((a - value(b)[1]), .-tail(value(b))...) -@inline *(a::Number, b::TaylorScalar) = TaylorScalar((a .* value(b))...) -@inline /(a::Number, b::TaylorScalar) = /(promote(a, b)...) +# Binary -@inline +(a::TaylorScalar, b::Number) = TaylorScalar((value(a)[1] + b), tail(value(a))...) -@inline -(a::TaylorScalar, b::Number) = TaylorScalar((value(a)[1] - b), tail(value(a))...) -@inline *(a::TaylorScalar, b::Number) = TaylorScalar((value(a) .* b)...) -@inline /(a::TaylorScalar, b::Number) = TaylorScalar((value(a) ./ b)...) +const AMBIGUOUS_TYPES = (AbstractFloat, Irrational, Integer, Rational, Real, RoundingMode) for op in [:>, :<, :(==), :(>=), :(<=)] - @eval @inline $op(a::Number, b::TaylorScalar) = $op(a, value(b)[1]) - @eval @inline $op(a::TaylorScalar, b::Number) = $op(value(a)[1], b) + for R in AMBIGUOUS_TYPES + @eval @inline $op(a::TaylorScalar, b::$R) = $op(value(a)[1], b) + @eval @inline $op(a::$R, b::TaylorScalar) = $op(a, value(b)[1]) + end @eval @inline $op(a::TaylorScalar, b::TaylorScalar) = $op(value(a)[1], value(b)[1]) end @@ -135,59 +132,66 @@ end *(promote(a, b)...) end -@generated function ^(t::TaylorScalar{T, N}, n::S) where {S <: Number, T, N} - ex = quote - v = value(t) - v1 = ^(v[1], n) - end - for i in 2:N +for R in (Integer, Real) + @eval @generated function ^(t::TaylorScalar{T, N}, n::S) where {S <: $R, T, N} ex = quote - $ex - $(Symbol('v', i)) = +($([:((n * $(binomial(i - 2, j - 1)) - - $(binomial(i - 2, j - 2))) * $(Symbol('v', j)) * - v[$(i + 1 - j)]) - for j in 1:(i - 1)]...)) / v[1] + v = value(t) + w11 = 1 + u1 = ^(v[1], n) end - end - ex = :($ex; TaylorScalar($([Symbol('v', i) for i in 1:N]...))) - return :(@inbounds $ex) -end - -@generated function ^(t::TaylorScalar{T, N}, n::S) where {S <: Integer, T, N} - # TODO: optimize for small powers - ex = quote - v = value(t) - v1 = ^(v[1], n) - end - for i in 2:N - ex = quote - $ex - $(Symbol('v', i)) = +($([:((n * $(binomial(i - 2, j - 1)) - - $(binomial(i - 2, j - 2))) * $(Symbol('v', j)) * - v[$(i + 1 - j)]) - for j in 1:(i - 1)]...)) / v[1] + for k in 1:N + ex = quote + $ex + $(Symbol('p', k)) = ^(v[1], n - $(k - 1)) + end + end + for i in 2:N + subex = quote + $(Symbol('w', i, 1)) = 0 + end + for k in 2:i + subex = quote + $subex + $(Symbol('w', i, k)) = +($([:((n * $(binomial(i - 2, j - 1)) - + $(binomial(i - 2, j - 2))) * + $(Symbol('w', j, k - 1)) * + v[$(i + 1 - j)]) + for j in (k - 1):(i - 1)]...)) + end + end + ex = quote + $ex + $subex + $(Symbol('u', i)) = +($([:($(Symbol('w', i, k)) * $(Symbol('p', k))) + for k in 2:i]...)) + end end + ex = :($ex; TaylorScalar($([Symbol('u', i) for i in 1:N]...))) + return :(@inbounds $ex) + end + @eval function ^(a::S, t::TaylorScalar{T, N}) where {S <: $R, T, N} + exp(t * log(a)) end - ex = :($ex; TaylorScalar($([Symbol('v', i) for i in 1:N]...))) - return :(@inbounds $ex) end +^(t::TaylorScalar, s::TaylorScalar) = exp(s * log(t)) + @generated function raise(f::T, df::TaylorScalar{T, M}, - t::TaylorScalar{T, N}) where {T, M, N} # M + 1 == N + t::TaylorScalar{T, N}) where {T, M, N} # M + 1 == N return quote $(Expr(:meta, :inline)) vdf, vt = value(df), value(t) @inbounds TaylorScalar(f, - $([:(+($([:($(binomial(i - 1, j - 1)) * vdf[$j] * - vt[$(i + 2 - j)]) for j in 1:i]...))) - for i in 1:M]...)) + $([:(+($([:($(binomial(i - 1, j - 1)) * vdf[$j] * + vt[$(i + 2 - j)]) for j in 1:i]...))) + for i in 1:M]...)) end end raise(::T, df::S, t::TaylorScalar{T, N}) where {S <: Number, T, N} = df * t @generated function raiseinv(f::T, df::TaylorScalar{T, M}, - t::TaylorScalar{T, N}) where {T, M, N} # M + 1 == N + t::TaylorScalar{T, N}) where {T, M, N} # M + 1 == N ex = quote vdf, vt = value(df), value(t) v1 = vt[2] / vdf[1] diff --git a/src/scalar.jl b/src/scalar.jl index 701bf75..8f3814b 100644 --- a/src/scalar.jl +++ b/src/scalar.jl @@ -2,6 +2,20 @@ import Base: convert, promote_rule export TaylorScalar +""" + TaylorDiff.can_taylor(V::Type) + +Determines whether the type V is allowed as the scalar type in a +Dual. By default, only `<:Real` types are allowed. +""" +can_taylorize(::Type{<:Real}) = true +can_taylorize(::Type) = false + +@noinline function throw_cannot_taylorize(V::Type) + throw(ArgumentError("Cannot create a Taylor polynomial over scalar type $V." * + " If the type behaves as a scalar, define TaylorDiff.can_taylorize(::Type{$V}) = true.")) +end + """ TaylorScalar{T, N} @@ -11,20 +25,23 @@ Representation of Taylor polynomials. - `value::NTuple{N, T}`: i-th element of this stores the (i-1)-th derivative """ -struct TaylorScalar{T, N} +struct TaylorScalar{T, N} <: Real value::NTuple{N, T} + function TaylorScalar{T, N}(value::NTuple{N, T}) where {T, N} + can_taylorize(T) || throw_cannot_taylorize(T) + new{T, N}(value) + end end -TaylorOrNumber = Union{TaylorScalar, Number} - -@inline TaylorScalar(xs::Vararg{T, N}) where {T, N} = TaylorScalar(xs) +TaylorScalar(value::NTuple{N, T}) where {T, N} = TaylorScalar{T, N}(value) +TaylorScalar(value::Vararg{T, N}) where {T, N} = TaylorScalar{T, N}(value) """ TaylorScalar{T, N}(x::T) where {T, N} Construct a Taylor polynomial with zeroth order coefficient. """ -@generated function TaylorScalar{T, N}(x::T) where {T, N} +@generated function TaylorScalar{T, N}(x::S) where {T, S <: Real, N} return quote $(Expr(:meta, :inline)) TaylorScalar((T(x), $(zeros(T, N - 1)...))) @@ -36,7 +53,7 @@ end Construct a Taylor polynomial with zeroth and first order coefficient, acting as a seed. """ -@generated function TaylorScalar{T, N}(x::T, d::T) where {T, N} +@generated function TaylorScalar{T, N}(x::S, d::S) where {T, S <: Real, N} return quote $(Expr(:meta, :inline)) TaylorScalar((T(x), T(d), $(zeros(T, N - 2)...))) @@ -55,11 +72,19 @@ end @inline value(t::TaylorScalar) = t.value @inline extract_derivative(t::TaylorScalar, i::Integer) = t.value[i] +@inline function extract_derivative(v::AbstractArray{T}, + i::Integer) where {T <: TaylorScalar} + map(t -> extract_derivative(t, i), v) +end @inline extract_derivative(r, i::Integer) = false +@inline function extract_derivative!(result::AbstractArray, v::AbstractArray{T}, + i::Integer) where {T <: TaylorScalar} + map!(t -> extract_derivative(t, i), result, v) +end @inline primal(t::TaylorScalar) = extract_derivative(t, 1) function promote_rule(::Type{TaylorScalar{T, N}}, - ::Type{S}) where {T, S, N} + ::Type{S}) where {T, S, N} TaylorScalar{promote_type(T, S), N} end function promote_rule(::Type{TaylorScalar{T1, N}}, @@ -67,12 +92,21 @@ function promote_rule(::Type{TaylorScalar{T1, N}}, TaylorScalar{promote_type(T1, T2), N} end -# Number-like convention (I patched them after removing <: Number) +function (::Type{F})(x::TaylorScalar{T, N}) where {T, N, F <: AbstractFloat} + F(primal(x)) +end -convert(::Type{TaylorScalar{T, N}}, x::TaylorScalar{T, N}) where {T, N} = x -function convert(::Type{TaylorScalar{T, N}}, x::S) where {T, S, N} - TaylorScalar{T, N}(convert(T, x)) +function Base.nextfloat(x::TaylorScalar{T, N}) where {T, N} + TaylorScalar{T, N}(ntuple(i -> i == 1 ? nextfloat(value(x)[i]) : value(x)[i], N)) end -function convert(::Type{TaylorScalar{T1, N}}, x::TaylorScalar{T2, N}) where {T1, T2, N} - TaylorScalar{T1, N}(convert.(T1, value(x))) + +function Base.prevfloat(x::TaylorScalar{T, N}) where {T, N} + TaylorScalar{T, N}(ntuple(i -> i == 1 ? prevfloat(value(x)[i]) : value(x)[i], N)) +end + +const UNARY_PREDICATES = Symbol[ + :isinf, :isnan, :isfinite, :iseven, :isodd, :isreal, :isinteger] + +for pred in UNARY_PREDICATES + @eval Base.$(pred)(x::TaylorScalar) = $(pred)(primal(x)) end diff --git a/test/Project.toml b/test/Project.toml index 0accb85..72bbeb9 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -2,3 +2,4 @@ FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/test/derivative.jl b/test/derivative.jl new file mode 100644 index 0000000..80d8434 --- /dev/null +++ b/test/derivative.jl @@ -0,0 +1,39 @@ + +@testset "O-function, O-derivative" begin + g(x) = x^3 + @test derivative(g, 1.0, 1) ≈ 3 + + h(x) = x .^ 3 + @test derivative(h, [2.0 3.0], 1) ≈ [12.0 27.0] + + g1(x) = x[1] * x[1] + x[2] * x[2] + @test derivative(g1, [1.0, 2.0], [1.0, 0.0], 1) ≈ 2.0 + + h1(x) = sum(x, dims = 1) + @test derivative(h1, [1.0 2.0; 2.0 3.0], [1.0, 1.0], 1) ≈ [2.0 2.0] +end + +@testset "I-function, O-derivative" begin + g!(y, x) = begin + y[1] = x * x + y[2] = x + 1 + end + x = 2.0 + y = [0.0, 0.0] + @test derivative(g!, y, x, 1.0, Val{2}()) ≈ [4.0, 1.0] +end + +@testset "O-function, I-derivative" begin + g(x) = x .^ 2 + @test derivative!(zeros(2), g, [1.0, 2.0], [1.0, 0.0], Val{2}()) ≈ [2.0, 0.0] +end + +@testset "I-function, I-derivative" begin + g!(y, x) = begin + y[1] = x[1] * x[1] + y[2] = x[2] * x[2] + end + x = [2.0, 3.0] + y = [0.0, 0.0] + @test derivative!(y, g!, zeros(2), x, [1.0, 0.0], Val{2}()) ≈ [4.0, 0.0] +end diff --git a/test/primitive.jl b/test/primitive.jl index 6b6d1c4..4cd6bb7 100644 --- a/test/primitive.jl +++ b/test/primitive.jl @@ -2,7 +2,7 @@ using FiniteDifferences @testset "No derivative or linear" begin some_number, another_number = 1.9, 2.6 - for f in (+, -, zero, one, adjoint, conj, deg2rad, rad2deg), order in (2,) + for f in (+, -, zero, one, adjoint, conj, deg2rad, rad2deg, abs, sign), order in (2,) @test derivative(f, some_number, order) ≈ 0.0 end for f in (+, -, <, <=, >, >=, ==), order in (2,) @@ -14,8 +14,10 @@ end @testset "Unary functions" begin some_number = 3.7 - for f in (x -> exp(x^2), expm1, exp2, exp10, x -> sin(x^2), x -> cos(x^2), sqrt, cbrt, - inv), order in (1, 4) + for f in ( + x -> exp(x^2), expm1, exp2, exp10, x -> sin(x^2), x -> cos(x^2), sinpi, cospi, + sqrt, cbrt, + inv), order in (1, 4) fdm = central_fdm(12, order) @test derivative(f, some_number, order)≈fdm(f, some_number) rtol=1e-6 end @@ -30,14 +32,18 @@ end end @testset "Binary functions" begin - some_number, another_number = 1.9, 2.6 + some_number, another_number = 1.9, 5.6 for f in (*, /), order in (1, 4) fdm = central_fdm(12, order) closure = x -> exp(f(x, another_number)) @test derivative(closure, some_number, order)≈fdm(closure, some_number) rtol=1e-6 end - for f in (x -> x^7, x -> x^another_number), order in (2, 4) + for f in (x -> x^7, x -> x^another_number), order in (1, 2, 4) fdm = central_fdm(12, order) @test derivative(f, some_number, order)≈fdm(f, some_number) rtol=1e-6 end + for f in (x -> x^7, x -> x^another_number), order in (1, 2) + fdm = forward_fdm(12, order) + @test derivative(f, 0, order)≈fdm(f, 0) atol=1e-6 + end end diff --git a/test/runtests.jl b/test/runtests.jl index 1ef7378..23ec468 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,8 +1,7 @@ using TaylorDiff using Test -include("scalar.jl") -include("vector.jl") include("primitive.jl") -include("zygote.jl") +include("derivative.jl") +# include("zygote.jl") # include("lux.jl") diff --git a/test/scalar.jl b/test/scalar.jl deleted file mode 100644 index fea2470..0000000 --- a/test/scalar.jl +++ /dev/null @@ -1 +0,0 @@ -@testset "Scalar" begin end diff --git a/test/vector.jl b/test/vector.jl deleted file mode 100644 index 801f38b..0000000 --- a/test/vector.jl +++ /dev/null @@ -1,5 +0,0 @@ - -@testset "Vector" begin - g(x) = x[1] * x[1] + x[2] * x[2] - @test derivative(g, [1.0, 2.0], [1.0, 0.0], 1) ≈ 2.0 -end diff --git a/test/zygote.jl b/test/zygote.jl index 8cea667..1ef667f 100644 --- a/test/zygote.jl +++ b/test/zygote.jl @@ -1,16 +1,33 @@ -using Zygote +using Zygote, LinearAlgebra @testset "Zygote for mixed derivative" begin some_number = 0.7 + some_numbers = [0.3 0.4 0.1;] for f in (exp, log, sqrt, sin, asin, sinh, asinh) @test gradient(x -> derivative(f, x, 2), some_number)[1] ≈ derivative(f, some_number, 3) + derivative_result = vec(derivative.(f, some_numbers, 3)) + @test Zygote.jacobian(x -> derivative.(f, x, 2), some_numbers)[1] ≈ + diagm(derivative_result) end + + some_matrix = [0.7 0.1; 0.4 0.2] + f = x -> sum(tanh.(x), dims = 1) + dfdx1(m, x) = derivative(m, x, [1.0, 0.0], 1) + dfdx2(m, x) = derivative(m, x, [0.0, 1.0], 1) + res(m, x) = dfdx1(m, x) .+ 2 * dfdx2(m, x) + grads = Zygote.gradient(some_matrix) do x + sum(res(f, x)) + end + expected_grads = x -> -2 * sinh(x) / cosh(x)^3 + @test grads[1] ≈ [1 0; 0 2] * expected_grads.(some_matrix) + @test gradient(x -> derivative(x -> x * x, x, 1), - 5.0)[1] ≈ 2.0 + 5.0)[1] ≈ 2.0 g(x) = x[1] * x[1] + x[2] * x[2] - @test gradient(x -> derivative(g, x, [1.0, 0.0], 1), [1.0, 2.0])[1] ≈ [2.0, 0.0] + @test gradient(x -> derivative(g, x, [1.0, 0.0], 1), + [1.0, 2.0])[1] ≈ [2.0, 0.0] end @testset "Zygote for parameter optimization" begin