Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

Colab crash using .differentiableReduce() on [Layer] appended with += #1032

Open
mikowals opened this issue Jun 29, 2020 · 1 comment
Open
Assignees

Comments

@mikowals
Copy link
Contributor

This code crashes without output in Colab (s4tf v0.10) though it compiles and runs locally on macOS:

import TensorFlow

public struct Network: Layer {
    var blocks: [Conv2D<Float>] = []

    public init() {
        self.blocks += [Conv2D(filterShape: (3, 3, 16, 16))]
    }

    @differentiable
    public func callAsFunction(_ input: Tensor<Float>) -> Tensor<Float> {
        blocks.differentiableReduce(input) { $1($0) }
    }
}

If I don't append with += (just assign blocks to an array or use blocks.append) there is no crash. Also if I just call blocks[0](input) in callAsFunction there is no crash.

The Colab runtime log message before the restarting is a warning:

python3: /swift-base/swift/lib/SILOptimizer/Analysis/Analysis.cpp:33: static void swift::SILAnalysis::verifyFunction(swift::SILFunction *): Assertion `F->isDefinition() && "Can't analyze external functions"' failed.

I came to this reduced error from a larger block of code that worked in v0.9 but is now crashing. So appending with += and calling differentiableReduce was not crashing in that version.

@marcrasi marcrasi self-assigned this Jul 8, 2020
@saeta
Copy link
Contributor

saeta commented Jul 15, 2020

@marcrasi gentle ping? Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants