# Adjoint for Base.TwicePrecision

**URL:** https://discourse.julialang.org/t/adjoint-for-base-twiceprecision/77052
**Category:** Machine Learning
**Tags:** zygote
**Created:** [February 25, 2022, 8:46am UTC](https://discourse.julialang.org/t/adjoint-for-base-twiceprecision/77052 "2022-02-25T08:46:43Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![lxvm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lxvm/32/50010_2.png) [@lxvm](https://discourse.julialang.org/u/lxvm)
#### Post date: [February 25, 2022, 8:46am UTC](https://discourse.julialang.org/t/adjoint-for-base-twiceprecision/77052/1 "2022-02-25T08:46:43Z")

</div>

Hello,

I would like to define an adjoint for Base.TwicePrecision though I was wondering if it can be done given the following test

```julia
julia> using Zygote

julia> gradient(x -> Float64(sum(map(i -> i*Base.TwicePrecision(x), 1:10))), 1.0)
ERROR: Non-differentiable function Core.Intrinsics.bitcast

```

Is it possible to work around a non-differentiable function?

The idea for this question came from trying to differentiate a StepRangeLen, and after defining adjoints for StepRangeLen and Base.TwicePrecision I ran into the same error.

Thanks

---

<div class="post-metadata">

### Author: ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)
#### Post date: [March 4, 2022, 5:03pm UTC](https://discourse.julialang.org/t/adjoint-for-base-twiceprecision/77052/2 "2022-03-04T17:03:23Z")

</div>

If you’re fine with a little piracy then a temporary measure would be to mark it as `@non_differentiable`. Longer-term I think it’s worth asking on the ChainRules.jl tracker if they’d be willing to accept a rule for `TwicePrecision`.
