Skip to content

Commit 122d83d

Browse files
committed
simpler
1 parent 191eb47 commit 122d83d

File tree

3 files changed

+2
-22
lines changed

3 files changed

+2
-22
lines changed

src/ChainRulesCore.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module ChainRulesCore
22
using Base.Broadcast: broadcasted, Broadcasted, broadcastable, materialize, materialize!
33
using Base.Meta
44
using LinearAlgebra
5-
using Compat: hasfield, hasproperty, ismutabletype
5+
using Compat: hasfield, hasproperty, ismutabletype, Returns
66

77
export frule, rrule # core function
88
# rule configurations

src/rule_definition_tools.jl

+1-9
Original file line numberDiff line numberDiff line change
@@ -418,14 +418,6 @@ function _nondiff_frule_expr(__source__, primal_sig_parts, primal_invoke)
418418
end
419419
end
420420

421-
struct NonDiffPullback{T<:Tuple{Vararg{NoTangent}}} <: Function
422-
v::T
423-
end
424-
425-
function (@nospecialize pb::NonDiffPullback)(@nospecialize ::Any)
426-
return pb.v
427-
end
428-
429421
function tuple_expression(primal_sig_parts)
430422
has_vararg = _isvararg(primal_sig_parts[end])
431423
return if !has_vararg
@@ -444,7 +436,7 @@ function _nondiff_rrule_expr(__source__, primal_sig_parts, primal_invoke)
444436
tup_expr = tuple_expression(primal_sig_parts)
445437
primal_name = first(primal_invoke.args)
446438
pullback_expr = @strip_linenos quote
447-
NonDiffPullback($(tup_expr))
439+
Returns($(tup_expr))
448440
end
449441

450442
@gensym kwargs

test/rule_definition_tools.jl

-12
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,6 @@ end
4242

4343
@testset "rule_definition_tools.jl" begin
4444
@testset "@non_differentiable" begin
45-
@testset "`NonDiffPullback`" begin
46-
NDP = ChainRulesCore.NonDiffPullback
47-
for i in 0:5
48-
tup = ntuple((_ -> NoTangent()), i)
49-
ndp = NDP(tup)
50-
@test ndp === @inferred NDP(tup)
51-
@test tup === @inferred ndp(:arbitrary)
52-
@test_throws MethodError ndp()
53-
@test_throws MethodError ndp(1, 2)
54-
end
55-
end
56-
5745
@testset "issue #678: identical pullback objects" begin
5846
issue_678_f(::Any) = nothing
5947
issue_678_g(::Any) = nothing

0 commit comments

Comments
 (0)