Tensor Conv2DWinograd(Tensor X, Tensor K, Tensor B, Tensor O, int[] stride, int[] pad) { Assert.AreEqual(X.channels, K.kernelDepth); Assert.AreEqual(K.kernelCount, B.flatWidth); Assert.AreEqual(B.flatWidth, B.length); Assert.AreEqual(stride.Length, 2); Assert.AreEqual(pad.Length, 4); // Winograd // transform kernel TensorShape Kws = new TensorShape(K.batch + 1, K.height + 1, K.width, K.channels); var fn_wk = new ComputeFunc(m_Kernels, "KernelWinograd_3x3"); fn_wk.SetTensor("X", K.shape, Pin(K).buffer); var Kw = Dispatch(fn_wk, Kws, K.kernelCount, X.channels, 1); var fn_w = new ComputeFunc(m_Kernels, "Conv2DWinograd_2x2_3x3"); SetTensor(fn_w, "X", X); SetTensor(fn_w, "K", Kw); SetTensor(fn_w, "B", B); fn_w.shader.SetInts("_Pad", pad); var OW = Dispatch(fn_w, O.shape, Kw.kernelCount, IDivC(O.width, 2), IDivC(O.height, 2)); return(OW); }
public void SetTensor(string name, TensorShape shape, ComputeBuffer buffer, Int64 dataOffset = 0) { func.SetTensor(name, shape, buffer, dataOffset); }