Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b1fa49f1
提交
b1fa49f1
authored
1月 24, 2008
作者:
olivier@olivier-desktop
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
finalized a decent version of elemwise
上级
c40eadf8
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
46 行增加
和
10 行删除
+46
-10
core.py
core.py
+0
-0
cutils.py
cutils.py
+28
-0
lib.py
gof/lib.py
+5
-2
type_spec.py
type_spec.py
+13
-8
没有找到文件。
core.py
浏览文件 @
b1fa49f1
差异被折叠。
点击展开。
cutils.py
0 → 100644
浏览文件 @
b1fa49f1
try
:
from
cutils_ext
import
*
except
ImportError
:
from
scipy
import
weave
single_runner
=
"""
if (!PyCObject_Check(py_cthunk)) {
PyErr_SetString(PyExc_ValueError,
"Argument to run_cthunk must be a PyCObject returned by the c_thunk method of an omega_op.");
return NULL;
}
int (*fn)(void*) = reinterpret_cast<int (*)(void*)>(PyCObject_AsVoidPtr(py_cthunk));
void* it = PyCObject_GetDesc(py_cthunk);
int failure = fn(it);
if (failure) {
return NULL;
}
"""
cthunk
=
object
()
mod
=
weave
.
ext_tools
.
ext_module
(
'cutils_ext'
)
mod
.
add_function
(
weave
.
ext_tools
.
ext_function
(
'run_cthunk'
,
single_runner
,
[
'cthunk'
]))
mod
.
compile
()
from
cutils_ext
import
*
gof/lib.py
浏览文件 @
b1fa49f1
...
@@ -238,7 +238,7 @@ class PythonOp(Op):
...
@@ -238,7 +238,7 @@ class PythonOp(Op):
if
input
not
in
exc
:
if
input
not
in
exc
:
self
.
check_input
(
input
)
self
.
check_input
(
input
)
try
:
try
:
results
=
self
.
impl
(
*
[
input
.
data
for
input
in
self
.
inputs
]
)
results
=
self
.
_impl
(
)
except
Exception
,
e
:
except
Exception
,
e
:
print
"Error in
%
s:
%
s"
%
(
self
,
e
)
print
"Error in
%
s:
%
s"
%
(
self
,
e
)
raise
raise
...
@@ -250,7 +250,7 @@ class PythonOp(Op):
...
@@ -250,7 +250,7 @@ class PythonOp(Op):
output
.
set_value
(
result
)
output
.
set_value
(
result
)
def
_perform
(
self
):
def
_perform
(
self
):
results
=
self
.
impl
(
*
[
input
.
data
for
input
in
self
.
inputs
]
)
results
=
self
.
_impl
(
)
if
self
.
nout
==
1
:
if
self
.
nout
==
1
:
self
.
out
.
set_value
(
results
)
self
.
out
.
set_value
(
results
)
else
:
else
:
...
@@ -267,6 +267,9 @@ class PythonOp(Op):
...
@@ -267,6 +267,9 @@ class PythonOp(Op):
raise
Exception
(
"Uncomputed input:
%
s in
%
s"
%
(
input
,
self
))
raise
Exception
(
"Uncomputed input:
%
s in
%
s"
%
(
input
,
self
))
self
.
perform
()
self
.
perform
()
def
_impl
(
self
):
return
self
.
impl
(
*
[
input
.
data
for
input
in
self
.
inputs
])
def
impl
(
*
args
):
def
impl
(
*
args
):
raise
NotImplementedError
(
"This op has no implementation."
)
raise
NotImplementedError
(
"This op has no implementation."
)
...
...
type_spec.py
浏览文件 @
b1fa49f1
...
@@ -13,28 +13,33 @@ class omega_type_converter_extension:
...
@@ -13,28 +13,33 @@ class omega_type_converter_extension:
return
[(
tvars
[
'c_type'
],
tvars
[
'name'
],
tvars
[
'var_convert'
])]
return
[(
tvars
[
'c_type'
],
tvars
[
'name'
],
tvars
[
'var_convert'
])]
def
format_provide
(
self
,
x
):
def
format_provide
(
self
,
x
):
return
'
%
s
%
s =
%
s;'
%
x
return
'
%
s
%
s =
%
s;
\n
'
%
x
def
declaration_code
(
self
,
templatize
=
0
,
inline
=
0
):
def
declaration_code
(
self
,
templatize
=
0
,
inline
=
0
):
tvars
=
self
.
template_vars
(
inline
=
inline
)
tvars
=
self
.
template_vars
(
inline
=
inline
)
code
=
'
%(py_var)
s =
%(var_lookup)
s;
\n
'
%
tvars
code
=
'
%(py_var)
s =
%(var_lookup)
s;
\n
'
%
tvars
code
+=
'
\n
'
.
join
([
self
.
format_provide
(
export
)
for
export
in
self
.
provides
()])
code
+=
''
.
join
([
self
.
format_provide
(
export
)
for
export
in
self
.
provides
()])
return
code
return
code
def
struct_init_code
(
self
):
return
"Py_INCREF(py_
%
s);"
%
self
.
name
def
struct_cleanup_code
(
self
):
return
"Py_DECREF(py_
%
s);"
%
self
.
name
def
struct_members_code
(
self
):
def
struct_members_code
(
self
):
return
'
\n
'
.
join
([
'
%
s_type
%
s;'
%
(
name
,
name
)
for
c_type
,
name
,
init
in
self
.
provides
()])
res
=
"PyObject* py_
%
s;
\n
"
%
self
.
name
return
res
+
''
.
join
([
'
%
s_type
%
s;
\n
'
%
(
name
,
name
)
for
c_type
,
name
,
init
in
self
.
provides
()])
def
struct_import_code
(
self
):
def
struct_import_code
(
self
):
return
'
\n
'
.
join
([
'__STRUCT_P->
%
s =
%
s;'
%
(
name
,
name
)
for
c_type
,
name
,
init
in
self
.
provides
()])
res
=
"__STRUCT_P->py_
%
s = py_
%
s;
\n
"
%
(
self
.
name
,
self
.
name
)
return
res
+
''
.
join
([
'__STRUCT_P->
%
s =
%
s;
\n
'
%
(
name
,
name
)
for
c_type
,
name
,
init
in
self
.
provides
()])
def
struct_support_code
(
self
):
def
struct_support_code
(
self
):
return
""
return
""
def
struct_typedefs
(
self
):
def
struct_typedefs
(
self
):
return
"
\n
"
.
join
([
"typedef
%
s
%
s_type;"
%
(
c_type
,
name
)
for
c_type
,
name
,
init
in
self
.
provides
()])
return
''
.
join
([
"typedef
%
s
%
s_type;
\n
"
%
(
c_type
,
name
)
for
c_type
,
name
,
init
in
self
.
provides
()])
# def struct_template_types(self):
# return [("typename %s_type" % name, ) for c_type, name, init in self.provides()]
class
int_converter
(
omega_type_converter_extension
,
c_spec
.
int_converter
):
class
int_converter
(
omega_type_converter_extension
,
c_spec
.
int_converter
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论