From b662a9b66a0f1b7d79749ccd0fbf07245eee8f06 Mon Sep 17 00:00:00 2001 From: Thomas Viehmann Date: Fri, 18 Jan 2019 15:27:12 -0800 Subject: add back NNPACK in PyTorch (#15924) Summary: This tests the water for adding back NNPACK in PyTorch, it's a lot better than the fallback THNN versions. In #6151, we (ezyang and soumith) removed NNPACK support from PyTorch. Of course Maratyszcza might have advice, too. (Or an opinion on the CMake changes.) The only functional changes are to use NNPack more aggressively on mobile and a .contiguous() to match NNPack's assumption (I stumbled over that while using NNPack for style transfer.) The CMake changes try to use the NNPack we already have in git. In terms of lines of code this is a large part of the diff of https://lernapparat.de/pytorch-jit-android/ . As far as I can tell, we don't have MKLDNN on mobile and the native THNN implementation are prohibitively expensive in terms of both CPU and memory. Pull Request resolved: https://github.com/pytorch/pytorch/pull/15924 Differential Revision: D13709576 Pulled By: ezyang fbshipit-source-id: f2e287739909451c173abf046588209a7450ca2c --- tools/autograd/derivatives.yaml | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tools') diff --git a/tools/autograd/derivatives.yaml b/tools/autograd/derivatives.yaml index 2a93d4265b..cf6f2b24ff 100644 --- a/tools/autograd/derivatives.yaml +++ b/tools/autograd/derivatives.yaml @@ -1369,6 +1369,12 @@ save_var: not_implemented("cudnn_batch_norm_backward save_var") input, weight, grad_output: batchnorm_double_backward(input, weight, grads[0], grads[1], grads[2], grad_output, running_mean, running_var, true, epsilon, save_mean, save_var, grad_input_mask) +# nnpack + +- name: _nnpack_spatial_convolution(Tensor input, Tensor weight, Tensor bias, IntList padding) + input: _nnpack_spatial_convolution_backward_input(input, grad, weight, padding) + weight: _nnpack_spatial_convolution_backward_weight(input, weight.sizes(), grad, padding) + bias: grad.contiguous().view({grad.size(0), grad.size(1), -1}).sum(0).sum(1) # Only frst three of _cudnn_rnn outputs can have gradients. # _cudnn_rnn outputs: (output, hy, cy, reserve, weight_buf) -- cgit v1.2.3