# Path: deeppy/expr/base.py
# class Binary(Op):
#     lhs = None
#     rhs = None
# 
#     def __call__(self, lhs, rhs):
#         lhs = _require_op(lhs)
#         rhs = _require_op(rhs)
#         self.lhs = lhs
#         self.rhs = rhs
#         if isinstance(lhs, Constant) and isinstance(rhs, Constant):
#             # Propagate constant
#             self.setup()
#             self.fprop()
#             return Constant(self.array)
#         self.inputs = [lhs, rhs]
#         return self


import cudarray as ca
from .base import Binary


class Dot(Binary):
    def setup(self):
        try:
            # XXX: don't be lazy
            self.shape = ca.dot(self.lhs.array, self.rhs.array).shape
        except ValueError:
            raise ValueError('Shape mismatch: %s and %s for %s. LHS: %s RHS: '
                             '%s.' % (self.lhs.shape, self.rhs.shape,
                                      self, self.lhs, self.rhs))

# Path: deeppy/expr/base.py
# class Binary(Op):
#     lhs = None
#     rhs = None
# 
#     def __call__(self, lhs, rhs):
#         lhs = _require_op(lhs)
#         rhs = _require_op(rhs)
#         self.lhs = lhs
#         self.rhs = rhs
#         if isinstance(lhs, Constant) and isinstance(rhs, Constant):
#             # Propagate constant
#             self.setup()
#             self.fprop()
#             return Constant(self.array)
#         self.inputs = [lhs, rhs]
#         return self


# Path: deeppy/expr/linalg.py
import cudarray as ca
from .base import Binary



class Dot(Binary):
    def setup(self):
        try:
            # XXX: don't be lazy
            self.shape = ca.dot(self.lhs.array, self.rhs.array).shape
        except ValueError:
            raise ValueError('Shape mismatch: %s and %s for %s. LHS: %s RHS: '
                             '%s.' % (self.lhs.shape, self.rhs.shape,
                                      self, self.lhs, self.rhs))

        self.array = ca.zeros(self.shape)