JuliaDiff / SparseDiffTools.jl

Fast jacobian computation through sparsity exploitation and matrix coloring
MIT License
238 stars 41 forks source link

Value type #54

Closed devmotion closed 5 years ago

devmotion commented 5 years ago

It seems, the function in lines https://github.com/JuliaDiffEq/SparseDiffTools.jl/blob/master/src/differentiation/compute_jacobian_ad.jl#L10-L16 is equivalent to the bad example in https://docs.julialang.org/en/v1/manual/performance-tips/index.html#Types-with-values-as-parameters-1? Should it just be chunksize = max(maximum(colors), DEFAULT_CHUNK_SIZE) in https://github.com/JuliaDiffEq/SparseDiffTools.jl/blob/master/src/differentiation/compute_jacobian_ad.jl#L27 instead? Or could the Val instance still be helpful when calling generate_chunked_partials?

But then still the same problem appears in https://github.com/JuliaDiffEq/SparseDiffTools.jl/blob/master/src/differentiation/compute_jacobian_ad.jl#L46?

ChrisRackauckas commented 5 years ago

The user is supposed to pass a value type. The partials have to be known at compile time for the tuple length.

ChrisRackauckas commented 5 years ago

If all we have is the length, we determine it at cache construction time so the type is gotten once, and then further function calls have it all inferred. It's the same in ForwardDiff and not the bad example there.

devmotion commented 5 years ago

I'm just desperately trying to find all possible issues and was confused by the default_chunk_size function and the fact that integers are "converted" to Vals. But then this is probably not a major issue, it seems.