Skip to content

Conversation

@chengchingwen
Copy link
Contributor

No description provided.

function rrule(::typeof(permutedims), x::AbstractVector)
project = ProjectTo(x)
permutedims_pullback_1(dy) = (NoTangent(), project(permutedims(unthunk(dy))))
permutedims_pullback_1(::ZeroTangent) = (NoTangent(), ZeroTangent())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDK why there are several Zeros, but perhaps if doing this it may as well accept all of them:

Suggested change
permutedims_pullback_1(::ZeroTangent) = (NoTangent(), ZeroTangent())
permutedims_pullback_1(z::AbstractZero) = (NoTangent(), z)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDK either, but I follow how CR.jl previously do.

norm_pullback_p(::ZeroTangent) = (NoTangent(), ZeroTangent(), ZeroTangent())

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instances of the wider pattern, which I didn't write, include:

isa AbstractZero && return (NoTangent(), V̄)

isa AbstractZero && return (NoTangent(), V̄)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, then should I update this PR, or just leave as it is?

@mcabbott mcabbott merged commit 024704e into JuliaDiff:main Dec 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants