def test_local_scalar_tensor_scalar():
dtypes = ['int8', 'int16', 'int32', 'int64',
'uint8', 'uint16', 'uint32', 'uint64',
'float32', 'float64',
'complex64', 'complex128'
]
for dtype in dtypes:
s_type = theano.scalar.Scalar(dtype=dtype)
s = s_type()
t = tensor.tensor_from_scalar(s)
s2 = tensor.scalar_from_tensor(t)
f = function([s], s2, mode=mode_opt)
e = f.maker.fgraph.toposort()
cast_nodes = [n for n in e
if isinstance(n.op, (tensor.TensorFromScalar,
tensor.ScalarFromTensor))]
assert len(cast_nodes) == 0
f(0)
评论列表
文章目录