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

Refactor tests and make NNPACK optional #154

Merged
merged 12 commits into from
Dec 24, 2019

Conversation

DhairyaLGandhi
Copy link
Member

This is aimed towards the multiple failures noted in NNlib due to the testing scheme failing to catch broken cases, even when errors were thrown

Relates to #153 and #152

Additionally the inference tests with the @inferred macro have been replaced with checking types from the output, this remains as a TODO to fix inference, and find what is causing inference to fail.

For now, this refactor ensures that tests that have errored (esp. on CI), show up correctly. The difference comes up as tests/conv.jl has the skips in place for checking fuzzing tests, returns and further tests aren't marked with failures

cc @staticfloat @ChrisRackauckas @MikeInnes

@DhairyaLGandhi
Copy link
Member Author

DhairyaLGandhi commented Dec 23, 2019

As a test, I have added a dummy function in there to throw and make sure that CI reports a failure.

@DhairyaLGandhi
Copy link
Member Author

Things look as expected on Travis, AppVeyor needs a bit of hand holding to build

@codecov-io
Copy link

codecov-io commented Dec 23, 2019

Codecov Report

Merging #154 into master will decrease coverage by 8.23%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #154      +/-   ##
==========================================
- Coverage   74.41%   66.18%   -8.24%     
==========================================
  Files          24       24              
  Lines         774      757      -17     
==========================================
- Hits          576      501      -75     
- Misses        198      256      +58
Impacted Files Coverage Δ
src/nnpack/NNPACK.jl 0% <0%> (-88.24%) ⬇️
src/NNlib.jl 100% <100%> (ø) ⬆️
src/nnpack/interface.jl 0% <0%> (-93.75%) ⬇️
src/nnpack/impl.jl 0% <0%> (-42.11%) ⬇️
src/nnpack/performance.jl 0% <0%> (-41.67%) ⬇️
src/nnpack/libnnpack.jl 0% <0%> (-30.91%) ⬇️
src/nnpack/libnnpack_types.jl 0% <0%> (-30%) ⬇️
src/pooling.jl 86.36% <0%> (-9.1%) ⬇️
src/nnpack/error.jl 0% <0%> (-4.42%) ⬇️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 480754a...20e8e47. Read the comment docs.

@DhairyaLGandhi
Copy link
Member Author

Added return type annotations to the NNPACK codebase to help inference along. Earlier it was inferring Any, and this should help resolve the type to the expected Array.

@DhairyaLGandhi
Copy link
Member Author

The inference works, but that breaks mixed precision conv_<filter/data>_im2col.

@DhairyaLGandhi
Copy link
Member Author

So this also introduces a switch to turn off NNPACK, which is unset by default. Good for backwards compatibility and fleshing out the implementation.

src/NNlib.jl Outdated
if Sys.islinux() || Sys.isapple()
include("nnpack/NNPACK.jl")
if get(ENV, "NNLIB_USE_NNPACK", "false") == "true"
if Sys.islinux() || Sys.isapple()
Copy link
Contributor

Choose a reason for hiding this comment

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

This is then something that needs to be set during precompile time. And if you want to change it, how do you cause the package to be recompiled for it to take affect?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, maybe I should move this to an __init__ function.

Copy link
Contributor

Choose a reason for hiding this comment

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

That has some other negatives in the sense that the NNPack code will no longer be preconpilable. One way would probably be to not use dispatch to select the backend code but instead have something like

function conv(...)
    if get(ENV(...))
         _NNPack_conv(...)
    else
        generic_conv(...)
    end
end

But that would require some restructuring of code that might be a bit annoying.

The easiest is probably to move to use a build step. The build file looks at the ENV variable and creates a file that includes the NNPack depending on the env variable. If one wants to change this option, one sets the nrw env var and the runs build on the package.

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean doing this in the build.jl file and write to deps.jl?

Copy link
Member Author

@DhairyaLGandhi DhairyaLGandhi Dec 24, 2019

Choose a reason for hiding this comment

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

I've made it so.

@DhairyaLGandhi DhairyaLGandhi changed the title Refactor tests Refactor tests and make NNPACK optional Dec 24, 2019
@DhairyaLGandhi
Copy link
Member Author

Merging this now, to get the ecosystem up and running. Hopefully it doesn't complicate debugging and testing too much @staticfloat ?

@DhairyaLGandhi DhairyaLGandhi merged commit 398bfdd into FluxML:master Dec 24, 2019
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.

3 participants