Skip to content

unbroadcast error due to overly strict types #1584

@paulxshen

Description

@paulxshen

Frequently I get something like

TypeError: in typeassert, expected Tuple{T, T} where T, got a value of type Tuple{Array..., Nothing}

caused by

unbroadcast(x::Tuple, x̄) = NTuple{length(x)}(length(x) == length(x̄) ?: accum_sum(x̄; dims=2:ndims(x̄))) # case length(x) > 1
from NTuple enforcing types when some gradient branch is nothing

I can sometimes fix it by rewriting broadcast code or hacks like multiplying a branch by 0 and then adding it to loss. But can we just change NTuple{length(x)} to Tuple in that line?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions