 #else
 
 #include "../common.h"
+
+static inline void THNN_(SpatialSubSampling_shapeCheck)(
+                         THCState *state,
+                         THCTensor *input,
+                         THCTensor *gradOutput,
+                         THCTensor *weight,
+                         int kW, int kH) {
+  THCUNN_argCheck(state, input->nDimension == 3 || input->nDimension == 4, 2, input,
+                  "3D or 4D input tensor expected but got: %s");
+
+  int nInputPlane = THCTensor_(size)(state, weight, 0);
+
+  int dimc = 2;
+  int dimr = 1;
+  int dimp = 0;
+
+  if (input->nDimension == 4) {
+    dimc++;
+    dimr++;
+    dimp++;
+  }
+
+  long nInputCols = input->size[dimc];
+  long nInputRows = input->size[dimr];
+  THArgCheck(input->size[dimp] == nInputPlane, 2, "invalid number of input planes");
+  THArgCheck(nInputCols >= kW && nInputRows >= kH, 2, "input image smaller than kernel size");
+
+  if (gradOutput != NULL) {
+    THArgCheck(THCTensor_(isContiguous)(state, gradOutput), 3, "gradOutput must be contiguous");
+  }
+}
 
 void THNN_(SpatialSubSampling_updateOutput)(
            THCState *state,

  int nInputPlane = THCTensor_(size)(state, weight, 0);

  THCUNN_assertSameGPU(state, 4, input, output, weight, bias);
  THArgCheck(input->nDimension == 3 || input->nDimension == 4, 2, "3D or 4D (batch) tensor expected");

  if (input->nDimension == 3) {
    long nInputCols = input->size[2];
    long nInputRows = input->size[1];
    long nOutputCols = (nInputCols - kW) / dW + 1;
    long nOutputRows = (nInputRows - kH) / dH + 1;

    THArgCheck(input->size[0] == nInputPlane, 2, "invalid number of input planes");
    THArgCheck(nInputCols >= kW && nInputRows >= kH, 2, "input image smaller than kernel size");

    input = THCTensor_(newContiguous)(state, input);
    input_data = THCTensor_(data)(state, input);

    long nbatch = input->size[0];
    long nOutputCols = (nInputCols - kW) / dW + 1;
    long nOutputRows = (nInputRows - kH) / dH + 1;

    input = THCTensor_(newContiguous)(state, input);
    input_data = THCTensor_(data)(state, input);
