parameters: (context, builder, sig, args)
return_statement: return impl_ret_borrowed(context, builder, sig.return_type,
                               out._getvalue())
docstring: np.dot(matrix, matrix, out)
docstring_summary: np.dot(matrix, matrix, out)
docstring_tokens: np . dot ( matrix matrix out )
function: def dot_3_mm(context, builder, sig, args):
      """
      np.dot(matrix, matrix, out)
      """
      xty, yty, outty = sig.args
      assert outty == sig.return_type
      dtype = xty.dtype
  
      x = make_array(xty)(context, builder, args[0])
      y = make_array(yty)(context, builder, args[1])
      out = make_array(outty)(context, builder, args[2])
      x_shapes = cgutils.unpack_tuple(builder, x.shape)
      y_shapes = cgutils.unpack_tuple(builder, y.shape)
      out_shapes = cgutils.unpack_tuple(builder, out.shape)
      m, k = x_shapes
      _k, n = y_shapes
  
      # The only case Numpy supports
      assert outty.layout == 'C'
  
      def check_args(a, b, out):
          m, k = a.shape
          _k, n = b.shape
          if k != _k:
              raise ValueError("incompatible array sizes for np.dot(a, b) "
                               "(matrix * matrix)")
          if out.shape != (m, n):
              raise ValueError("incompatible output array size for "
                               "np.dot(a, b, out) (matrix * matrix)")
  
      context.compile_internal(builder, check_args,
                               signature(types.none, *sig.args), args)
      check_c_int(context, builder, m)
      check_c_int(context, builder, k)
      check_c_int(context, builder, n)
  
      x_data = x.data
      y_data = y.data
      out_data = out.data
  
      # Check whether any of the operands is really a 1-d vector represented
      # as a (1, k) or (k, 1) 2-d array.  In those cases, it is pessimal
      # to call the generic matrix * matrix product BLAS function.
      one = ir.Constant(intp_t, 1)
      is_left_vec = builder.icmp_signed('==', m, one)
      is_right_vec = builder.icmp_signed('==', n, one)
  
      with builder.if_else(is_right_vec) as (r_vec, r_mat):
          with r_vec:
              with builder.if_else(is_left_vec) as (v_v, m_v):
                  with v_v:
                      # V * V
                      call_xxdot(context, builder, False, dtype,
                                 k, x_data, y_data, out_data)
                  with m_v:
                      # M * V
                      do_trans = xty.layout == outty.layout
                      call_xxgemv(context, builder, do_trans,
                                  xty, x_shapes, x_data, y_data, out_data)
          with r_mat:
              with builder.if_else(is_left_vec) as (v_m, m_m):
                  with v_m:
                      # V * M
                      do_trans = yty.layout != outty.layout
                      call_xxgemv(context, builder, do_trans,
                                  yty, y_shapes, y_data, x_data, out_data)
                  with m_m:
                      # M * M
                      call_xxgemm(context, builder,
                                  xty, x_shapes, x_data,
                                  yty, y_shapes, y_data,
                                  outty, out_shapes, out_data)
  
      return impl_ret_borrowed(context, builder, sig.return_type,
                               out._getvalue())
function_tokens: def dot_3_mm ( context , builder , sig , args ) : xty , yty , outty = sig . args assert outty == sig . return_type dtype = xty . dtype x = make_array ( xty ) ( context , builder , args [ 0 ] ) y = make_array ( yty ) ( context , builder , args [ 1 ] ) out = make_array ( outty ) ( context , builder , args [ 2 ] ) x_shapes = cgutils . unpack_tuple ( builder , x . shape ) y_shapes = cgutils . unpack_tuple ( builder , y . shape ) out_shapes = cgutils . unpack_tuple ( builder , out . shape ) m , k = x_shapes _k , n = y_shapes # The only case Numpy supports assert outty . layout == 'C' def check_args ( a , b , out ) : m , k = a . shape _k , n = b . shape if k != _k : raise ValueError ( "incompatible array sizes for np.dot(a, b) " "(matrix * matrix)" ) if out . shape != ( m , n ) : raise ValueError ( "incompatible output array size for " "np.dot(a, b, out) (matrix * matrix)" ) context . compile_internal ( builder , check_args , signature ( types . none , * sig . args ) , args ) check_c_int ( context , builder , m ) check_c_int ( context , builder , k ) check_c_int ( context , builder , n ) x_data = x . data y_data = y . data out_data = out . data # Check whether any of the operands is really a 1-d vector represented # as a (1, k) or (k, 1) 2-d array.  In those cases, it is pessimal # to call the generic matrix * matrix product BLAS function. one = ir . Constant ( intp_t , 1 ) is_left_vec = builder . icmp_signed ( '==' , m , one ) is_right_vec = builder . icmp_signed ( '==' , n , one ) with builder . if_else ( is_right_vec ) as ( r_vec , r_mat ) : with r_vec : with builder . if_else ( is_left_vec ) as ( v_v , m_v ) : with v_v : # V * V call_xxdot ( context , builder , False , dtype , k , x_data , y_data , out_data ) with m_v : # M * V do_trans = xty . layout == outty . layout call_xxgemv ( context , builder , do_trans , xty , x_shapes , x_data , y_data , out_data ) with r_mat : with builder . if_else ( is_left_vec ) as ( v_m , m_m ) : with v_m : # V * M do_trans = yty . layout != outty . layout call_xxgemv ( context , builder , do_trans , yty , y_shapes , y_data , x_data , out_data ) with m_m : # M * M call_xxgemm ( context , builder , xty , x_shapes , x_data , yty , y_shapes , y_data , outty , out_shapes , out_data ) return impl_ret_borrowed ( context , builder , sig . return_type , out . _getvalue ( ) )