提交 f8872bd4 authored 作者: lamblin's avatar lamblin

Merge pull request #1199 from goodfeli/doc

Doc
def renderString(string, dict):
import warnings
def render_string(string, sub):
"""
string: a string, containing formatting instructions
sub: a dictionary containing keys and values to substitute for
them.
returns: string % sub
The only difference between this function and the % operator
is that it raises an exception with a more informative error
message than the % operator does.
"""
try:
finalCode = string % dict
finalCode = string % sub
except Exception , E:
#print 'could not render C code due to exception with message "'+str(E)+'", trying to find out why...'
# If unable to render the string, render longer and longer
# initial substrings until we find the minimal initial substring
# that causes an error
i = 0
while i <= len(string):
try:
finalCode = string[0:i] % dict
finalCode = string[0:i] % sub
except Exception, F:
if str(F) == str(E):
raise Exception(string[0:i]+"<<<< caused exception "+str(F))
i+=1
assert False
return finalCode
#
def renderString(string, dict):
warnings.warn("renderString is deprecated. It is now called render_string",
stacklevel = 2)
return render_string(string, dict)
def pretty_format(string):
lines = string.split('\n')
......@@ -34,11 +53,8 @@ def pretty_format(string):
rval = '\n'.join(lines)
return rval
#
def strip_leading_white_space(line):
while len(line) >0 and (line[0]==' ' or line[0]=='\t'):
line = line[1:]
#
return line
#
......@@ -220,7 +220,7 @@ if(!work_complete){
}}}}}}} //extra scope so error handler jumps don't cross declarations
///////////// < /code generated by GpuConv3D >
"""
return strutil.renderString(codeSource,locals())
return strutil.render_string(codeSource,locals())
def c_support_code_apply(self, node, nodename):
# This code is not sensitive to the ignore_border flag.
......@@ -279,7 +279,7 @@ conv_rows_stack( float* img, float* kern, float* bias, float* out,
"""
return codeSource#renderString(codeSource,locals())
return codeSource
gpu_convd = GpuConv3D()
......
......@@ -336,7 +336,7 @@ convgrad_rows_stack( float* img, float* dCdH, float* dCdW,
dCdW[j,z,k,l,m] += dCdH[i,j,p,q,r] * V[i,z,dr*p+k,dc*q+l,dt*r+m]
*/
"""
return codeSource#renderString(codeSource,locals())
return codeSource
gpu_conv_grad3d = GpuConvGrad3D()
......
......@@ -263,7 +263,7 @@ if(!work_complete){
}}}}}} // for fail
///////////// < /code generated by GpuConvTransp3D >
"""
return strutil.renderString(codeSource,locals())
return strutil.render_string(codeSource,locals())
def c_support_code_apply(self, node, nodename):
# This code is not sensitive to the ignore_border flag.
......
......@@ -545,7 +545,7 @@ class Conv3D(theano.Op):
///////////// < /code generated by Conv3D >
"""
return strutil.renderString(codeSource,locals())
return strutil.render_string(codeSource,locals())
global conv3D
conv3D = Conv3D()
......
......@@ -271,7 +271,7 @@ class ConvGrad3D(theano.Op):
///////////// < /code generated by ConvGradW3D >
"""
return strutil.renderString(codeSource, locals())
return strutil.render_string(codeSource, locals())
convGrad3D = ConvGrad3D()
......
......@@ -324,7 +324,7 @@ class ConvTransp3D(theano.Op):
///////////// < /code generated by ConvTransp3D >
"""
return strutil.renderString(codeSource, locals())
return strutil.render_string(codeSource, locals())
convTransp3D = ConvTransp3D()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论