提交 d61eb6d0 authored 作者: Jeremiah Lowin's avatar Jeremiah Lowin

support weird axes in tensordot: both empty [ [ ], [ ] ]

上级 f142d6b7
...@@ -7100,11 +7100,12 @@ class Dot(Op): ...@@ -7100,11 +7100,12 @@ class Dot(Op):
def __str__(self): def __str__(self):
return "dot" return "dot"
_dot = Dot() dot = Dot()
pprint.assign(_dot, printing.OperatorPrinter(printing.special['middle_dot'], pprint.assign(dot, printing.OperatorPrinter(printing.special['middle_dot'],
-1, 'left')) -1, 'left'))
def dot(a, b): #TODO replace dot with dotfunc?
def dotfunc(a, b):
""" """
Computes the dot product of two variables. For two matrices, this is Computes the dot product of two variables. For two matrices, this is
equivalent to matrix multiplication. For two vectors, this is the inner equivalent to matrix multiplication. For two vectors, this is the inner
...@@ -7138,7 +7139,7 @@ def dot(a, b): ...@@ -7138,7 +7139,7 @@ def dot(a, b):
elif a.ndim > 2 or b.ndim > 2: elif a.ndim > 2 or b.ndim > 2:
return tensordot(a, b, [[a.ndim - 1], [numpy.maximum(0, b.ndim - 2)]]) return tensordot(a, b, [[a.ndim - 1], [numpy.maximum(0, b.ndim - 2)]])
else: else:
return _dot(a, b) return dot(a, b)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论