From c057bea9983600265add55cb75c898ad31091bca Mon Sep 17 00:00:00 2001 From: Wei Wu Date: Sat, 25 Mar 2017 12:51:33 +0800 Subject: [PATCH] update fc with nnpck (#5570) fix description fix --- docs/how_to/nnpack.md | 4 ++-- src/operator/fully_connected.cc | 14 +++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/docs/how_to/nnpack.md b/docs/how_to/nnpack.md index a1a42085c3ca..65a9d535da7f 100644 --- a/docs/how_to/nnpack.md +++ b/docs/how_to/nnpack.md @@ -2,7 +2,7 @@ [NNPACK](https://github.com/Maratyszcza/NNPACK) is an acceleration package for neural network computations, which can run on x86-64, ARMv7, or ARM64 architecture cpus. it's very useful for us using NNPACK to speed up running speed when deploy the trained model on mobile device. -MXNet(nnvm branch) has integrated NNPACK for forward propagation(only inference) in convolution/max-pooling/fully-connected, so you may consider using NNPACK now. +MXNet has integrated NNPACK for forward propagation(only inference) in convolution/max-pooling/fully-connected, so you may consider using NNPACK now. ### Conditions @@ -15,7 +15,7 @@ The following table will tell you which satisfaction will NNPACK work. |:--------- |:---------- | |convolution |2d convolution `and` no-bias=False `and` dilate=(1,1) `and` num_group=1 `and` batch-size = 1 or batch-size > 1 && stride = (1,1);| |pooling | max-pooling `and` kernel=(2,2) `and` stride=(2,2) `and` pooling_convention=full | -|fully-connected| batch-size = 2^n | +|fully-connected| without any restrictions | ### Build/Install NNPACK with MXNet diff --git a/src/operator/fully_connected.cc b/src/operator/fully_connected.cc index 8dda6331f637..44ace9e47325 100644 --- a/src/operator/fully_connected.cc +++ b/src/operator/fully_connected.cc @@ -36,15 +36,11 @@ Operator* CreateOp(FullyConnectedParam param, int dtype, const size_t batch_size = (*in_shape)[0][0]; // nnp_fully_connected_inference will do optimization for batch-size = 1 // nnp_fully_connected_output will do optimization for batch-size > 1 - // but just found FullyConnected in NNPACK result is wrong when batch_size != 2^n - // so here only using NNPACK when batch_size = 2^n. - if ((batch_size == 1) || ((batch_size > 1) && (!(batch_size & (batch_size - 1))))) { - switch (dtype) { - case mshadow::kFloat32: - return new NNPACKFullyConnectedOp(param); - default: - break; - } + switch (dtype) { + case mshadow::kFloat32: + return new NNPACKFullyConnectedOp(param); + default: + break; } #endif switch (dtype) {