Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
18622fed
提交
18622fed
authored
12月 19, 2014
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Some documentation fixes.
上级
66f946d4
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
16 行增加
和
12 行删除
+16
-12
extending_theano_c.txt
doc/tutorial/extending_theano_c.txt
+16
-12
没有找到文件。
doc/tutorial/extending_theano_c.txt
浏览文件 @
18622fed
...
@@ -836,14 +836,15 @@ this new version of the VectorTimesVector op :
...
@@ -836,14 +836,15 @@ this new version of the VectorTimesVector op :
class doesn't change anything here.
class doesn't change anything here.
* External C code : the external C code implements the various
* External C code : the external C code implements the various
functions associated with the op.
associated with the op.
functions associated with the op.
Writing this C code
Writing this C code involves a few subtleties which deser
ve
involves a few subtleties which deserve their own respecti
ve
their own respective
sections.
sections.
Main function
Main function
-------------
-------------
If you pass a function name to the ``__init__()`` method of the ``COp`` class, it must respect the following constraints:
If you pass a function name to the ``__init__()`` method of the
``COp`` class, it must respect the following constraints:
* It must return an int. The value of that int indicates whether
* It must return an int. The value of that int indicates whether
the op could perform its task or not. A value of 0 indicates
the op could perform its task or not. A value of 0 indicates
...
@@ -852,13 +853,16 @@ If you pass a function name to the ``__init__()`` method of the ``COp`` class, i
...
@@ -852,13 +853,16 @@ If you pass a function name to the ``__init__()`` method of the ``COp`` class, i
must set a python exception indicating the details of the
must set a python exception indicating the details of the
problem.
problem.
* It must receive one argument for each input to the op followed by one
* It must receive one argument for each input to the op followed
pointer to an argument for each output of the op.
by one pointer to an argument for each output of the op. The
types for the argument is dependant on the Types (that is
theano Types) of your inputs and outputs.
For example, the main C function of an op that takes two arrays as
For example, the main C function of an op that takes two TensorTypes
inputs and returns both their sum and the difference between them
(which has ``PyArrayObject *`` as its C type) as inputs and returns
would have four parameters (two for the op's inputs and two for its
both their sum and the difference between them would have four
outputs) and it's signature would look something like this :
parameters (two for the op's inputs and two for its outputs) and it's
signature would look something like this :
.. code-block:: c
.. code-block:: c
...
@@ -870,7 +874,7 @@ Macros
...
@@ -870,7 +874,7 @@ Macros
For certain section tags, your C code can benefit from a number of
For certain section tags, your C code can benefit from a number of
pre-defined macros. These section tags have no macros: ``init_code``,
pre-defined macros. These section tags have no macros: ``init_code``,
``
c_
support_code``. All other tags will have the support macros
``support_code``. All other tags will have the support macros
discussed below.
discussed below.
* ``APPLY_SPECIFIC(str)`` which will automatically append a name
* ``APPLY_SPECIFIC(str)`` which will automatically append a name
...
@@ -905,7 +909,7 @@ In the same way, the macros ``DTYPE_OUTPUT_{i}``,
...
@@ -905,7 +909,7 @@ In the same way, the macros ``DTYPE_OUTPUT_{i}``,
every output 'i' of the op.
every output 'i' of the op.
In addition to these macros, the ``init_code_struct``, ``code``, and
In addition to these macros, the ``init_code_struct``, ``code``, and
``code_cleanup`` also have the following macros:
``code_cleanup``
section tags
also have the following macros:
* ``FAIL`` : Code to insert at error points. A python exception
* ``FAIL`` : Code to insert at error points. A python exception
should be set prior to this code. An invocation look like this:
should be set prior to this code. An invocation look like this:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论