Giter Club home page Giter Club logo

Comments (2)

goerch avatar goerch commented on September 21, 2024

Modifying OnceDifferentiable to

mutable struct OnceDifferentiable{F, DF, FDF, TF, TDF, TX} <: AbstractObjective
    f::F # objective
    df::DF # (partial) derivative of objective
    fdf::FDF # objective and (partial) derivative of objective
    F::TF # cache for f output
    DF::TDF # cache for df output
    x_f::TX # x used to evaluate f (stored in F)
    x_df::TX # x used to evaluate df (stored in DF)
    f_calls::Vector{Int}
    df_calls::Vector{Int}
end

I see

 0.000015 seconds (3 allocations: 224 bytes)
  0.000005 seconds (1 allocation: 160 bytes)
  0.000001 seconds (3 allocations: 960 bytes)
  0.000000 seconds (1 allocation: 896 bytes)
  0.000002 seconds (4 allocations: 8.016 KiB)
  0.000001 seconds (2 allocations: 7.953 KiB)
  0.000011 seconds (5 allocations: 78.281 KiB)
  0.000011 seconds (3 allocations: 78.219 KiB)
  0.000178 seconds (5 allocations: 781.406 KiB)
  0.000110 seconds (3 allocations: 781.344 KiB)

  305.021 ns (3 allocations: 224 bytes)
  53.191 ns (1 allocation: 160 bytes)
  326.941 ns (3 allocations: 960 bytes)
  86.506 ns (1 allocation: 896 bytes)
  850.000 ns (3 allocations: 8.00 KiB)
  596.154 ns (1 allocation: 7.94 KiB)
  6.100 μs (4 allocations: 78.27 KiB)
  4.520 μs (2 allocations: 78.20 KiB)
  45.800 μs (4 allocations: 781.39 KiB)
  47.400 μs (2 allocations: 781.33 KiB)

BTW, a similar problem could arise in other objective types too.

from nlsolversbase.jl.

pkofod avatar pkofod commented on September 21, 2024

Yeah, this is because it's not type stable. This was on purpose to avoid recompilation. I can benchmark it again. The reason is that there's dynamic dispatch which causes allocations.

from nlsolversbase.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.