Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify chain input-output #27

Merged
merged 4 commits into from
Feb 23, 2022
Merged

Verify chain input-output #27

merged 4 commits into from
Feb 23, 2022

Conversation

chriselrod
Copy link
Contributor

@chriselrod chriselrod commented Feb 23, 2022

This was accidentally built on top of part of #26, so I suggest merging that first rather than separating these.

input_dims(_) = nothing
function _check_input_dims(x, i)
d = input_dims(x)
d === nothing || @assert d == i
Copy link
Member

Choose a reason for hiding this comment

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

Would it be better to throw an ArgumentError rather than Assert?

Copy link
Member

Choose a reason for hiding this comment

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

A helpful error message would also be nice.

test/runtests.jl Outdated
@@ -8,6 +8,14 @@ dual(x) = ForwardDiff.Dual(x, randn(), randn(), randn())
dual(x::ForwardDiff.Dual) = ForwardDiff.Dual(x, dual(randn()), dual(randn()))

@testset "SimpleChains.jl" begin
# Should throw, as 8 ≠ 10
@test_throws AssertionError SimpleChain((
Copy link
Member

Choose a reason for hiding this comment

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

ArgumentError rather than assert?

@chriselrod chriselrod merged commit 6d305c7 into main Feb 23, 2022
@chriselrod chriselrod deleted the verifychaininputoutput branch February 23, 2022 12:46
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