Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b1fc6111
提交
b1fc6111
authored
9月 30, 2014
作者:
Pierre Luc Carrier
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Document NumPy C-API data types
上级
ab258c60
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
25 行增加
和
2 行删除
+25
-2
extending_theano_c.txt
doc/tutorial/extending_theano_c.txt
+25
-2
没有找到文件。
doc/tutorial/extending_theano_c.txt
浏览文件 @
b1fc6111
...
@@ -90,7 +90,28 @@ require interaction with the NumPy C-API.
...
@@ -90,7 +90,28 @@ require interaction with the NumPy C-API.
This sections covers the API's elements that are often required to write code
This sections covers the API's elements that are often required to write code
for a Theano C op. The full documentation for the API can be found here :
for a Theano C op. The full documentation for the API can be found here :
`NumPy C-API <http://docs.scipy.org/doc/numpy/reference/c-api.html>`_
`NumPy C-API <http://docs.scipy.org/doc/numpy/reference/c-api.html>`_.
NumPy data types
----------------
To allow portability between platforms, the NumPy C-API defines its own data
types which should be used whenever you are manipulating a NumPy array's
internal data. The data types most commonly used to implement C ops are the
following : ``npy_int{8,16,32,64}``, ``npy_uint{8,16,32,64}`` and
``npy_float{32,64}``.
You should use these data types when manipulating a NumPy array's internal
data instead of C primitives because the size of the memory representation
for C primitives can vary between platforms. For instance, a C ``long`` can be
represented in memory with 4 bytes but it can also be represented with 8.
On the other hand, the in-memory size of NumPy data types remains constant
across platforms. Using them will make your code simpler and more portable.
The full list of defined data types can be found here :
`NumPy C-API data types
<http://docs.scipy.org/doc/numpy/reference/c-api.dtype.html#c-type-names>`_.
NumPy ndarrays
NumPy ndarrays
...
@@ -140,7 +161,9 @@ The following macros serve to access various attributes of NumPy ndarrays.
...
@@ -140,7 +161,9 @@ The following macros serve to access various attributes of NumPy ndarrays.
.. method:: void* PyArray_DATA(PyArrayObject* arr)
.. method:: void* PyArray_DATA(PyArrayObject* arr)
Returns a pointer to the first element of the array's data.
Returns a pointer to the first element of the array's data. The returned
pointer must be cast to a pointer of the proper Numpy C-API data type
before use.
.. method:: int PyArray_NDIM(PyArrayObject* arr)
.. method:: int PyArray_NDIM(PyArrayObject* arr)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论