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

testcode for doc/extending/inplace.txt

上级 8b0980b8
...@@ -55,7 +55,7 @@ Suppose you had an Op which took ``x`` as input and returned ...@@ -55,7 +55,7 @@ Suppose you had an Op which took ``x`` as input and returned
purpose, you would set the ``view_map`` field as follows: purpose, you would set the ``view_map`` field as follows:
.. code-block:: python .. testcode::
myop.view_map = {0: [0]} myop.view_map = {0: [0]}
...@@ -66,7 +66,7 @@ inputs that are viewed by a given output, this feature is currently ...@@ -66,7 +66,7 @@ inputs that are viewed by a given output, this feature is currently
unsupported. Here are more examples: unsupported. Here are more examples:
.. code-block:: python .. testcode::
myop.view_map = {0: [0]} # first output is a view of first input myop.view_map = {0: [0]} # first output is a view of first input
myop.view_map = {0: [1]} # first output is a view of second input myop.view_map = {0: [1]} # first output is a view of second input
...@@ -101,8 +101,11 @@ operation on ``x``. ...@@ -101,8 +101,11 @@ operation on ``x``.
modified. Therefore, code using inplace operations would look like modified. Therefore, code using inplace operations would look like
this: this:
.. code-block:: python .. testcode::
from theano.tensor import dscalars, log
from theano.tensor.inplace import add_inplace
x, y = dscalars('x', 'y') x, y = dscalars('x', 'y')
r1 = log(x) r1 = log(x)
...@@ -144,7 +147,7 @@ Theano needs to be notified of this fact. The syntax is similar to ...@@ -144,7 +147,7 @@ Theano needs to be notified of this fact. The syntax is similar to
that of ``view_map``: that of ``view_map``:
.. code-block:: python .. testcode::
myop.destroy_map = {0: [0]} myop.destroy_map = {0: [0]}
...@@ -153,7 +156,7 @@ What this means is that the first output (position 0) operates inplace on the ...@@ -153,7 +156,7 @@ What this means is that the first output (position 0) operates inplace on the
first input (position 0). first input (position 0).
.. code-block:: python .. testcode::
myop.destroy_map = {0: [0]} # first output operates inplace on first input myop.destroy_map = {0: [0]} # first output operates inplace on first input
myop.destroy_map = {0: [1]} # first output operates inplace on second input myop.destroy_map = {0: [1]} # first output operates inplace on second input
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论