# Specifying return Activity in Enzyme

**URL:** <https://discourse.julialang.org/t/specifying-return-activity-in-enzyme/92641>\
**Category:** General Usage\
**Tags:** performance, autodiff, enzyme\
**Created:** [January 7, 2023, 4:46pm UTC](https://discourse.julialang.org/t/specifying-return-activity-in-enzyme/92641 "2023-01-07T16:46:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RS-Coop](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rs-coop/32/32175_2.png) [@RS-Coop](https://discourse.julialang.org/u/RS-Coop)\
**Post date:** [January 7, 2023, 4:46pm UTC](https://discourse.julialang.org/t/specifying-return-activity-in-enzyme/92641/1 "2023-01-07T16:46:50Z")

</div>

Consider a function f:\mathbb{R}^n\to\mathbb{R}. Following along from the Enzyme AutoDiff API documentation example on computing the Hessian via FoR mixed mode AD, I have written the following julia function to compute Hessian-vector products:

```julia
function hvp(f::F, x::S, v::S) where {F, S<:AbstractVector{<:AbstractFloat}}

    bx = similar(x)
    dbx = similar(x)

    autodiff(
        Forward,
        x -> autodiff_deferred(f, x),
        Duplicated(Duplicated(x, bx), Duplicated(v, dbx))
    )

    return dbx
end

```

My question: it is useful in a performance sense to provide the return type `Activity`, and if so how do I do this correctly? For example, it seems to me that I should pass the `Activity` value for the outermost `autodiff` as `const`, but I can’t get this to work.
