提交 ee1dbd1c authored 作者: Frederic Bastien's avatar Frederic Bastien

in ConvOp.__init__, if the unroll value are not good, we try to find a good one.…

in ConvOp.__init__, if the unroll value are not good, we try to find a good one. Otherwise we set 1 and print an OPTIMISATION WARNING. We do this as it is probably safer to use default value for the optimisation parameter if they are bad and execute then to fail.
上级 96b7efa1
...@@ -43,9 +43,17 @@ class ConvOp(Op): ...@@ -43,9 +43,17 @@ class ConvOp(Op):
self.unroll_kern=unroll_kern self.unroll_kern=unroll_kern
if self.unroll_batch>0 and self.bsize % self.unroll_batch!=0: if self.unroll_batch>0 and self.bsize % self.unroll_batch!=0:
raise Exception("unroll_batch(%s) should be 0 or a multiple of bsize(%s)"%(str(self.unroll_batch),str(self.bsize))) if self.bsize<self.unroll_batch:
self.unroll_batch = self.bsize
else:
self.unroll_batch=1
print "OPTIMISATION WARNING: in ConvOp.__init__() unroll_batch(%s) must be 0 or a multiple of bsize(%s). We revert it to 1. This won't change the result, but may make it slower."%(str(self.unroll_batch),str(self.bsize))
if self.unroll_kern>0 and self.nkern % unroll_kern!=0: if self.unroll_kern>0 and self.nkern % unroll_kern!=0:
raise Exception("unroll_kern(%s) should be 0 or a multiple of nkern(%s)"%(str(self.unroll_kern),str(self.nkern))) if self.nkern<self.unroll_kern:
self.unroll_kern = self.nkern
else:
self.unroll_kern=1
print "OPTIMISATION WARNING: in ConvOp.__init__() unroll_kern(%s) should be 0 or a multiple of nkern(%s)We revert it to 1. This won't change the result, but may make it slower."%(str(self.unroll_kern),str(self.nkern))
if self.dx!=1 or self.dy!=1: if self.dx!=1 or self.dy!=1:
print "Warning, dx!=1 or dy!=1 only supported in python mode!" print "Warning, dx!=1 or dy!=1 only supported in python mode!"
raise NotImplementedError() raise NotImplementedError()
...@@ -146,13 +154,13 @@ class ConvOp(Op): ...@@ -146,13 +154,13 @@ class ConvOp(Op):
un_b = bsize un_b = bsize
else: else:
un_b = 1 un_b = 1
print "WARNING, can't determine a good unroll value for the batch in the gradient. Maybe you can optimize this!" print "OPTIMISATION WARNING: in ConvOp.grad() we can't determine a good unroll value for the batch. Maybe you can optimize this!"
if un_k!=0 and nkern%un_k!=0: if un_k!=0 and nkern%un_k!=0:
if nkern<un_k: if nkern<un_k:
un_k = nkern un_k = nkern
else: else:
un_k = 1 un_k = 1
print "WARNING, can't determine a good unroll value for the kerner in the gradient. Maybe you can optimize this!" print "OPTIMISATION WARNING: in ConvOp.grad() we can't determine a good unroll value for the kernel. Maybe you can optimize this!"
dw = ConvOp(imshp, kshp, nkern, bsize, 1,1, output_mode='valid', dw = ConvOp(imshp, kshp, nkern, bsize, 1,1, output_mode='valid',
unroll_batch=un_b, unroll_kern=un_k)(img,filters) unroll_batch=un_b, unroll_kern=un_k)(img,filters)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论