iree/tools/iree-e2e-matmul-test.c
static iree_status_t reference_matmul(iree_vm_list_t* input_list,
                                      iree_hal_buffer_view_t* result) {
  iree_hal_buffer_view_t* lhs;
  iree_hal_buffer_view_t* rhs;
  iree_hal_buffer_view_t* acc;
  IREE_RETURN_IF_ERROR(iree_get_buffer_view_list_item(input_list, 0, &lhs));
  IREE_RETURN_IF_ERROR(iree_get_buffer_view_list_item(input_list, 1, &rhs));
  IREE_RETURN_IF_ERROR(iree_get_buffer_view_list_item(input_list, 2, &acc));

  iree_hal_dim_t m_size, k_size, n_size;
  IREE_RETURN_IF_ERROR(
      get_matmul_sizes(lhs, rhs, acc, result, &m_size, &k_size, &n_size));
  void* lhs_data;
  void* rhs_data;
  void* acc_data;
  void* result_data;
  IREE_RETURN_IF_ERROR(get_buffer_view_dense_row_major_data(lhs, &lhs_data));
  IREE_RETURN_IF_ERROR(get_buffer_view_dense_row_major_data(rhs, &rhs_data));
  IREE_RETURN_IF_ERROR(get_buffer_view_dense_row_major_data(acc, &acc_data));
  IREE_RETURN_IF_ERROR(
      get_buffer_view_dense_row_major_data(result, &result_data));
  iree_hal_element_type_t lhs_type = iree_hal_buffer_view_element_type(lhs);
  iree_hal_element_type_t rhs_type = iree_hal_buffer_view_element_type(rhs);
  iree_hal_element_type_t acc_type = iree_hal_buffer_view_element_type(acc);
  for (iree_hal_dim_t m = 0; m < m_size; ++m) {
    for (iree_hal_dim_t n = 0; n < n_size; ++n) {
      reference_matmul_element(m_size, k_size, n_size, lhs_type, rhs_type,
                               acc_type, lhs_data, rhs_data, acc_data,
                               result_data, m, n);
    }
  }
  return iree_ok_status();
}
// Reference matmul implementation, used to compare matmul results against.
Reference matmul implementation, used to compare matmul results against.
Reference matmul implementation used to compare matmul results against .
static iree_status_t reference_matmul(iree_vm_list_t* input_list,
                                      iree_hal_buffer_view_t* result) {
  iree_hal_buffer_view_t* lhs;
  iree_hal_buffer_view_t* rhs;
  iree_hal_buffer_view_t* acc;
  IREE_RETURN_IF_ERROR(iree_get_buffer_view_list_item(input_list, 0, &lhs));
  IREE_RETURN_IF_ERROR(iree_get_buffer_view_list_item(input_list, 1, &rhs));
  IREE_RETURN_IF_ERROR(iree_get_buffer_view_list_item(input_list, 2, &acc));
  iree_hal_dim_t m_size, k_size, n_size;
  IREE_RETURN_IF_ERROR(
      get_matmul_sizes(lhs, rhs, acc, result, &m_size, &k_size, &n_size));
  void* lhs_data;
  void* rhs_data;
  void* acc_data;
  void* result_data;
  IREE_RETURN_IF_ERROR(get_buffer_view_dense_row_major_data(lhs, &lhs_data));
  IREE_RETURN_IF_ERROR(get_buffer_view_dense_row_major_data(rhs, &rhs_data));
  IREE_RETURN_IF_ERROR(get_buffer_view_dense_row_major_data(acc, &acc_data));
  IREE_RETURN_IF_ERROR(
      get_buffer_view_dense_row_major_data(result, &result_data));
  iree_hal_element_type_t lhs_type = iree_hal_buffer_view_element_type(lhs);
  iree_hal_element_type_t rhs_type = iree_hal_buffer_view_element_type(rhs);
  iree_hal_element_type_t acc_type = iree_hal_buffer_view_element_type(acc);
  for (iree_hal_dim_t m = 0; m < m_size; ++m) {
    for (iree_hal_dim_t n = 0; n < n_size; ++n) {
      reference_matmul_element(m_size, k_size, n_size, lhs_type, rhs_type,
                               acc_type, lhs_data, rhs_data, acc_data,
                               result_data, m, n);
    }
  }
  return iree_ok_status();
}
static iree_status_t reference_matmul ( iree_vm_list_t * input_list , iree_hal_buffer_view_t * result ) { iree_hal_buffer_view_t * lhs ; iree_hal_buffer_view_t * rhs ; iree_hal_buffer_view_t * acc ; IREE_RETURN_IF_ERROR ( iree_get_buffer_view_list_item ( input_list , 0 , & lhs ) ) ; IREE_RETURN_IF_ERROR ( iree_get_buffer_view_list_item ( input_list , 1 , & rhs ) ) ; IREE_RETURN_IF_ERROR ( iree_get_buffer_view_list_item ( input_list , 2 , & acc ) ) ; iree_hal_dim_t m_size , k_size , n_size ; IREE_RETURN_IF_ERROR ( get_matmul_sizes ( lhs , rhs , acc , result , & m_size , & k_size , & n_size ) ) ; void * lhs_data ; void * rhs_data ; void * acc_data ; void * result_data ; IREE_RETURN_IF_ERROR ( get_buffer_view_dense_row_major_data ( lhs , & lhs_data ) ) ; IREE_RETURN_IF_ERROR ( get_buffer_view_dense_row_major_data ( rhs , & rhs_data ) ) ; IREE_RETURN_IF_ERROR ( get_buffer_view_dense_row_major_data ( acc , & acc_data ) ) ; IREE_RETURN_IF_ERROR ( get_buffer_view_dense_row_major_data ( result , & result_data ) ) ; iree_hal_element_type_t lhs_type = iree_hal_buffer_view_element_type ( lhs ) ; iree_hal_element_type_t rhs_type = iree_hal_buffer_view_element_type ( rhs ) ; iree_hal_element_type_t acc_type = iree_hal_buffer_view_element_type ( acc ) ; for ( iree_hal_dim_t m = 0 ; m < m_size ; ++ m ) { for ( iree_hal_dim_t n = 0 ; n < n_size ; ++ n ) { reference_matmul_element ( m_size , k_size , n_size , lhs_type , rhs_type , acc_type , lhs_data , rhs_data , acc_data , result_data , m , n ) ; } } return iree_ok_status ( ) ; }
Reference matmul implementation, used to compare matmul results against.
Reference matmul implementation used to compare matmul results against .