提交 7f44b538 authored 作者: abergeron's avatar abergeron

Merge pull request #1922 from Hengjean/CheckInputDoc

Check input doc
......@@ -50,7 +50,7 @@ the most important ones:
.. class:: CLinkerType
.. method:: c_declare(name, sub)
.. method:: c_declare(name, sub, check_input=True)
This must return C code which declares variables. These variables
will be available to operations defined in C. You may also write
......@@ -61,7 +61,7 @@ the most important ones:
This must return C code which initializes the variables declared in
``c_declare``. Either this or ``c_extract`` will be called.
.. method:: c_extract(name, sub)
.. method:: c_extract(name, sub, check_input=True)
This must return C code which takes a reference to a Python object
and initializes the variables declared in ``c_declare`` to match the
......@@ -129,6 +129,11 @@ associated to the Variable is ``py_<name>``.
``sub``, on the other hand, is a dictionary containing bits of C code
suitable for use in certain situations. For instance, ``sub['fail']``
contains code that should be inserted wherever an error is identified.
``c_declare`` and ``c_extract`` also accept a third ``check_input``
optional argument. If you want your type to validate its inputs, it must
only do it when ``check_input`` is True.
The example code below should help you understand how everything plays
out:
......
......@@ -91,6 +91,8 @@ Op Contract
def flops(self, inputs, outputs):
pass
check_input = True
.. ../extending/op.txt
......@@ -133,6 +135,10 @@ string representation of your op.
The :func:`R_op` method is needed if you want ``theano.tensor.Rop`` to
work with your op.
The optional boolean :func:'check_input' attribute is used to specify if you want the types used in
your op to check their inputs in their c_code. It can be used to speed up compilation, reduce overhead
(particularly for scalars) and reduce the number of generated C files.
Op Example
==========
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论