https://github.com/JuliaLang/julia
Revision b84fe52c8876de1537c50481546a734cc1990441 authored by Keno Fischer on 28 October 2018, 19:24:13 UTC, committed by GitHub on 28 October 2018, 19:24:13 UTC
* Make broadcast recursion in `flatten` structural

The inference enhancements in #29294 work quite well to prevent limiting
on many kinds of code. However, targetting TPUs, one code pattern it
struggeled with was a fairly large broadcast fusion in Flux:

     λ.(reshape(γ, affine_shape...) .* ((x .- μ) ./ σ) .+ reshape(β, affine_shape...))

The reason #29294 is because the make_makeargs function used by the
implementation of Broadcast.flatten (which the TPU backend uses) had
a non-decreasing first argument (passing the return value of a previous
invocation of make_makeargs back in as the first argument). However,
that's not a fundamental limitation of the operation, but rather an
implementation choice. This PR switches that function's recursion pattern
to be purely structural, allowing inference to infer through it (with
the changes in #29294). As a result, ResNet50 infers properly.

* Comment spelling fix

Co-Authored-By: mbauman <mbauman@gmail.com>
1 parent 1038233
Raw File
Tip revision: b84fe52c8876de1537c50481546a734cc1990441 authored by Keno Fischer on 28 October 2018, 19:24:13 UTC
Make broadcast recursion in `flatten` structural (#29816)
Tip revision: b84fe52
.freebsdci.sh
#!/bin/sh
# FreeBSD CI Build Scripts
# The flow of a FreeBSD CI (https://freebsdci.julialang.org) build:
#
# 1. `cleanup`
# 2. `compile`
# 3. `build-state`
# 4. `runtests`
# 5. `test-embedding`
#
# Detail of flow is controlled by the variable `factory`
# here.
# https://github.com/iblis17/julia-fbsd-buildbot/blob/master/master/master.cfg
#
# Usage: .freebsdci.sh <stage>

set -xe

build-state(){
    gmake build-stats
}

cleanup(){
    git clean -fdx
}

compile(){
    export MALLOC_CONF='junk:false'
    export VERBOSE=1
    export FORCE_ASSERTIONS=1
    export LLVM_ASSERTIONS=1
    export USECCACHE=1

    gmake check-whitespace
    gmake release -j $MAKE_JOBS_NUMBER
}

runtests(){
    export MALLOC_CONF='junk:false'
    export VERBOSE=1
    export FORCE_ASSERTIONS=1
    export LLVM_ASSERTIONS=1
    export JULIA_TEST_MAXRSS_MB=600
    export JULIA_CPU_THREADS=$MAKE_JOBS_NUMBER

    ./usr/bin/julia --check-bounds=yes test/runtests.jl all
    ./usr/bin/julia --check-bounds=yes test/runtests.jl \
        LibGit2/online Pkg/pkg download
}

test-embedding(){
    export JULIA='../../julia'
    export BIN='../../tmp'

    mkdir -vp tmp
    gmake -C test embedding
}


if [ -z $1 ]
then
    exit 1
fi

$1
back to top