Skip to content

control on chunk_size in chunk_size  #156

@JianghuiDu

Description

@JianghuiDu

There doesn't seem to be an argument for chunk_size in JacVec or JacVecOperator. My code has some temporary variables inside so I use dualcache. But my choice of chunk_size in dualcache is not compatible with JacVec unless it is set to 1.

Here's an example using the example shown in the dualcache tutorial:

using LinearAlgebra, OrdinaryDiffEq, PreallocationTools
function foo(du, u, (A, tmp), t)
    tmp = get_tmp(tmp, u)
    mul!(tmp, A, u)
    @. du = u + tmp
    nothing
end
chunk_size = 1
# chunk_size = 5  doesn't work!

(A, tmp) = (ones(5,5), dualcache(zeros(5), Val{chunk_size}))
ff = (y,x)->foo(y,x,(A,tmp),nothing)

u0 = rand(5);
du0 = similar(u0);
ff(du0,u0)

using SparseDiffTools

J = JacVec(ff,u0;autodiff=true);
res = similar(u0);
mul!(res,J,u0) # Does 1 f evaluation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions