Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
6b197857
提交
6b197857
authored
7月 31, 2017
作者:
Thomas George
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
AllocEmpty now uses param
上级
8a41c6fb
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
14 行增加
和
5 行删除
+14
-5
basic_ops.py
theano/gpuarray/basic_ops.py
+4
-1
basic.py
theano/tensor/basic.py
+10
-4
没有找到文件。
theano/gpuarray/basic_ops.py
浏览文件 @
6b197857
...
...
@@ -970,7 +970,10 @@ class GpuAllocEmpty(HideC, AllocEmpty):
def
__init__
(
self
,
dtype
,
context_name
):
self
.
dtype
=
dtype
self
.
context_name
=
context_name
self
.
typecode
=
gpuarray
.
dtype_to_typecode
(
self
.
dtype
)
@property
def
typecode
(
self
):
return
gpuarray
.
dtype_to_typecode
(
self
.
dtype
)
def
get_params
(
self
,
node
):
return
self
.
params_type
.
get_params
(
context
=
get_context
(
self
.
context_name
),
...
...
theano/tensor/basic.py
浏览文件 @
6b197857
...
...
@@ -17,6 +17,7 @@ from theano import gof
from
theano.gof
import
Apply
,
Constant
,
Op
,
Variable
,
ParamsType
from
theano.gof.type
import
Generic
from
theano.scalar
import
int32
as
int32_t
from
theano.tensor
import
elemwise
from
theano.tensor.var
import
(
AsTensorError
,
TensorVariable
,
TensorConstant
,
TensorConstantSignature
,
...
...
@@ -6632,13 +6633,18 @@ class Choose(Op):
class
AllocEmpty
(
gof
.
Op
):
"""Implement Alloc on the cpu, but without initializing memory."""
__props__
=
(
"dtype"
,)
__props__
=
(
"dtype"
,
"typecode"
)
params_type
=
ParamsType
(
typecode
=
int32_t
)
# specify the type of the data
def
__init__
(
self
,
dtype
):
assert
isinstance
(
dtype
,
str
),
dtype
self
.
dtype
=
dtype
.
lower
()
@property
def
typecode
(
self
):
return
np
.
dtype
(
self
.
dtype
)
.
num
def
make_node
(
self
,
*
shape
):
shape
,
bcast
=
alloc_validate_shape
(
shape
)
otype
=
TensorType
(
dtype
=
self
.
dtype
,
broadcastable
=
bcast
)
...
...
@@ -6668,11 +6674,11 @@ class AllocEmpty(gof.Op):
out
[
0
]
=
np
.
empty
(
sh
,
dtype
=
self
.
dtype
)
def
c_code
(
self
,
node
,
name
,
inputs
,
out_
,
sub
):
dtype
=
"NPY_"
+
self
.
dtype
.
upper
()
out
,
=
out_
fail
=
sub
[
'fail'
]
shps
=
inputs
nd
=
len
(
shps
)
params
=
sub
[
'params'
]
str
=
"npy_intp dims[
%(nd)
s];
\n
"
%
locals
()
for
idx
,
sh
in
enumerate
(
shps
):
str
+=
"dims[
%(idx)
s] ="
\
...
...
@@ -6691,7 +6697,7 @@ class AllocEmpty(gof.Op):
Py_XDECREF(
%(out)
s);
%(out)
s = (PyArrayObject*)PyArray_EMPTY(
%(nd)
s,
dims,
%(
dtype)
s
,
%(
params)
s->typecode
,
0);
if (!
%(out)
s)
{
...
...
@@ -6706,7 +6712,7 @@ class AllocEmpty(gof.Op):
return
[
node
.
inputs
]
def
c_code_cache_version
(
self
):
return
(
3
,)
return
(
4
,)
def
do_constant_folding
(
self
,
node
):
return
False
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论