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

add NNPACK check status and test #198

Conversation

edgarriba
Copy link
Member

@edgarriba edgarriba commented Jun 21, 2016

@nyanp @wangyida @bhack @mtamburrano
Could you test NNPACK in your own devices? Getting a segfault here

@edgarriba edgarriba force-pushed the feat/generic-computational-graph-device-abstraction branch 2 times, most recently from 0c676ea to be7711a Compare June 21, 2016 15:30
@bhack
Copy link
Contributor

bhack commented Jun 21, 2016

The Segfault was on the AVX2 flag?

@edgarriba
Copy link
Member Author

nope. Still not working

deconv_layer_worker_specific_storage& cws =
(*deconv_layer_worker_storage_)[index];
copy_and_pad_delta(cws.curr_delta_padded, *in_grad[0]);
copy_and_pad_delta(cws.curr_delta_padded, *in_grad[0]); // *in_grad[0] does not exist here!
const vec_t& W = *in_data[1];
Copy link
Member Author

Choose a reason for hiding this comment

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

@wangyida Are you sure that you compiled this? There are variables that are not declared

Copy link
Contributor

@wangyida wangyida Jun 22, 2016

Choose a reason for hiding this comment

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

Here is a mistake, line 101:

copy_and_pad_delta(cws.curr_delta_padded, *in_grad[0]);

should be replaced as:

(*deconv_layer_worker_storage_)[index].prev_out_ = in_data[0];

and line 166:

std::function<void(const vec_t&, vec_t&)> copy_and_pad_delta;

should be replaced as:

std::function<void(const vec_t&, int)> copy_and_unpad_output;

You can modify them directly, output of deconvolution might be unpadded and the delta in backforward might be padded, it's just the opposite operation of convolution in padding strategy.
I haven't compile with nnp backend as nnPack is not installed yet. These codes are modified logically in nnp.

@bhack
Copy link
Contributor

bhack commented Jun 21, 2016

@edgarriba How the segfault is reproducible?

@bhack
Copy link
Contributor

bhack commented Jun 21, 2016

@edgarriba I've executed the test and i got an error. Have you executed init_nnp_engine()?

@bhack
Copy link
Contributor

bhack commented Jun 21, 2016

terminate called after throwing an instance of 'tiny_cnn::nn_error'
  what():  ����m[ERROR] NNPACK Max-Pool requires a stride == 2.

@edgarriba
Copy link
Member Author

good point ! Unfortunately my laptop doesn't support AVX2.

If I compile with -mavx2 flag I got the following error: Illegal instruction (core dumped). In the other case, NNPACK raises the following error: NNPACK does not implement this function for the host CPU.

@bhack
Copy link
Contributor

bhack commented Jun 21, 2016

Arg! We have avx2 at work. But I've only avx on laptop.
Avx2 require a quite new CPU. How many kernels are avx2 only?

@bhack
Copy link
Contributor

bhack commented Jun 21, 2016

P.s. Avx2 was introduced with Haswell arch.

@bhack
Copy link
Contributor

bhack commented Jun 22, 2016

@Maratyszcza Needs all the kernels in NNPACK avx2?

@bhack
Copy link
Contributor

bhack commented Jun 22, 2016

@edgarriba You can execute tests with Intel SDE or Qemu to emulate avx2

@edgarriba
Copy link
Member Author

edgarriba commented Jun 22, 2016

@bhack oki. I'll try

@edgarriba
Copy link
Member Author

edgarriba commented Jun 22, 2016

@bhack getting the same. I updated the test, the parameters were wrong.
Not sure if we are configuring well the kernels. The segfault occurs inside NNPACK routine.

@Maratyszcza @ajtulloch Did you found any issue during Caffe's integration?

@ajtulloch
Copy link

Make sure all the unit tests for the Caffe integration pass on your machine?

@edgarriba
Copy link
Member Author

@ajtulloch thx for your answer.
I've tried nnpack-pr branch and all tests passes except InnerProductLayerTest/0.TestGradientNNPACK. Check log.txt

@bhack @nyanp If tests for convolution and pooling works in Caffe's version it means that we are doing something wrong.

@bhack
Copy link
Contributor

bhack commented Jun 22, 2016

@edgarriba Are you running with Intel SDE?

@edgarriba
Copy link
Member Author

@ajtulloch @Maratyszcza I noticed that nnp_max_pooling_output is running, however it deallocates the content of my output_ptr. Any idea?

@Maratyszcza
Copy link

Maratyszcza commented Jun 22, 2016

@edgarriba An issue in convolution backpropagation came up during Caffe integration (see Maratyszcza/NNPACK#15), but I believe it is fixed now. AFAIK, there aren't any unsolved crash or correctness bugs.

As for nnp_max_pooling_output, you may want to check how you compute the output size (and compare it with NNPACK). I remember that there are some variations in output size between packages, and NNPACK follows Caffe & cuDNN convention. Update: if your package follows different convention, it may lead to out-of-bounds writes in NNPACK, which may make it feel like some memory is deallocated.

@Maratyszcza
Copy link

@bhack I'd expect that all kernels require AVX2 or at least FMA3 (which means Haswell+ among Intel CPUs). However, you may build NNPACK with clang with --enable-psimd flag. Performance wouldn't be as good, but it will work everywhere, and probably suit your development needs.

@bhack
Copy link
Contributor

bhack commented Jun 22, 2016

@Maratyszcza Thank you. I've already executed with Intel sde on a cpu without avx2 but your option it is useful cause doen't rely on closed source tools. There will be a common maintainer ship of NNPACK with the Facebook group or will remain a personal project?

@Maratyszcza
Copy link

@bhack I heard you can emulate new instruction sets with qemu if Intel SDE doesn't suit your needs.

For the next year I am still a Ph.D. student at Georgia Tech, but NNPACK is developed in collaboration with F.A.I.R., and it is production-quality code.

@wangyida
Copy link
Contributor

This is a major PR, so I think that some bug fixes in my local machine is better not being pushed as a new PR that will make it a additional task for @edgarriba to rebase again. I think I could push them after this PR got merged, am I right?
BTW, Line 141 of CMakeLists.txt might be better replaced as:

LINK_LIBRARIES(${REQUIRED_LIBRARIES})

Some OpenCV related libs would be regarded placed in the current directory if it is written as:

link_directories(${REQUIRED_LIBRARIES})

@edgarriba edgarriba force-pushed the feat/generic-computational-graph-device-abstraction branch 3 times, most recently from 0810832 to 0588bc8 Compare June 25, 2016 21:39
add AVX2 flag

add NNPACK support for maxpooling layer

add missing engine initialization

minor typo and lint changes

fix minor issue with param access

refactor backend_init, add setup tests for maxpol and conv layers

remove old file

remove old file

add NNPACK fully_connected

fix NNPACK pointer cast

fix travis checks
@edgarriba
Copy link
Member Author

@bhack @nyanp NNPACK working. We're good to merge. Next LibDNN.

@Maratyszcza @ajtulloch thx for your support !
@Maratyszcza Can we link tiny-cnn to NNPACK project readme?

@nyanp
Copy link
Member

nyanp commented Jun 26, 2016

@edgarriba
OK, great!! (I'm sorry but I wasn't enough time for the past few days to support your debbuging...) Let's go next :)

@nyanp nyanp merged commit 5a14ee1 into tiny-dnn:feat/generic-computational-graph Jun 26, 2016
@Maratyszcza
Copy link

@edgarriba Referenced tiny-cnn in NNPACK readme. Or did you mean something else?

@edgarriba
Copy link
Member Author

@Maratyszcza That's fine. Thanks a lot !

edgarriba added a commit to edgarriba/tiny-cnn that referenced this pull request Aug 8, 2016
add AVX2 flag

add NNPACK support for maxpooling layer

add missing engine initialization

minor typo and lint changes

fix minor issue with param access

refactor backend_init, add setup tests for maxpol and conv layers

remove old file

remove old file

add NNPACK fully_connected

fix NNPACK pointer cast

fix travis checks
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

6 participants