JuliaDiff / JuliaDiff/ChainRulesTestUtils.jl

Support testing chunked forward mode

Open
#37 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
Julia
Stars
50
Forks
18
PR merge metrics
No merged PRs in 30d

Description

Consider this (From #36)

simo(x) = (x, 2x)
function ChainRulesCore.frule((_, ẋ), simo, x)
    y = simo(x)
    return y, Composite{typeof(y)}(ẋ, 2ẋ)
end

I believe that that the following should work:

frule_test(simo, (randn(), randn(4)))  # chunked mode, scalar/vector
frule_test(simo, (randn(3), randn(2, 3)))  # chunked mode, vector/matrix

as I believe the following is the correct chunked mode behavour.
@YingboMa am i right?

at least for the scalar primal and vector differential

julia> frule((Zero(), [1, 2, 3]), simo, π)
((π, 6.283185307179586), ([1, 2, 3], [2, 4, 6]))

julia> frule((Zero(), [1 1; 0 1; 1 0]), simo, [1, 1, 1])
(([1, 1, 1], [2, 2, 2]), Composite{Tuple{Array{Int64,1},Array{Int64,1}}}([1 1; 0 1; 1 0], [2 2; 0 2; 2 0]))

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the existing frule_test calls and the frule examples shown in this issue, then review the discussion in #36. Determine the expected chunked forward-mode behavior for scalar/vector and vector/matrix inputs, and confirm that frule_test accepts both cases with the demonstrated outputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
testing-qa
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.