Skip to content
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
10 changes: 2 additions & 8 deletions .github/workflows/IntegrationTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@ jobs:
julia-version: [1.5]
os: [ubuntu-latest]
package:
- {user: JuliaDiff, repo: ChainRules.jl}
- {user: JuliaMath, repo: SpecialFunctions.jl}
- {user: invenia, repo: BlockDiagonals.jl}
- {user: invenia, repo: PDMatsExtras.jl}
- {user: chrisbrahms, repo: Hankel.jl}
- {user: SciML, repo: DiffEqBase.jl}
- {user: dfdx, repo: Yota.jl}
# - {user: Invenia, repo: Nabla.jl}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why commented out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't actually depend on this yet, so it is pointless to test it?
But I wanted it in there so that the I would relember that this line needs to have user and repo fields


steps:
- uses: actions/checkout@v2
Expand All @@ -43,7 +37,7 @@ jobs:
# force it to use this PR's version of the package
Pkg.develop(PackageSpec(path=".")) # resolver may fail with main deps
Pkg.update()
Pkg.test() # resolver may fail with test time deps
Pkg.test() # resolver may fail with test time deps
catch err
err isa Pkg.Resolve.ResolverError || rethrow()
# If we can't resolve that means this is incompatible by SemVer and this is fine
Expand Down
4 changes: 2 additions & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The ChainRulesCore.jl package is licensed under the MIT "Expat" License:
The ChainRulesOverloadGeneration.jl package is licensed under the MIT "Expat" License:

> Copyright (c) 2018-2019: Jarrett Revels, and other JuliaDiff Contributors:
> https://github.com/JuliaDiff/ChainRulesCore.jl/contributors
> https://github.com/JuliaDiff/ChainRulesOverloadGeneration.jl/contributors
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
Expand Down
15 changes: 15 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name = "ChainRulesOverloadGeneration"
uuid = "f51149dc-2911-5acf-81fc-2076a2a81d4f"
version = "0.1.0"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"

[compat]
ChainRulesCore = "0.9"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
<img src="https://rawcdn.githack.com/JuliaDiff/ChainRulesCore.jl/b0b8dbf26807f8f6bc1a3c073b6720b8d90a8cd4/docs/src/assets/logo.svg" width="256"/>

# ChainRulesCore
# ChainRulesOverloadGeneration

[![Build Status](https://github.com/JuliaDiff/ChainRulesCore.jl/workflows/CI/badge.svg)](https://github.com/JuliaDiff/ChainRulesCore.jl/actions?query=workflow:CI)
[![Coverage](https://codecov.io/gh/JuliaDiff/ChainRulesCore.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaDiff/ChainRulesCore.jl)
[![Build Status](https://github.com/JuliaDiff/ChainRulesOverloadGeneration.jl/workflows/CI/badge.svg)](https://github.com/JuliaDiff/ChainRulesOverloadGeneration.jl/actions?query=workflow:CI)
[![Coverage](https://codecov.io/gh/JuliaDiff/ChainRulesOverloadGeneration.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaDiff/ChainRulesOverloadGeneration.jl)
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
[![DOI](https://zenodo.org/badge/199721843.svg)](https://zenodo.org/badge/latestdoi/199721843)

**Docs:**
[![](https://img.shields.io/badge/docs-master-blue.svg)](https://juliadiff.org/ChainRulesCore.jl/dev)
[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliadiff.org/ChainRulesCore.jl/stable)
[![](https://img.shields.io/badge/docs-master-blue.svg)](https://juliadiff.org/ChainRulesOverloadGeneration.jl/dev)
[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliadiff.org/ChainRulesOverloadGeneration.jl/stable)

The ChainRulesCore package provides a light-weight dependency for defining sensitivities for functions in your packages, without you needing to depend on ChainRules itself.

This will allow your package to be used with [ChainRules.jl](https://github.com/JuliaDiff/ChainRules.jl), which aims to provide a variety of common utilities that can be used by downstream automatic differentiation (AD) tools to define and execute forward-, reverse-, and mixed-mode primitives.

This package is a work in progress; PRs welcome!
The ChainRulesOverloadGeneration package provides a suite of methods for using [ChainRulesCore.jl](https://github.com/JuliaDiff/ChainRulesCore.jl) rules in operator overloading AD systems.
It tracks what rules are defined at any point in time, and lets you trigger functions to which can use `@eval` in order to define the matching operator overloads.
12 changes: 9 additions & 3 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,21 @@ uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[ChainRulesCore]]
deps = ["Compat", "LinearAlgebra", "SparseArrays"]
path = ".."
git-tree-sha1 = "b391f22252b8754f4440de1f37ece49d8a7314bb"
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
version = "0.9.44"

[[ChainRulesOverloadGeneration]]
deps = ["ChainRulesCore"]
path = ".."
uuid = "f51149dc-2911-5acf-81fc-2076a2a81d4f"
version = "0.1.0"

[[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "0900bc19193b8e672d9cd477e6cd92d9e7c02f99"
git-tree-sha1 = "e4e2b39db08f967cc1360951f01e8a75ec441cab"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "3.29.0"
version = "3.30.0"

[[Dates]]
deps = ["Printf"]
Expand Down
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
ChainRulesOverloadGeneration = "f51149dc-2911-5acf-81fc-2076a2a81d4f"
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
DocThemeIndigo = "8bac0ac5-51bf-41f9-885e-2bf1ac2bec5f"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Expand Down
62 changes: 11 additions & 51 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,72 +1,32 @@
using ChainRulesCore
using ChainRulesOverloadGeneration
using ChainRulesCore: ChainRulesCore
using Documenter
using DocThemeIndigo
using Markdown

DocMeta.setdocmeta!(
ChainRulesCore,
:DocTestSetup,
quote
using Random
Random.seed!(0) # frule doctest shows output

using ChainRulesCore
# These rules are all actually defined in ChainRules.jl, but we redefine them here to
# avoid the dependency.
@scalar_rule(sin(x), cos(x)) # frule and rrule doctest
@scalar_rule(sincos(x), @setup((sinx, cosx) = Ω), cosx, -sinx) # frule doctest
@scalar_rule(hypot(x::Real, y::Real), (x / Ω, y / Ω)) # rrule doctest
end
)

indigo = DocThemeIndigo.install(ChainRulesCore)
indigo = DocThemeIndigo.install(ChainRulesOverloadGeneration)

makedocs(
modules=[ChainRulesCore],
modules=[ChainRulesOverloadGeneration],
format=Documenter.HTML(
prettyurls=false,
assets=[indigo],
mathengine=MathJax3(
Dict(
:tex => Dict(
"inlineMath" => [["\$","\$"], ["\\(","\\)"]],
"tags" => "ams",
# TODO: remove when using physics package
"macros" => Dict(
"ip" => ["{\\left\\langle #1, #2 \\right\\rangle}", 2],
"Re" => "{\\operatorname{Re}}",
"Im" => "{\\operatorname{Im}}",
"tr" => "{\\operatorname{tr}}",
),
),
),
),
),
sitename="ChainRules",
authors="Jarrett Revels and other contributors",
sitename="ChainRules Overload Generation",
authors="Lyndon White and other contributors",
pages=[
"Introduction" => "index.md",
"FAQ" => "FAQ.md",
"Writing Good Rules" => "writing_good_rules.md",
"Complex Numbers" => "complex.md",
"Deriving Array Rules" => "arrays.md",
"Debug Mode" => "debug_mode.md",
"Gradient Accumulation" => "gradient_accumulation.md",
"Usage in AD" => [
"Overview" => "autodiff/overview.md",
"Operator Overloading" => "autodiff/operator_overloading.md",
],
"Design" => [
"Changing the Primal" => "design/changing_the_primal.md",
"Many Differential Types" => "design/many_differentials.md",
"Examples of making AD systems" => [
"Forward Mode" => "examples/forward_mode.md",
"Reverse Mode" => "examples/reverse_mode.md",
],
"API" => "api.md",
],
],
strict=true,
checkdocs=:exports,
)

deploydocs(
repo = "github.com/JuliaDiff/ChainRulesCore.jl.git",
repo = "github.com/JuliaDiff/ChainRulesOverloadGeneration.jl.git",
push_preview=true,
)
41 changes: 2 additions & 39 deletions docs/src/api.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,12 @@
# API Documentation

## Rules
```@autodocs
Modules = [ChainRulesCore]
Pages = ["rules.jl"]
Private = false
```

## Rule Definition Tools
```@autodocs
Modules = [ChainRulesCore]
Pages = ["rule_definition_tools.jl"]
Private = false
```

## Differentials
```@autodocs
Modules = [ChainRulesCore]
Pages = [
"differentials/abstract_zero.jl",
"differentials/one.jl",
"differentials/composite.jl",
"differentials/thunks.jl",
"differentials/abstract_differential.jl",
"differentials/notimplemented.jl",
]
Private = false
```

## Accumulation
```@docs
add!!
ChainRulesCore.is_inplaceable_destination
```

## Ruleset Loading
```@autodocs
Modules = [ChainRulesCore]
Modules = [ChainRulesOverloadGeneration]
Pages = ["ruleset_loading.jl"]
Private = false
```

## Internal
```@docs
ChainRulesCore.AbstractTangent
ChainRulesCore.debug_mode
ChainRulesCore.clear_new_rule_hooks!
ChainRulesOverloadGeneration.clear_new_rule_hooks!
```
Binary file added docs/src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions docs/src/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions docs/src/examples/forward_mode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# ForwardDiffZero
This is a fairly standard operator overloading-based forward mode AD system.
It defines a `Dual` part which holds both the primal value, paired with the partial derivative.
It doesn't handle chunked-mode, or perturbation confusion.
The overload generation hook in this example is: `define_dual_overload`.

````@eval
using Markdown
Markdown.parse("""
```julia
$(read(joinpath(@__DIR__,"../../../test/demos/forwarddiffzero.jl"), String))
```
""")
````
16 changes: 16 additions & 0 deletions docs/src/examples/reverse_mode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# ReverseDiffZero

This is a fairly standard operator overloading based reverse mode AD system.
It defines a `Tracked` type which carries the primal value as well as a reference to the tape which is it using, a partially accumulated partial derivative and a `propagate` function that propagates its partial back to its input.
A perhaps unusual thing about it is how little it carries around its creating operator's inputs.
That information is all entirely wrapped up in the `propagate` function.
The overload generation hook in this example is: `define_tracked_overload`.

````@eval
using Markdown
Markdown.parse("""
```julia
$(read(joinpath(@__DIR__,"../../../test/demos/reversediffzero.jl"), String))
```
""")
````
Loading