This commit is contained in:
George Hotz 2020-10-19 09:37:07 -07:00
parent bee89a4840
commit 4faf3a0aed
1 changed files with 6 additions and 7 deletions

View File

@ -159,13 +159,12 @@ class Conv2D(Function):
def forward(ctx, x, w):
cout,cin,H,W = w.shape
ret = np.zeros((x.shape[0], cout, x.shape[2]-(H-1), x.shape[3]-(W-1)), dtype=w.dtype)
for Y in range(ret.shape[2]):
for X in range(ret.shape[3]):
for j in range(H):
for i in range(W):
tx = x[:, :, Y+j, X+i]
tw = w[:, :, j, i]
ret[:, :, Y, X] += tx.dot(tw.T)
for j in range(H):
for i in range(W):
tw = w[:, :, j, i]
for Y in range(ret.shape[2]):
for X in range(ret.shape[3]):
ret[:, :, Y, X] += x[:, :, Y+j, X+i].dot(tw.T)
return ret
@staticmethod