提交 48de5a3b authored 作者: Iban Harlouchet's avatar Iban Harlouchet

numpydoc for theano/tensor/elemwise_cgen.py

上级 a5604ec8
...@@ -117,8 +117,11 @@ def make_checks(loop_orders, dtypes, sub): ...@@ -117,8 +117,11 @@ def make_checks(loop_orders, dtypes, sub):
def make_alloc(loop_orders, dtype, sub, fortran='0'): def make_alloc(loop_orders, dtype, sub, fortran='0'):
"""Generate C code to allocate outputs. """Generate C code to allocate outputs.
:param fortran: a string included in the generated code. If it Parameters
evaludate to non-zero, an ndarray in fortran order will be ----------
fortran : str
A string included in the generated code. If it
evaluate to non-zero, an ndarray in fortran order will be
created, otherwise it will be c order. created, otherwise it will be c order.
""" """
...@@ -179,25 +182,24 @@ def make_loop(loop_orders, dtypes, loop_tasks, sub, openmp=None): ...@@ -179,25 +182,24 @@ def make_loop(loop_orders, dtypes, loop_tasks, sub, openmp=None):
Make a nested loop over several arrays and associate specific code Make a nested loop over several arrays and associate specific code
to each level of nesting. to each level of nesting.
@type loop_orders: list of N tuples of length M. Parameters
@param loop_orders: Each value of each ----------
tuple can be either the index of a dimension to loop over or loop_orders : list of N tuples of length M
the letter 'x' which means there is no looping to be done Each value of each tuple can be either the index of a dimension to
over that variable at that point (in other words we broadcast loop over or the letter 'x' which means there is no looping to be done
over that dimension). If an entry is an integer, it will become over that variable at that point (in other words we broadcast
an alias of the entry of that rank. over that dimension). If an entry is an integer, it will become
an alias of the entry of that rank.
@type loop_tasks: list of M+1 pieces of code. loop_tasks : list of M+1 pieces of code
@param loop_tasks: The ith loop_task is a pair of strings, the first The ith loop_task is a pair of strings, the first
string is code to be executed before the ith loop starts, the second string is code to be executed before the ith loop starts, the second
one contains code to be executed just before going to the next element one contains code to be executed just before going to the next element
of the ith dimension. of the ith dimension.
The last element if loop_tasks is a single string, containing code The last element if loop_tasks is a single string, containing code
to be executed at the very end. to be executed at the very end.
sub : dictionary
@type sub: a dictionary. Maps 'lv#' to a suitable variable name.
@param sub: Maps 'lv#' to a suitable variable name. The 'lvi' variable corresponds to the ith element of loop_orders.
The 'lvi' variable corresponds to the ith element of loop_orders.
""" """
def loop_over(preloop, code, indices, i): def loop_over(preloop, code, indices, i):
...@@ -244,8 +246,9 @@ def make_loop(loop_orders, dtypes, loop_tasks, sub, openmp=None): ...@@ -244,8 +246,9 @@ def make_loop(loop_orders, dtypes, loop_tasks, sub, openmp=None):
return "{%s}" % s return "{%s}" % s
def make_reordered_loop(init_loop_orders, olv_index, dtypes, inner_task, sub, openmp=None): def make_reordered_loop(init_loop_orders, olv_index, dtypes, inner_task, sub,
'''A bit like make_loop, but when only the inner-most loop executes code. openmp=None):
"""A bit like make_loop, but when only the inner-most loop executes code.
All the loops will be reordered so that the loops over the output tensor All the loops will be reordered so that the loops over the output tensor
are executed with memory access as contiguous as possible. are executed with memory access as contiguous as possible.
...@@ -253,7 +256,8 @@ def make_reordered_loop(init_loop_orders, olv_index, dtypes, inner_task, sub, op ...@@ -253,7 +256,8 @@ def make_reordered_loop(init_loop_orders, olv_index, dtypes, inner_task, sub, op
will be on its rows; if it's f_contiguous, it will be on its columns. will be on its rows; if it's f_contiguous, it will be on its columns.
The output tensor's index among the loop variables is indicated by olv_index. The output tensor's index among the loop variables is indicated by olv_index.
'''
"""
# Number of variables # Number of variables
nvars = len(init_loop_orders) nvars = len(init_loop_orders)
...@@ -463,25 +467,25 @@ def make_loop_careduce(loop_orders, dtypes, loop_tasks, sub): ...@@ -463,25 +467,25 @@ def make_loop_careduce(loop_orders, dtypes, loop_tasks, sub):
Make a nested loop over several arrays and associate specific code Make a nested loop over several arrays and associate specific code
to each level of nesting. to each level of nesting.
@type loop_orders: list of N tuples of length M. Parameters
@param loop_orders: Each value of each ----------
tuple can be either the index of a dimension to loop over or loop_orders : list of N tuples of length M
the letter 'x' which means there is no looping to be done Each value of each tuple can be either the index of a dimension to
over that variable at that point (in other words we broadcast loop over or the letter 'x' which means there is no looping to be done
over that dimension). If an entry is an integer, it will become over that variable at that point (in other words we broadcast
an alias of the entry of that rank. over that dimension). If an entry is an integer, it will become
an alias of the entry of that rank.
@type loop_tasks: list of M+1 pieces of code. loop_tasks : list of M+1 pieces of code
@param loop_tasks: The ith loop_task is a pair of strings, the first The ith loop_task is a pair of strings, the first
string is code to be executed before the ith loop starts, the second string is code to be executed before the ith loop starts, the second
one contains code to be executed just before going to the next element one contains code to be executed just before going to the next element
of the ith dimension. of the ith dimension.
The last element if loop_tasks is a single string, containing code The last element if loop_tasks is a single string, containing code
to be executed at the very end. to be executed at the very end.
sub: dictionary
@type sub: a dictionary. Maps 'lv#' to a suitable variable name.
@param sub: Maps 'lv#' to a suitable variable name. The 'lvi' variable corresponds to the ith element of loop_orders.
The 'lvi' variable corresponds to the ith element of loop_orders.
""" """
def loop_over(preloop, code, indices, i): def loop_over(preloop, code, indices, i):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论