iree/modules/hal/module.c
static bool iree_hal_element_types_are_compatible(
    iree_hal_element_type_t actual_type,
    iree_hal_element_type_t expected_type) {
  if (iree_hal_element_numerical_type_is_opaque(actual_type)) {
    // If the provided type is opaque it can map to anything. This allows
    // applications to bypass the checks when they are treating all the data as
    // opaque, such as when carrying around buffer data in binary blobs.
    return true;
  }

  if (iree_hal_element_numerical_type_is_integer(actual_type) &&
      iree_hal_element_numerical_type_is_integer(expected_type) &&
      iree_hal_element_bit_count(actual_type) ==
          iree_hal_element_bit_count(expected_type)) {
    // Integer types of the same bit width are allowed to be cast.
    // This allows users or the compiler to treat data as signless while still
    // allowing signedness. For example, tensor<1xi32> can successfully match
    // a tensor<1xui32> expectation.
    return true;
  }

  // Otherwise we require an exact match. This may be overly conservative but
  // in most cases is a useful error message. Users can pass in OPAQUE types if
  // hitting this to bypass.
  return actual_type == expected_type;
}
// Returns true if the |expected_type| can be satisfied with |actual_type|.
// This allows for basic type widening and bypassing instead of requiring an
// exact match in all cases.
Returns true if the |expected_type| can be satisfied with |actual_type|.
This allows for basic type widening and bypassing instead of requiring an
exact match in all cases.
Returns true if the |expected_type| can be satisfied with |actual_type| . This allows for basic type widening and bypassing instead of requiring an exact match in all cases .
static bool iree_hal_element_types_are_compatible(
    iree_hal_element_type_t actual_type,
    iree_hal_element_type_t expected_type) {
  if (iree_hal_element_numerical_type_is_opaque(actual_type)) {
    return true;
  }
  if (iree_hal_element_numerical_type_is_integer(actual_type) &&
      iree_hal_element_numerical_type_is_integer(expected_type) &&
      iree_hal_element_bit_count(actual_type) ==
          iree_hal_element_bit_count(expected_type)) {
    return true;
  }
  return actual_type == expected_type;
}
static bool iree_hal_element_types_are_compatible ( iree_hal_element_type_t actual_type , iree_hal_element_type_t expected_type ) { if ( iree_hal_element_numerical_type_is_opaque ( actual_type ) ) { return true ; } if ( iree_hal_element_numerical_type_is_integer ( actual_type ) && iree_hal_element_numerical_type_is_integer ( expected_type ) && iree_hal_element_bit_count ( actual_type ) == iree_hal_element_bit_count ( expected_type ) ) { return true ; } return actual_type == expected_type ; }
Returns true if the |expected_type| can be satisfied with |actual_type|.
Returns true if the |expected_type| can be satisfied with |actual_type| .
// If the provided type is opaque it can map to anything. This allows // applications to bypass the checks when they are treating all the data as // opaque, such as when carrying around buffer data in binary blobs. // Integer types of the same bit width are allowed to be cast. // This allows users or the compiler to treat data as signless while still // allowing signedness. For example, tensor<1xi32> can successfully match // a tensor<1xui32> expectation. // Otherwise we require an exact match. This may be overly conservative but // in most cases is a useful error message. Users can pass in OPAQUE types if // hitting this to bypass.