Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
6700dcdf
提交
6700dcdf
authored
3月 13, 2021
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
3月 18, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Create custom CompileError that prints compilation output correctly
上级
1ee6f62c
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
26 行增加
和
6 行删除
+26
-6
cmodule.py
aesara/link/c/cmodule.py
+4
-4
exceptions.py
aesara/link/c/exceptions.py
+12
-0
test_cmodule.py
tests/link/c/test_cmodule.py
+10
-2
没有找到文件。
aesara/link/c/cmodule.py
浏览文件 @
6700dcdf
...
@@ -28,7 +28,7 @@ import aesara
...
@@ -28,7 +28,7 @@ import aesara
# we will abuse the lockfile mechanism when reading and writing the registry
# we will abuse the lockfile mechanism when reading and writing the registry
from
aesara.compile.compilelock
import
lock_ctx
from
aesara.compile.compilelock
import
lock_ctx
from
aesara.configdefaults
import
config
,
gcc_version_str
from
aesara.configdefaults
import
config
,
gcc_version_str
from
aesara.link.c.exceptions
import
MissingGXX
from
aesara.link.c.exceptions
import
CompileError
,
MissingGXX
from
aesara.utils
import
(
from
aesara.utils
import
(
LOCAL_BITWIDTH
,
LOCAL_BITWIDTH
,
flatten
,
flatten
,
...
@@ -2543,9 +2543,9 @@ class GCC_compiler(Compiler):
...
@@ -2543,9 +2543,9 @@ class GCC_compiler(Compiler):
# We replace '\n' by '. ' in the error message because when Python
# We replace '\n' by '. ' in the error message because when Python
# prints the exception, having '\n' in the text makes it more
# prints the exception, having '\n' in the text makes it more
# difficult to read.
# difficult to read.
compile_stderr
=
compile_stderr
.
replace
(
"
\n
"
,
". "
)
#
compile_stderr = compile_stderr.replace("\n", ". ")
raise
Exception
(
raise
CompileError
(
f
"Compilation failed (return status={status}):
{compile_stderr}"
f
"Compilation failed (return status={status}):
\n
{' '.join(cmd)}
\n
{compile_stderr}"
)
)
elif
config
.
cmodule__compilation_warning
and
compile_stderr
:
elif
config
.
cmodule__compilation_warning
and
compile_stderr
:
# Print errors just below the command line.
# Print errors just below the command line.
...
...
aesara/link/c/exceptions.py
浏览文件 @
6700dcdf
from
distutils.errors
import
CompileError
as
BaseCompileError
class
MissingGXX
(
Exception
):
class
MissingGXX
(
Exception
):
"""
"""
This error is raised when we try to generate c code,
This error is raised when we try to generate c code,
but g++ is not available.
but g++ is not available.
"""
"""
class
CompileError
(
BaseCompileError
):
"""This custom `Exception` prints compilation errors with their original
formatting.
"""
def
__str__
(
self
):
return
self
.
args
[
0
]
tests/link/c/test_cmodule.py
浏览文件 @
6700dcdf
...
@@ -4,18 +4,21 @@ We don't have real tests for the cache, but it would be great to make them!
...
@@ -4,18 +4,21 @@ We don't have real tests for the cache, but it would be great to make them!
But this one tests a current behavior that isn't good: the c_code isn't
But this one tests a current behavior that isn't good: the c_code isn't
deterministic based on the input type and the op.
deterministic based on the input type and the op.
"""
"""
import
logging
import
logging
import
tempfile
from
unittest.mock
import
patch
from
unittest.mock
import
patch
import
numpy
as
np
import
numpy
as
np
import
pytest
import
aesara
import
aesara
from
aesara.compile.ops
import
DeepCopyOp
from
aesara.link.c.cmodule
import
GCC_compiler
,
default_blas_ldflags
from
aesara.link.c.cmodule
import
GCC_compiler
,
default_blas_ldflags
from
aesara.link.c.exceptions
import
CompileError
from
aesara.tensor.type
import
dvectors
from
aesara.tensor.type
import
dvectors
class
MyOp
(
aesara
.
compile
.
ops
.
DeepCopyOp
):
class
MyOp
(
DeepCopyOp
):
nb_called
=
0
nb_called
=
0
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
...
@@ -37,6 +40,11 @@ class MyOp(aesara.compile.ops.DeepCopyOp):
...
@@ -37,6 +40,11 @@ class MyOp(aesara.compile.ops.DeepCopyOp):
)
)
def
test_compiler_error
():
with
pytest
.
raises
(
CompileError
),
tempfile
.
TemporaryDirectory
()
as
dir_name
:
GCC_compiler
.
compile_str
(
"module_name"
,
"blah"
,
location
=
dir_name
)
def
test_inter_process_cache
():
def
test_inter_process_cache
():
# When an op with c_code, but no version. If we have 2 apply node
# When an op with c_code, but no version. If we have 2 apply node
# in the graph with different inputs variable(so they don't get
# in the graph with different inputs variable(so they don't get
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论