Beispiel #1
0
 def make_node(self, *matrices):
     if not matrices:
         raise ValueError("no matrices to allocate")
     matrices = list(map(at.as_tensor, matrices))
     if any(mat.type.ndim != 2 for mat in matrices):
         raise TypeError("all data arguments must be matrices")
     if self.sparse:
         out_type = aesara.sparse.matrix(
             self.format, dtype=largest_common_dtype(matrices))
     else:
         out_type = aesara.tensor.matrix(
             dtype=largest_common_dtype(matrices))
     return Apply(self, matrices, [out_type])
Beispiel #2
0
 def perform(self, node, inputs, output_storage, params=None):
     dtype = largest_common_dtype(inputs)
     if self.sparse:
         output_storage[0][0] = sp.sparse.block_diag(
             inputs, self.format, dtype)
     else:
         output_storage[0][0] = scipy_block_diag(*inputs).astype(dtype)