Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

`@grad_from_chainrules` does not support `where` clauses

Abierto
#320 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
julia
Área
tooling

Línea de trabajo

Read src/macros.jl around the @grad_from_chainrules signature check and generated method definitions, then compare the f6/f7 cases in test/MacrosTests.jl. Check how the macro handles where clauses and their parameters. Done means the shown constrained signature is accepted and tests cover where clauses, including related argument types.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

@grad_from_chainrules rejects signatures with a where clause:

using ReverseDiff, ChainRulesCore

f(x) = sum(x)
ChainRulesCore.rrule(::typeof(f), x) = f(x), Δ -> (NoTangent(), fill(Δ, size(x)))
ReverseDiff.@grad_from_chainrules f(x::ReverseDiff.TrackedArray{T}) where {T <: AbstractFloat}
ERROR: LoadError: `@grad_from_chainrules` has to be applied to a function signature

Expected: the rule is imported for TrackedArray{<:AbstractFloat}, as with @grad, which accepts where clauses (covered by the f6/f7 tests in test/MacrosTests.jl). Without them you can't import a rule only for tracked arrays of a given element type, or tie the types of several arguments together (e.g. x::TrackedArray{T}, y::AbstractArray{T}).

Cause: the macro only accepts an Expr(:call, ...). A where clause wraps the call in Expr(:where, ...), and the generated method definitions don't carry whereparams through either.

ReverseDiff master (b796032, v1.18.4), Julia 1.13.1.

Lenguaje dominante
Julia
Estrellas
396
Forks
61
Merge medio
23 h 18 min
PR fusionados (30 d)
16

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de JuliaDiff/ReverseDiff.jl

Todos los issues de JuliaDiff/ReverseDiff.jl

Issues similares

Más issues de Julia

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.