static void nn_SpatialConvolutionMM_updateOutput_frame(THFloatTensor *input, THFloatTensor *output,
	THFloatTensor *weight, THFloatTensor *bias,
	THFloatTensor *finput,
	int kW, int kH, int dW, int dH, int padW, int padH,
	long nInputPlane, long inputWidth, long inputHeight,
	long nOutputPlane, long outputWidth, long outputHeight)
{
	nn_unfolded_copy(finput, input, kW, kH, dW, dH, padW, padH,
		nInputPlane, inputWidth, inputHeight, outputWidth, outputHeight);

	THFloatTensor *output2d = THFloatTensor_newWithStorage2d(output->storage, output->storageOffset,
		nOutputPlane, -1,
		outputHeight*outputWidth, -1);

	long i;
	for (i = 0; i < nOutputPlane; i++)
	{
		float *data = output->storage->data + output->storageOffset + output->stride[0]*i;
		float what = bias->storage->data[i];
		long len = outputHeight*outputWidth;
		THFloatVector_fill(data, what, len);
	}

	THFloatTensor_addmm(output2d, 1, output2d, 1, weight, finput);

	THFloatTensor_free(output2d);
}
Exemplo n.º 2
0
THFloatTensor *nn_View_updateOutput(struct module *module, THFloatTensor *input)
{
	long nElements = THFloatTensor_nElement(input);
	long numElements = module->View.numElements;
	long batchSize = nElements / numElements;
	THFloatTensor *view;

	if (batchSize > 1)
		view = THFloatTensor_newWithStorage2d(input->storage, input->storageOffset, batchSize, numElements, numElements, 1);
	else
		view = THFloatTensor_newWithStorage1d(input->storage, input->storageOffset, numElements, 1);

	THFloatTensor_free(module->output);
	module->output = view;

	return module->output;
}