提交 c25e8465 authored 作者: Iban Harlouchet's avatar Iban Harlouchet 提交者: Arnaud Bergeron

testcode for doc/extending/ctype.txt

上级 4959dd28
...@@ -156,12 +156,16 @@ out: ...@@ -156,12 +156,16 @@ out:
Defining the methods Defining the methods
==================== ====================
.. testsetup::
import theano
.. If you modify this code, also change : .. If you modify this code, also change :
.. theano/tests/test_tutorial.py:T_extending.test_extending_2 .. theano/tests/test_tutorial.py:T_extending.test_extending_2
**c_declare** **c_declare**
.. code-block:: python .. testcode::
def c_declare(name, sub): def c_declare(name, sub):
return """ return """
...@@ -194,7 +198,7 @@ it, it's best to publish it somewhere. ...@@ -194,7 +198,7 @@ it, it's best to publish it somewhere.
**c_init** **c_init**
.. code-block:: python .. testcode::
def c_init(name, sub): def c_init(name, sub):
return """ return """
...@@ -223,7 +227,7 @@ called, without knowing for sure which of the two. ...@@ -223,7 +227,7 @@ called, without knowing for sure which of the two.
**c_extract** **c_extract**
.. code-block:: python .. testcode::
def c_extract(name, sub): def c_extract(name, sub):
return """ return """
...@@ -262,7 +266,7 @@ API) and we put it in our double variable that we declared previously. ...@@ -262,7 +266,7 @@ API) and we put it in our double variable that we declared previously.
**c_sync** **c_sync**
.. code-block:: python .. testcode::
def c_sync(name, sub): def c_sync(name, sub):
return """ return """
...@@ -324,7 +328,7 @@ than sorry. ...@@ -324,7 +328,7 @@ than sorry.
**c_cleanup** **c_cleanup**
.. code-block:: python .. testcode::
def c_cleanup(name, sub): def c_cleanup(name, sub):
return "" return ""
...@@ -373,7 +377,7 @@ and call it: ...@@ -373,7 +377,7 @@ and call it:
.. If you modify this code, also change : .. If you modify this code, also change :
.. theano/tests/test_tutorial.py:T_extending.test_extending_2 .. theano/tests/test_tutorial.py:T_extending.test_extending_2
.. code-block:: python .. testcode::
from theano import function from theano import function
from theano.tensor import double from theano.tensor import double
...@@ -462,7 +466,7 @@ Final version ...@@ -462,7 +466,7 @@ Final version
.. If you modify this code, also change : .. If you modify this code, also change :
.. theano/tests/test_tutorial.py:T_extending.test_extending_2 .. theano/tests/test_tutorial.py:T_extending.test_extending_2
.. code-block:: python .. testcode::
from theano import gof from theano import gof
...@@ -526,7 +530,7 @@ know how to generate C code. ...@@ -526,7 +530,7 @@ know how to generate C code.
You can implement c_code for this op. You register it like this: You can implement c_code for this op. You register it like this:
.. code-block:: python .. testcode::
theano.compile.ops.register_deep_copy_op_c_code(YOUR_TYPE_CLASS, THE_C_CODE, version=()) theano.compile.ops.register_deep_copy_op_c_code(YOUR_TYPE_CLASS, THE_C_CODE, version=())
...@@ -548,7 +552,7 @@ ViewOp to generate C code when working with this type, as ...@@ -548,7 +552,7 @@ ViewOp to generate C code when working with this type, as
otherwise it will use Python code instead. This is achieved by otherwise it will use Python code instead. This is achieved by
calling: calling:
.. code-block:: python .. testcode::
theano.compile.ops.register_view_op_c_code(YOUR_TYPE_CLASS, THE_C_CODE, version=()) theano.compile.ops.register_view_op_c_code(YOUR_TYPE_CLASS, THE_C_CODE, version=())
...@@ -568,7 +572,7 @@ Theano Variable that has a shape attribute (Shape_i returns only one of ...@@ -568,7 +572,7 @@ Theano Variable that has a shape attribute (Shape_i returns only one of
the elements of the shape). the elements of the shape).
.. code-block:: python .. testcode::
theano.compile.ops.register_shape_c_code(YOUR_TYPE_CLASS, THE_C_CODE, version=()) theano.compile.ops.register_shape_c_code(YOUR_TYPE_CLASS, THE_C_CODE, version=())
theano.compile.ops.register_shape_i_c_code(YOUR_TYPE_CLASS, THE_C_CODE, CHECK_INPUT, version=()) theano.compile.ops.register_shape_i_c_code(YOUR_TYPE_CLASS, THE_C_CODE, CHECK_INPUT, version=())
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论