@gof.local_optimizer([usmm])
def local_usmm_csx(node):
 if (node.op == usmm):
  (alpha, x, y, z) = node.inputs
  x_is_sparse_variable = _is_sparse_variable(x)
  y_is_sparse_variable = _is_sparse_variable(y)
  if (x_is_sparse_variable and (not y_is_sparse_variable)):
   if (x.type.format == 'csc'):
    (x_val, x_ind, x_ptr, x_shape) = csm_properties(x)
    x_nsparse = x_shape[0]
    dtype_out = scalar.upcast(alpha.type.dtype, x.type.dtype, y.type.dtype, z.type.dtype)
    if (dtype_out not in ('float32', 'float64')):
     return False
    if (y.type.dtype != dtype_out):
     return False
    return [usmm_csc_dense(alpha, x_val, x_ind, x_ptr, x_nsparse, y, z)]
 return False

@ gof . local_optimizer ( [ usmm ] ) def local_usmm_csx ( node ) : if ( node . op == usmm ) : ( alpha , x , y , z ) = node . inputs x_is_sparse_variable = _is_sparse_variable ( x ) y_is_sparse_variable = _is_sparse_variable ( y ) if ( x_is_sparse_variable and ( not y_is_sparse_variable ) ) : if ( x . type . format == 'csc' ) : ( x_val , x_ind , x_ptr , x_shape ) = csm_properties ( x ) x_nsparse = x_shape [ 0 ] dtype_out = scalar . upcast ( alpha . type . dtype , x . type . dtype , y . type . dtype , z . type . dtype ) if ( dtype_out not in ( 'float32' , 'float64' ) ) : return False if ( y . type . dtype != dtype_out ) : return False return [ usmm_csc_dense ( alpha , x_val , x_ind , x_ptr , x_nsparse , y , z ) ] return False
usmm -> usmm_csc_dense .