Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
454ae317
Unverified
提交
454ae317
authored
11月 19, 2020
作者:
Junpeng Lao
提交者:
GitHub
11月 19, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement a Jax conversion for the Second Op (#185)
上级
30be6347
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
23 行增加
和
1 行删除
+23
-1
test_jax.py
tests/sandbox/test_jax.py
+14
-0
jaxify.py
theano/sandbox/jaxify.py
+9
-1
没有找到文件。
tests/sandbox/test_jax.py
浏览文件 @
454ae317
...
@@ -696,6 +696,20 @@ def test_identity():
...
@@ -696,6 +696,20 @@ def test_identity():
compare_jax_and_py
(
fgraph
,
[
get_test_value
(
i
)
for
i
in
fgraph
.
inputs
])
compare_jax_and_py
(
fgraph
,
[
get_test_value
(
i
)
for
i
in
fgraph
.
inputs
])
def
test_second
():
a0
=
tt
.
scalar
(
"a0"
)
b
=
tt
.
scalar
(
"b"
)
out
=
theano
.
scalar
.
basic
.
second
(
a0
,
b
)
fgraph
=
theano
.
gof
.
FunctionGraph
([
a0
,
b
],
[
out
])
compare_jax_and_py
(
fgraph
,
[
10.0
,
5.0
])
a1
=
tt
.
vector
(
"a1"
)
out
=
tt
.
second
(
a1
,
b
)
fgraph
=
theano
.
gof
.
FunctionGraph
([
a1
,
b
],
[
out
])
compare_jax_and_py
(
fgraph
,
[
np
.
zeros
([
5
],
dtype
=
theano
.
config
.
floatX
),
5.0
])
def
test_shared
():
def
test_shared
():
a
=
theano
.
shared
(
np
.
array
([
1
,
2
,
3
],
dtype
=
theano
.
config
.
floatX
))
a
=
theano
.
shared
(
np
.
array
([
1
,
2
,
3
],
dtype
=
theano
.
config
.
floatX
))
...
...
theano/sandbox/jaxify.py
浏览文件 @
454ae317
...
@@ -19,7 +19,7 @@ from theano.compile.ops import (
...
@@ -19,7 +19,7 @@ from theano.compile.ops import (
)
)
from
theano.gof
import
FunctionGraph
from
theano.gof
import
FunctionGraph
from
theano.ifelse
import
IfElse
from
theano.ifelse
import
IfElse
from
theano.scalar.basic
import
Cast
,
Clip
,
Composite
,
Identity
,
ScalarOp
from
theano.scalar.basic
import
Cast
,
Clip
,
Composite
,
Identity
,
ScalarOp
,
Second
from
theano.scan.op
import
Scan
from
theano.scan.op
import
Scan
from
theano.scan.utils
import
scan_args
as
ScanArgs
from
theano.scan.utils
import
scan_args
as
ScanArgs
from
theano.tensor.basic
import
(
from
theano.tensor.basic
import
(
...
@@ -256,6 +256,14 @@ def jax_funcify_ScalarSoftplus(op):
...
@@ -256,6 +256,14 @@ def jax_funcify_ScalarSoftplus(op):
return
scalarsoftplus
return
scalarsoftplus
@jax_funcify.register
(
Second
)
def
jax_funcify_Second
(
op
):
def
second
(
x
,
y
):
return
jnp
.
broadcast_to
(
y
,
x
.
shape
)
return
second
@jax_funcify.register
(
AllocEmpty
)
@jax_funcify.register
(
AllocEmpty
)
def
jax_funcify_AllocEmpty
(
op
):
def
jax_funcify_AllocEmpty
(
op
):
def
allocempty
(
*
shape
):
def
allocempty
(
*
shape
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论