Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f5c82cdc
提交
f5c82cdc
authored
4月 10, 2008
作者:
bergstrj@iro.umontreal.ca
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
moved elemwise2 to elemwise
上级
c7db795f
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
191 行增加
和
259 行删除
+191
-259
_test_elemwise.py
_test_elemwise.py
+188
-46
_test_elemwise2.py
_test_elemwise2.py
+0
-210
_test_tensor.py
_test_tensor.py
+1
-1
elemwise.py
elemwise.py
+0
-0
opt.py
opt.py
+1
-1
tensor.py
tensor.py
+1
-1
没有找到文件。
_test_elemwise.py
浏览文件 @
f5c82cdc
import
time
import
unittest
import
numpy
from
tensor
import
astensor
,
Tensor
from
gof
import
ResultBase
,
Op
,
Env
,
modes
import
gof
from
gof
import
modes
,
Env
from
elemwise
import
*
class
ElemwiseAdd
(
Elemwise
):
def
__init__
(
self
,
x
,
y
):
self
.
inputs
=
(
x
,
y
)
self
.
outputs
=
[
Tensor
(
dtype
=
x
.
dtype
,
broadcastable
=
x
.
broadcastable
)]
def
var_desc
(
self
):
return
[(
'x'
,
1
),
(
'y'
,
1
)],
[(
'z'
,
1
)]
# def destroy_map(self):
# return {self.out: [self.inputs[0]]}
from
scalar
import
*
def
c_code_foreach
(
self
):
return
"
%(z)
s_i =
%(x)
s_i +
%(y)
s_i;"
from
elemwise
import
*
def
inputs
():
l1
=
[[
1.0
,
2.0
],
[
3.0
,
4.0
]]
l2
=
[[
3.0
,
4.0
],
[
1.0
,
2.0
]]
l3
=
numpy
.
ones
((
2
,
3
))
x
=
modes
.
build
(
astensor
(
l1
,
name
=
'x'
))
y
=
modes
.
build
(
astensor
(
l2
,
name
=
'y'
))
z
=
modes
.
build
(
astensor
(
l3
,
name
=
'z'
))
x
=
modes
.
build
(
Tensor
(
'float64'
,
(
0
,
0
),
name
=
'x'
))
y
=
modes
.
build
(
Tensor
(
'float64'
,
(
1
,
0
),
name
=
'y'
))
z
=
modes
.
build
(
Tensor
(
'float64'
,
(
0
,
0
),
name
=
'z'
))
return
x
,
y
,
z
def
env
(
inputs
,
outputs
,
validate
=
True
,
features
=
[]):
return
Env
(
inputs
,
outputs
,
features
=
features
,
consistency_check
=
validate
)
class
_test_
Elemwis
e
(
unittest
.
TestCase
):
class
_test_
DimShuffl
e
(
unittest
.
TestCase
):
def
test_0
(
self
):
x
,
y
,
z
=
inputs
()
e
=
ElemwiseAdd
(
x
,
y
)
.
out
fn
,
i
,
o
=
gof
.
CLinker
(
env
([
x
,
y
],
[
e
]))
.
make_thunk
(
True
)
fn
()
assert
(
e
.
data
==
numpy
.
array
([[
4
,
6
],
[
4
,
6
]]))
.
all
()
x
.
data
.
resize
((
1
,
4
))
y
.
data
.
resize
((
1
,
4
))
fn
()
assert
(
e
.
data
==
numpy
.
array
([[
4
,
6
,
4
,
6
]]))
.
all
()
def
with_linker
(
self
,
linker
):
for
xsh
,
shuffle
,
zsh
in
[((
2
,
3
),
(
1
,
'x'
,
0
),
(
3
,
1
,
2
)),
((
1
,
2
,
3
),
(
1
,
2
),
(
2
,
3
)),
((
1
,
2
,
1
,
3
),
(
1
,
3
),
(
2
,
3
)),
((
2
,
3
,
4
),
(
2
,
1
,
0
),
(
4
,
3
,
2
)),
((
2
,
3
,
4
),
(
'x'
,
2
,
1
,
0
,
'x'
),
(
1
,
4
,
3
,
2
,
1
)),
((
1
,
4
,
3
,
2
,
1
),
(
3
,
2
,
1
),
(
2
,
3
,
4
)),
((
1
,
1
,
4
),
(
1
,
2
),
(
1
,
4
))]:
x
=
modes
.
build
(
Tensor
(
'float64'
,
[
1
*
(
entry
==
1
)
for
entry
in
xsh
],
name
=
'x'
))
e
=
DimShuffle
(
x
,
shuffle
)
.
out
# print shuffle, e.owner.grad(e.owner.inputs, e.owner.outputs).owner.new_order
f
=
linker
(
env
([
x
],
[
e
]))
.
make_function
(
inplace
=
False
)
assert
f
(
numpy
.
ones
(
xsh
))
.
shape
==
zsh
# def test_1(self):
# x, y, z = inputs()
# e = ElemwiseAdd(x, y).out
# fn, i, o = gof.CLinker(env([x, y], [e])).make_thunk(True)
# fn()
# assert (e.data == numpy.array([[4, 6], [4, 6]])).all()
# x.data.resize((1, 4))
# y.data.resize((1, 4))
# fn()
# assert (e.data == numpy.array([[4, 6, 4, 6]])).all()
def
test_perform
(
self
):
self
.
with_linker
(
gof
.
PerformLinker
)
# def test_straightforward(self):
# x, y, z = inputs()
# e0 = DimShuffle(x, [1, 'x', 0]).out
# f = gof.PerformLinker(env([x], [e0])).make_function(inplace=True)
# assert f(numpy.ones((2, 3))).shape == (3, 1, 2)
class
_test_Broadcast
(
unittest
.
TestCase
):
def
with_linker
(
self
,
linker
):
for
xsh
,
ysh
in
[((
3
,
5
),
(
3
,
5
)),
((
3
,
5
),
(
1
,
5
)),
((
3
,
5
),
(
3
,
1
)),
((
1
,
5
),
(
5
,
1
)),
((
1
,
1
),
(
1
,
1
)),
((
2
,
3
,
4
,
5
),
(
2
,
3
,
4
,
5
)),
((
2
,
3
,
4
,
5
),
(
1
,
3
,
1
,
5
)),
((
2
,
3
,
4
,
5
),
(
1
,
1
,
1
,
1
)),
((),
())]:
x
=
modes
.
build
(
Tensor
(
'float64'
,
[
1
*
(
entry
==
1
)
for
entry
in
xsh
],
name
=
'x'
))
y
=
modes
.
build
(
Tensor
(
'float64'
,
[
1
*
(
entry
==
1
)
for
entry
in
ysh
],
name
=
'y'
))
e
=
Broadcast
(
Add
,
(
x
,
y
))
.
out
f
=
linker
(
env
([
x
,
y
],
[
e
]))
.
make_function
(
inplace
=
False
)
# xv = numpy.array(range(numpy.product(xsh)))
# xv = xv.reshape(xsh)
# yv = numpy.array(range(numpy.product(ysh)))
# yv = yv.reshape(ysh)
xv
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
*
xsh
))
yv
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
*
ysh
))
zv
=
xv
+
yv
# print "AAAAAAAAAAAAAAAAAA"
# print f(xv, yv)
# print zv
# print "BBBBBBBBBBBBBBBBBB"
self
.
failUnless
((
f
(
xv
,
yv
)
==
zv
)
.
all
())
def
with_linker_inplace
(
self
,
linker
):
for
xsh
,
ysh
in
[((
5
,
5
),
(
5
,
5
)),
((
5
,
5
),
(
1
,
5
)),
((
5
,
5
),
(
5
,
1
)),
((
1
,
1
),
(
1
,
1
)),
((
2
,
3
,
4
,
5
),
(
2
,
3
,
4
,
5
)),
((
2
,
3
,
4
,
5
),
(
1
,
3
,
1
,
5
)),
((
2
,
3
,
4
,
5
),
(
1
,
1
,
1
,
1
)),
((),
())]:
x
=
modes
.
build
(
Tensor
(
'float64'
,
[
1
*
(
entry
==
1
)
for
entry
in
xsh
],
name
=
'x'
))
y
=
modes
.
build
(
Tensor
(
'float64'
,
[
1
*
(
entry
==
1
)
for
entry
in
ysh
],
name
=
'y'
))
e
=
Broadcast
(
Add
,
(
x
,
y
),
{
0
:
0
})
.
out
f
=
linker
(
env
([
x
,
y
],
[
e
]))
.
make_function
(
inplace
=
False
)
xv
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
*
xsh
))
yv
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
*
ysh
))
zv
=
xv
+
yv
f
(
xv
,
yv
)
self
.
failUnless
((
xv
==
zv
)
.
all
())
def
test_perform
(
self
):
self
.
with_linker
(
gof
.
PerformLinker
)
def
test_c
(
self
):
self
.
with_linker
(
gof
.
CLinker
)
def
test_perform_inplace
(
self
):
self
.
with_linker_inplace
(
gof
.
PerformLinker
)
def
test_c_inplace
(
self
):
self
.
with_linker_inplace
(
gof
.
CLinker
)
def
test_fill
(
self
):
x
=
modes
.
build
(
Tensor
(
'float64'
,
[
0
,
0
],
name
=
'x'
))
y
=
modes
.
build
(
Tensor
(
'float64'
,
[
1
,
1
],
name
=
'y'
))
e
=
Broadcast
(
Second
,
(
x
,
y
),
{
0
:
0
})
.
out
f
=
gof
.
CLinker
(
env
([
x
,
y
],
[
e
]))
.
make_function
(
inplace
=
False
)
xv
=
numpy
.
ones
((
5
,
5
))
yv
=
numpy
.
random
.
rand
(
1
,
1
)
f
(
xv
,
yv
)
assert
(
xv
==
yv
)
.
all
()
class
_test_CAReduce
(
unittest
.
TestCase
):
def
with_linker
(
self
,
linker
):
for
xsh
,
tosum
in
[((
5
,
6
),
(
0
,
1
)),
((
5
,
6
),
(
0
,
)),
((
5
,
6
),
(
1
,
)),
((
5
,
6
),
()),
((
2
,
3
,
4
,
5
),
(
0
,
1
,
3
)),
((),
())]:
x
=
modes
.
build
(
Tensor
(
'float64'
,
[
1
*
(
entry
==
1
)
for
entry
in
xsh
],
name
=
'x'
))
e
=
CAReduce
(
Add
,
[
x
],
dimensions_to_reduce
=
tosum
)
.
out
f
=
linker
(
env
([
x
],
[
e
]))
.
make_function
(
inplace
=
False
)
xv
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
*
xsh
))
zv
=
xv
for
axis
in
reversed
(
sorted
(
tosum
)):
zv
=
numpy
.
add
.
reduce
(
zv
,
axis
)
# print "AAAAAAAAAAAAAAAAAA"
# print xsh, tosum
# print f(xv)
# print zv
# print f(xv) - zv
# print "BBBBBBBBBBBBBBBBBB"
self
.
failUnless
((
numpy
.
abs
(
f
(
xv
)
-
zv
)
<
1e-10
)
.
all
())
def
test_perform
(
self
):
self
.
with_linker
(
gof
.
PerformLinker
)
def
test_c
(
self
):
self
.
with_linker
(
gof
.
CLinker
)
if
__name__
==
'__main__'
:
unittest
.
main
()
# x = modes.build(Tensor('float64', [0, 0], name = 'x'))
# y = modes.build(Tensor('float64', [0, 0], name = 'y'))
# e = Broadcast(SquareDiff, (x, y), {0:0}).out
# f = gof.CLinker(env([x, y], [e])).make_function(inplace = False)
# xv = numpy.random.rand(1000, 1000)
# yv = numpy.random.rand(1000, 1000)
# zv = numpy.random.rand(1000, 1000)
# add = numpy.frompyfunc(lambda x, y: x + y, 2, 1)
# t0 = time.time()
# for i in xrange(100):
# xv -= yv
# xv *= xv
# # xv += yv
# print time.time() - t0
# t0 = time.time()
# for i in xrange(100):
# f(xv, yv)
# print time.time() - t0
# def test_straightforward(self):
# x, y, z = inputs()
# e0 = CAReduce(Add, [x]).out
# # print e0.owner
# f = gof.PerformLinker(env([x], [e0])).make_function(inplace=True)
# assert f(numpy.ones((2, 2))) == 4.0
##########
##########
# def test_straightforward(self):
# x, y, z = inputs()
# e0 = Broadcast(Add, (x, y)).out
# f = gof.PerformLinker(env([x, y], [e0])).make_function(inplace=True)
# assert (f(numpy.ones((2, 2)), numpy.ones((1, 2))) == numpy.ones((2, 2))*2).all()
# # for result in e0.owner.grad(e0.owner.inputs, (z, )):
# # print env([x, y, z], [result])
# def test_c(self):
# x = modes.build(Tensor('float64', (0, 0), name = 'x'))
# y = modes.build(Tensor('float64', (0, 1), name = 'y'))
# z = modes.build(Tensor('float64', (0, 0), name = 'z'))
# # x = modes.build(Tensor('float64', (), name = 'x'))
# # y = modes.build(Tensor('float64', (), name = 'y'))
# # x, y, z = inputs()
# e0 = Broadcast(Add, (x, y)).out
# f = gof.CLinker(env([x, y], [e0])).make_function(inplace=True)
# print f(numpy.ones((4, 4), order = 'f'), numpy.array([[1], [2], [3], [4]]))
# # print f(numpy.ones(()), numpy.ones(()))
# assert (f(numpy.ones((2, 2)), numpy.ones((2, 1))) == numpy.ones((2, 2))*2).all()
_test_elemwise2.py
deleted
100644 → 0
浏览文件 @
c7db795f
import
time
import
unittest
from
gof
import
ResultBase
,
Op
,
Env
,
modes
import
gof
from
scalar
import
*
from
elemwise2
import
*
def
inputs
():
x
=
modes
.
build
(
Tensor
(
'float64'
,
(
0
,
0
),
name
=
'x'
))
y
=
modes
.
build
(
Tensor
(
'float64'
,
(
1
,
0
),
name
=
'y'
))
z
=
modes
.
build
(
Tensor
(
'float64'
,
(
0
,
0
),
name
=
'z'
))
return
x
,
y
,
z
def
env
(
inputs
,
outputs
,
validate
=
True
,
features
=
[]):
return
Env
(
inputs
,
outputs
,
features
=
features
,
consistency_check
=
validate
)
class
_test_DimShuffle
(
unittest
.
TestCase
):
def
with_linker
(
self
,
linker
):
for
xsh
,
shuffle
,
zsh
in
[((
2
,
3
),
(
1
,
'x'
,
0
),
(
3
,
1
,
2
)),
((
1
,
2
,
3
),
(
1
,
2
),
(
2
,
3
)),
((
1
,
2
,
1
,
3
),
(
1
,
3
),
(
2
,
3
)),
((
2
,
3
,
4
),
(
2
,
1
,
0
),
(
4
,
3
,
2
)),
((
2
,
3
,
4
),
(
'x'
,
2
,
1
,
0
,
'x'
),
(
1
,
4
,
3
,
2
,
1
)),
((
1
,
4
,
3
,
2
,
1
),
(
3
,
2
,
1
),
(
2
,
3
,
4
)),
((
1
,
1
,
4
),
(
1
,
2
),
(
1
,
4
))]:
x
=
modes
.
build
(
Tensor
(
'float64'
,
[
1
*
(
entry
==
1
)
for
entry
in
xsh
],
name
=
'x'
))
e
=
DimShuffle
(
x
,
shuffle
)
.
out
# print shuffle, e.owner.grad(e.owner.inputs, e.owner.outputs).owner.new_order
f
=
linker
(
env
([
x
],
[
e
]))
.
make_function
(
inplace
=
False
)
assert
f
(
numpy
.
ones
(
xsh
))
.
shape
==
zsh
def
test_perform
(
self
):
self
.
with_linker
(
gof
.
PerformLinker
)
# def test_straightforward(self):
# x, y, z = inputs()
# e0 = DimShuffle(x, [1, 'x', 0]).out
# f = gof.PerformLinker(env([x], [e0])).make_function(inplace=True)
# assert f(numpy.ones((2, 3))).shape == (3, 1, 2)
class
_test_Broadcast
(
unittest
.
TestCase
):
def
with_linker
(
self
,
linker
):
for
xsh
,
ysh
in
[((
3
,
5
),
(
3
,
5
)),
((
3
,
5
),
(
1
,
5
)),
((
3
,
5
),
(
3
,
1
)),
((
1
,
5
),
(
5
,
1
)),
((
1
,
1
),
(
1
,
1
)),
((
2
,
3
,
4
,
5
),
(
2
,
3
,
4
,
5
)),
((
2
,
3
,
4
,
5
),
(
1
,
3
,
1
,
5
)),
((
2
,
3
,
4
,
5
),
(
1
,
1
,
1
,
1
)),
((),
())]:
x
=
modes
.
build
(
Tensor
(
'float64'
,
[
1
*
(
entry
==
1
)
for
entry
in
xsh
],
name
=
'x'
))
y
=
modes
.
build
(
Tensor
(
'float64'
,
[
1
*
(
entry
==
1
)
for
entry
in
ysh
],
name
=
'y'
))
e
=
Broadcast
(
Add
,
(
x
,
y
))
.
out
f
=
linker
(
env
([
x
,
y
],
[
e
]))
.
make_function
(
inplace
=
False
)
# xv = numpy.array(range(numpy.product(xsh)))
# xv = xv.reshape(xsh)
# yv = numpy.array(range(numpy.product(ysh)))
# yv = yv.reshape(ysh)
xv
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
*
xsh
))
yv
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
*
ysh
))
zv
=
xv
+
yv
# print "AAAAAAAAAAAAAAAAAA"
# print f(xv, yv)
# print zv
# print "BBBBBBBBBBBBBBBBBB"
self
.
failUnless
((
f
(
xv
,
yv
)
==
zv
)
.
all
())
def
with_linker_inplace
(
self
,
linker
):
for
xsh
,
ysh
in
[((
5
,
5
),
(
5
,
5
)),
((
5
,
5
),
(
1
,
5
)),
((
5
,
5
),
(
5
,
1
)),
((
1
,
1
),
(
1
,
1
)),
((
2
,
3
,
4
,
5
),
(
2
,
3
,
4
,
5
)),
((
2
,
3
,
4
,
5
),
(
1
,
3
,
1
,
5
)),
((
2
,
3
,
4
,
5
),
(
1
,
1
,
1
,
1
)),
((),
())]:
x
=
modes
.
build
(
Tensor
(
'float64'
,
[
1
*
(
entry
==
1
)
for
entry
in
xsh
],
name
=
'x'
))
y
=
modes
.
build
(
Tensor
(
'float64'
,
[
1
*
(
entry
==
1
)
for
entry
in
ysh
],
name
=
'y'
))
e
=
Broadcast
(
Add
,
(
x
,
y
),
{
0
:
0
})
.
out
f
=
linker
(
env
([
x
,
y
],
[
e
]))
.
make_function
(
inplace
=
False
)
xv
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
*
xsh
))
yv
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
*
ysh
))
zv
=
xv
+
yv
f
(
xv
,
yv
)
self
.
failUnless
((
xv
==
zv
)
.
all
())
def
test_perform
(
self
):
self
.
with_linker
(
gof
.
PerformLinker
)
def
test_c
(
self
):
self
.
with_linker
(
gof
.
CLinker
)
def
test_perform_inplace
(
self
):
self
.
with_linker_inplace
(
gof
.
PerformLinker
)
def
test_c_inplace
(
self
):
self
.
with_linker_inplace
(
gof
.
CLinker
)
def
test_fill
(
self
):
x
=
modes
.
build
(
Tensor
(
'float64'
,
[
0
,
0
],
name
=
'x'
))
y
=
modes
.
build
(
Tensor
(
'float64'
,
[
1
,
1
],
name
=
'y'
))
e
=
Broadcast
(
Second
,
(
x
,
y
),
{
0
:
0
})
.
out
f
=
gof
.
CLinker
(
env
([
x
,
y
],
[
e
]))
.
make_function
(
inplace
=
False
)
xv
=
numpy
.
ones
((
5
,
5
))
yv
=
numpy
.
random
.
rand
(
1
,
1
)
f
(
xv
,
yv
)
assert
(
xv
==
yv
)
.
all
()
class
_test_CAReduce
(
unittest
.
TestCase
):
def
with_linker
(
self
,
linker
):
for
xsh
,
tosum
in
[((
5
,
6
),
(
0
,
1
)),
((
5
,
6
),
(
0
,
)),
((
5
,
6
),
(
1
,
)),
((
5
,
6
),
()),
((
2
,
3
,
4
,
5
),
(
0
,
1
,
3
)),
((),
())]:
x
=
modes
.
build
(
Tensor
(
'float64'
,
[
1
*
(
entry
==
1
)
for
entry
in
xsh
],
name
=
'x'
))
e
=
CAReduce
(
Add
,
[
x
],
dimensions_to_reduce
=
tosum
)
.
out
f
=
linker
(
env
([
x
],
[
e
]))
.
make_function
(
inplace
=
False
)
xv
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
*
xsh
))
zv
=
xv
for
axis
in
reversed
(
sorted
(
tosum
)):
zv
=
numpy
.
add
.
reduce
(
zv
,
axis
)
# print "AAAAAAAAAAAAAAAAAA"
# print xsh, tosum
# print f(xv)
# print zv
# print f(xv) - zv
# print "BBBBBBBBBBBBBBBBBB"
self
.
failUnless
((
numpy
.
abs
(
f
(
xv
)
-
zv
)
<
1e-10
)
.
all
())
def
test_perform
(
self
):
self
.
with_linker
(
gof
.
PerformLinker
)
def
test_c
(
self
):
self
.
with_linker
(
gof
.
CLinker
)
if
__name__
==
'__main__'
:
unittest
.
main
()
# x = modes.build(Tensor('float64', [0, 0], name = 'x'))
# y = modes.build(Tensor('float64', [0, 0], name = 'y'))
# e = Broadcast(SquareDiff, (x, y), {0:0}).out
# f = gof.CLinker(env([x, y], [e])).make_function(inplace = False)
# xv = numpy.random.rand(1000, 1000)
# yv = numpy.random.rand(1000, 1000)
# zv = numpy.random.rand(1000, 1000)
# add = numpy.frompyfunc(lambda x, y: x + y, 2, 1)
# t0 = time.time()
# for i in xrange(100):
# xv -= yv
# xv *= xv
# # xv += yv
# print time.time() - t0
# t0 = time.time()
# for i in xrange(100):
# f(xv, yv)
# print time.time() - t0
# def test_straightforward(self):
# x, y, z = inputs()
# e0 = CAReduce(Add, [x]).out
# # print e0.owner
# f = gof.PerformLinker(env([x], [e0])).make_function(inplace=True)
# assert f(numpy.ones((2, 2))) == 4.0
##########
##########
# def test_straightforward(self):
# x, y, z = inputs()
# e0 = Broadcast(Add, (x, y)).out
# f = gof.PerformLinker(env([x, y], [e0])).make_function(inplace=True)
# assert (f(numpy.ones((2, 2)), numpy.ones((1, 2))) == numpy.ones((2, 2))*2).all()
# # for result in e0.owner.grad(e0.owner.inputs, (z, )):
# # print env([x, y, z], [result])
# def test_c(self):
# x = modes.build(Tensor('float64', (0, 0), name = 'x'))
# y = modes.build(Tensor('float64', (0, 1), name = 'y'))
# z = modes.build(Tensor('float64', (0, 0), name = 'z'))
# # x = modes.build(Tensor('float64', (), name = 'x'))
# # y = modes.build(Tensor('float64', (), name = 'y'))
# # x, y, z = inputs()
# e0 = Broadcast(Add, (x, y)).out
# f = gof.CLinker(env([x, y], [e0])).make_function(inplace=True)
# print f(numpy.ones((4, 4), order = 'f'), numpy.array([[1], [2], [3], [4]]))
# # print f(numpy.ones(()), numpy.ones(()))
# assert (f(numpy.ones((2, 2)), numpy.ones((2, 1))) == numpy.ones((2, 2))*2).all()
_test_tensor.py
浏览文件 @
f5c82cdc
...
...
@@ -9,7 +9,7 @@ import gof, gof.graph
from
gof.python25
import
any
import
gof
from
elemwise
2
import
DimShuffle
from
elemwise
import
DimShuffle
def
_numpy_checker
(
x
,
y
):
"""
...
...
elemwise
2
.py
→
elemwise.py
浏览文件 @
f5c82cdc
File moved
opt.py
浏览文件 @
f5c82cdc
from
gof
import
opt
from
elemwise
2
import
Broadcast
from
elemwise
import
Broadcast
class
InplaceOptimizer
(
opt
.
OpSpecificOptimizer
):
...
...
tensor.py
浏览文件 @
f5c82cdc
...
...
@@ -11,7 +11,7 @@ import gof.op
from
base_tensor
import
BaseTensor
,
BaseTensorOp
import
blas
# for gemm, dot
import
elemwise
2
as
s2t
import
elemwise
as
s2t
import
scalar
as
scal
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论