Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b6494726
提交
b6494726
authored
6月 03, 2021
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
6月 04, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix Numba conversion of Switch
上级
7a6c42e6
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
16 行增加
和
0 行删除
+16
-0
dispatch.py
aesara/link/numba/dispatch.py
+10
-0
test_numba.py
tests/link/test_numba.py
+6
-0
没有找到文件。
aesara/link/numba/dispatch.py
浏览文件 @
b6494726
...
@@ -35,6 +35,7 @@ from aesara.scalar.basic import (
...
@@ -35,6 +35,7 @@ from aesara.scalar.basic import (
Scalar
,
Scalar
,
ScalarOp
,
ScalarOp
,
Second
,
Second
,
Switch
,
)
)
from
aesara.scalar.math
import
Softplus
from
aesara.scalar.math
import
Softplus
from
aesara.tensor.basic
import
(
from
aesara.tensor.basic
import
(
...
@@ -371,6 +372,15 @@ def {scalar_op_fn_name}({input_names}):
...
@@ -371,6 +372,15 @@ def {scalar_op_fn_name}({input_names}):
return
numba
.
njit
(
scalar_op_fn
)
return
numba
.
njit
(
scalar_op_fn
)
@numba_funcify.register
(
Switch
)
def
numba_funcify_Switch
(
op
,
node
,
**
kwargs
):
@numba.njit
def
switch
(
condition
,
x
,
y
):
return
x
if
np
.
all
(
condition
)
else
y
return
switch
@numba_funcify.register
(
Elemwise
)
@numba_funcify.register
(
Elemwise
)
def
numba_funcify_Elemwise
(
op
,
node
,
use_signature
=
False
,
identity
=
None
,
**
kwargs
):
def
numba_funcify_Elemwise
(
op
,
node
,
use_signature
=
False
,
identity
=
None
,
**
kwargs
):
scalar_op_fn
=
numba_funcify
(
op
.
scalar_op
,
node
,
**
kwargs
)
scalar_op_fn
=
numba_funcify
(
op
.
scalar_op
,
node
,
**
kwargs
)
...
...
tests/link/test_numba.py
浏览文件 @
b6494726
...
@@ -285,6 +285,12 @@ def test_create_numba_signature(v, expected, force_scalar):
...
@@ -285,6 +285,12 @@ def test_create_numba_signature(v, expected, force_scalar):
[
np
.
random
.
randn
(
100
)
.
astype
(
config
.
floatX
)
for
i
in
range
(
4
)],
[
np
.
random
.
randn
(
100
)
.
astype
(
config
.
floatX
)
for
i
in
range
(
4
)],
lambda
x
,
y
,
x1
,
y1
:
(
x
+
y
)
*
(
x1
+
y1
)
*
y
,
lambda
x
,
y
,
x1
,
y1
:
(
x
+
y
)
*
(
x1
+
y1
)
*
y
,
),
),
(
# This also tests the use of repeated arguments
[
aet
.
matrix
(),
aet
.
scalar
()],
[
np
.
random
.
normal
(
size
=
(
2
,
2
))
.
astype
(
config
.
floatX
),
0.0
],
lambda
a
,
b
:
aet
.
switch
(
a
,
b
,
a
),
),
],
],
)
)
def
test_Elemwise
(
inputs
,
input_vals
,
output_fn
):
def
test_Elemwise
(
inputs
,
input_vals
,
output_fn
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论