tensor4all / TensorCrossInterpolation.jl

https://tensor4all.github.io/TensorCrossInterpolation.jl/
MIT License
21 stars 1 forks source link

`compress!` is not compatible with Zygote.jl #12

Closed shinaoka closed 1 month ago

shinaoka commented 5 months ago
Mutating arrays is not supported -- called setindex!(Vector{Array{Float64, 4}}, ...)
This error occurs when you ask Zygote to differentiate operations that change
the elements of arrays in place (e.g. setting values with x .= ...)

Possible fixes:
- avoid mutating operations (preferred)
- or read the documentation and solutions for this error
  https://fluxml.ai/Zygote.jl/latest/limitations

Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] _throw_mutation_error(f::Function, args::Vector{Array{Float64, 4}})
    @ Zygote ~/.julia/packages/Zygote/nsBv0/src/lib/array.jl:70
  [3] (::Zygote.var"#539#540"{Vector{Array{Float64, 4}}})(::Nothing)
    @ Zygote ~/.julia/packages/Zygote/nsBv0/src/lib/array.jl:82
  [4] (::Zygote.var"#2623#back#541"{Zygote.var"#539#540"{Vector{Array{Float64, 4}}}})(Δ::Nothing)
    @ Zygote ~/.julia/packages/ZygoteRules/M4xmc/src/adjoint.jl:72
  [5] #compress!#234
    @ ~/.julia/packages/TensorCrossInterpolation/sZnUJ/src/tensortrain.jl:146 [inlined]
  [6] (::Zygote.Pullback{Tuple{TensorCrossInterpolation.var"##compress!#234", Float64, Int64, typeof(TensorCrossInterpolation.compress!), TensorCrossInterpolation.TensorTrain{Float64, 4}, Symbol}, Any})(Δ::Nothing)
    @ Zygote ~/.julia/packages/Zygote/nsBv0/src/compiler/interface2.jl:0
  [7] compress!
    @ ~/.julia/packages/TensorCrossInterpolation/sZnUJ/src/tensortrain.jl:119 [inlined]
...
    @ ~/.julia/packages/Optim/ZhuZN/src/multivariate/optimize/interface.jl:151 [inlined]