Question about: TemporalConvolution.c

I read the THNN recently, I am confusing about the TemporalConvolution.c (I can not understand the achievement)

My Question is:

  1. each iteration in for is corresponding to many outchannels ? (nFrame out feature dimensions). And why choose this way :persevere: (I find it hard to understand it)

  2. The input is LxC instead of CxL ?

  3. should we put these two line int64_t outputFrameStride = (kW-1)/dW+1; int64_t inputFrameStride = outputFrameStride*dW; out of the for operation ?

for(k = 0; nOutputFrame > 0; k++)  
    {
      int64_t outputFrameStride = (kW-1)/dW+1;
      int64_t inputFrameStride = outputFrameStride*dW;
      int64_t nFrame = (nInputFrame-k*dW-kW)/inputFrameStride + 1;  
      nOutputFrame -= nFrame;

      THTensor_(setStorage2d)(inputWindow, input->storage,
                              input->storageOffset+k*dW*input->size[1],
                              nFrame, inputFrameStride*input->size[1],
                              kW*input->size[1], 1);

      THTensor_(setStorage2d)(outputWindow, output->storage,
                              output->storageOffset + k*output->size[1],
                              nFrame, outputFrameStride*output->size[1],
                              output->size[1], 1);

      THTensor *tweight = THTensor_(new)();
      THTensor_(transpose)(tweight, weight, 0, 1);
      THTensor_(addmm)(outputWindow, 1, outputWindow, 1, inputWindow, tweight);
      THTensor_(free)(tweight);
    }
  }
  1. Yes, looks like it.
  2. http://pytorch.org/docs/master/nn.html?highlight=conv1d#torch.nn.Conv1d Input should be N x C x L
  3. Yes, those lines should probably go outside.

Thank you for you reply @richard.

About Q2, http://pytorch.org/docs/master/nn.html?highlight=conv1d#torch.nn.Conv1: is python level. C level maybe not in this rank. From the doc in torch http://pytorch.org/docs/master/nn.html?highlight=conv1d#torch.nn.Conv1d, it seems that the input is nInputFrame x inputFrameSize or nBatchFrame x nInputFrame x inputFrameSize

TemporalConvolution.c is not used in pytorch. Conv1d in pytorch needs N x C x L, it simly views it as 2d N x C x L x 1 and calls SpatialConvolutionMM.c

thank you smth. :grinning: