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

Fix broadcast inference #85

Merged
merged 3 commits into from
Sep 21, 2020
Merged

Conversation

devmotion
Copy link
Contributor

@devmotion devmotion commented Sep 12, 2020

This PR fixes an inference problem with broadcasting of TrackedArray.

On master:

julia> using Tracker, Test

julia> f(x) = @. x < zero(x)

julia> @inferred(f(Tracker.param(rand(5,4))))
ERROR: return type BitArray{2} does not match inferred return type Any
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] top-level scope at REPL[15]:1

With this PR:

julia> using Tracker, Test

julia> f(x) = @. x < zero(x)

julia> @inferred(f(Tracker.param(rand(5,4))))
5×4 BitArray{2}:
 0  0  0  0
 0  0  0  0
 0  0  0  0
 0  0  0  0
 0  0  0  0

This came up in TuringLang/Bijectors.jl#81.

@devmotion devmotion mentioned this pull request Sep 12, 2020
1 task
@devmotion
Copy link
Contributor Author

@DhairyaLGandhi @willtebbutt Anyone up for reviewing and (hopefully) merging this PR?

Copy link
Member

@willtebbutt willtebbutt left a comment

Choose a reason for hiding this comment

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

Should the testing be a bit broader to include a thing that outputs reals as well?

Other than that I'm happy.

src/lib/array.jl Show resolved Hide resolved
@devmotion
Copy link
Contributor Author

@willtebbutt Can you merge the PR and make a new release? I don't have any permissions for Tracker.jl

@willtebbutt willtebbutt merged commit e578cb4 into FluxML:master Sep 21, 2020
@devmotion devmotion deleted the broadcast_inference branch September 21, 2020 14:57
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.

None yet

2 participants