提交 bfce7e8e authored 作者: Brandon T. Willard's avatar Brandon T. Willard

Add missing FunctionGraph unit tests

上级 1cbd5f2e
差异被折叠。
import numpy as np
from theano.gof.graph import Apply, Variable from theano.gof.graph import Apply, Variable
from theano.gof.op import Op from theano.gof.op import Op
from theano.gof.type import Type from theano.gof.type import Type
...@@ -20,10 +22,25 @@ class MyType(Type): ...@@ -20,10 +22,25 @@ class MyType(Type):
return hash(MyType) return hash(MyType)
class MyType2(Type):
def filter(self, data):
return data
def __eq__(self, other):
return isinstance(other, MyType)
def __hash__(self):
return hash(MyType)
def MyVariable(name): def MyVariable(name):
return Variable(MyType(), None, None, name=name) return Variable(MyType(), None, None, name=name)
def MyVariable2(name):
return Variable(MyType2(), None, None, name=name)
class MyOp(Op): class MyOp(Op):
def __init__(self, name, dmap=None, x=None): def __init__(self, name, dmap=None, x=None):
self.name = name self.name = name
...@@ -40,6 +57,9 @@ class MyOp(Op): ...@@ -40,6 +57,9 @@ class MyOp(Op):
outputs = [MyType()()] outputs = [MyType()()]
return Apply(self, inputs, outputs) return Apply(self, inputs, outputs)
def perform(self, node, inputs, outputs):
outputs[0] = np.array(inputs)
def __str__(self): def __str__(self):
return self.name return self.name
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论