Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.2.0 #11

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name = "FMISensitivity"
uuid = "3e748fe5-cd7f-4615-8419-3159287187d2"
authors = ["TT <[email protected]>", "LM <[email protected]>"]
version = "0.1.4"
version = "0.2.0"

[deps]
FMICore = "8af89139-c281-408e-bce2-3005eb87462f"
FMIBase = "900ee838-d029-460e-b485-d98a826ceef2"
ForwardDiffChainRules = "c9556dd2-1aed-4cfe-8560-1557cf593001"
SciMLSensitivity = "1ed8b502-d754-442c-8d5d-10ac956f44a1"

[compat]
FMICore = "0.20.0"
FMIBase = "1.0.0"
ForwardDiffChainRules = "0.2.0"
SciMLSensitivity = "6.51.2 - 7.51"
SciMLSensitivity = "7.0 - 7.59"
julia = "1.6"
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ To keep dependencies nice and clean, the original package [*FMI.jl*](https://git
- [*FMI.jl*](https://github.com/ThummeTo/FMI.jl): High level loading, manipulating, saving or building entire FMUs from scratch
- [*FMIImport.jl*](https://github.com/ThummeTo/FMIImport.jl): Importing FMUs into Julia
- [*FMIExport.jl*](https://github.com/ThummeTo/FMIExport.jl): Exporting stand-alone FMUs from Julia Code
- [*FMIBase.jl*](https://github.com/ThummeTo/FMIBase.jl): Common concepts for import and export of FMUs
- [*FMICore.jl*](https://github.com/ThummeTo/FMICore.jl): C-code wrapper for the FMI-standard
- [*FMISensitivity.jl*](https://github.com/ThummeTo/FMISensitivity.jl): Static and dynamic sensitivities over FMUs
- [*FMIBuild.jl*](https://github.com/ThummeTo/FMIBuild.jl): Compiler/Compilation dependencies for FMIExport.jl
- [*FMIFlux.jl*](https://github.com/ThummeTo/FMIFlux.jl): Machine Learning with FMUs (differentiation over FMUs)
- [*FMIFlux.jl*](https://github.com/ThummeTo/FMIFlux.jl): Machine Learning with FMUs
- [*FMIZoo.jl*](https://github.com/ThummeTo/FMIZoo.jl): A collection of testing and example FMUs

## What Platforms are supported?
Expand Down
41 changes: 12 additions & 29 deletions src/FMISensitivity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,23 @@ import SciMLSensitivity: ForwardDiff
import SciMLSensitivity: FiniteDiff
import SciMLSensitivity: ReverseDiff
import SciMLSensitivity: Zygote
import FMICore.ChainRulesCore

import FMIBase.ChainRulesCore
using FMIBase.ChainRulesCore: ZeroTangent, NoTangent, @thunk

import ForwardDiffChainRules
import ForwardDiffChainRules: @ForwardDiff_frule
import SciMLSensitivity.ReverseDiff: @grad_from_chainrules
import FMICore.ChainRulesCore: ZeroTangent, NoTangent, @thunk
using FMICore: undual, unsense, untrack
using ForwardDiffChainRules: @ForwardDiff_frule
using SciMLSensitivity.ReverseDiff: @grad_from_chainrules

using SciMLSensitivity.LinearAlgebra
import SciMLSensitivity.SparseDiffTools

import FMICore: invalidate!, check_invalidate!

using FMICore

function isZeroTangent(d)
return false
end
function isZeroTangent(d::ZeroTangent)
return true
end
function isZeroTangent(d::AbstractArray{<:ZeroTangent})
return true
end

# additional dispatch for ReverseDiff.jl
# import SciMLSensitivity.ReverseDiff: increment_deriv!, ZeroTangent
# function ReverseDiff.increment_deriv!(::ReverseDiff.TrackedReal, ::ZeroTangent)
# return nothing
# end
# function ReverseDiff.increment_deriv!(::ReverseDiff.TrackedArray, ::ZeroTangent, ::Int64)
# return nothing
# end

include("FMI2.jl")
using FMIBase
using FMIBase.FMICore
using FMIBase: undual, unsense, untrack

include("utils.jl")
include("sense.jl")
include("hotfixes.jl")

end # module
12 changes: 12 additions & 0 deletions src/hotfixes.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# Copyright (c) 2023 Tobias Thummerer, Lars Mikelsons
# Licensed under the MIT license. See LICENSE file in the project root for details.
#

import SciMLSensitivity.Zygote: grad_mut, Context
import FMIBase: FMUEvaluationOutput
#grad_mut(av::AbstractVector) = invoke(grad_mut, Tuple{Any}, av)
grad_mut(av::FMUEvaluationOutput) = invoke(grad_mut, Tuple{Any}, av)
#grad_mut(c::Zygote.Context, av::AbstractVector) = invoke(grad_mut, Tuple{Zygote.Context, Any}, c, av)
grad_mut(c::Zygote.Context, av::FMUEvaluationOutput) = invoke(grad_mut, Tuple{Zygote.Context, Any}, c, av)
#grad_mut(av::AbstractVector) = []
Loading
Loading