return ar, ac def _assert_composable(a, b, tr_a=False, tr_b=False): s1, s2 = get_shape(a, b) s1 = _tr(s1, tr_a) s2 = _tr(s2, tr_b) assert ( s1[1] == s2[0] ), f"Objects {a} and {b} are asserted to be composable, but they are not." # Zero @B.dispatch(precedence=proven()) def matmul(a: AbstractMatrix, b: Zero, tr_a=False, tr_b=False): _assert_composable(a, b, tr_a=tr_a, tr_b=tr_b) ar, _ = _shape_tr(a, tr_a) _, bc = _shape_tr(b, tr_b) return Zero(b.dtype, ar, bc) @B.dispatch(precedence=proven()) def matmul(a: Zero, b: AbstractMatrix, tr_a=False, tr_b=False): _assert_composable(a, b, tr_a=tr_a, tr_b=tr_b) ar, _ = _shape_tr(a, tr_a) _, bc = _shape_tr(b, tr_b) return Zero(b.dtype, ar, bc)
def render_wrap(self, e, formatter): return str(e) @property def _stationary(self): return self[0].stationary @_dispatch def __eq__(self, other: "AmbiguousDimensionalityKernel"): return self[0] == other[0] # Will never need parentheses when printing. @need_parens.dispatch(precedence=proven()) def need_parens(el: Function, parent: AmbiguousDimensionalityKernel): return False @need_parens.dispatch(precedence=proven()) def need_parens(el: AmbiguousDimensionalityKernel, parent: Function): return False # Simply redirect computation. @pairwise.dispatch def pairwise(k: AmbiguousDimensionalityKernel, x, y): return pairwise(k[0], x, y)