tensorflow/compiler/mlir/tfrt/jit/python_binding/conversion_utils.cc
// Returns TFRT's dtype for the Python buffer protocol's type string.
Returns TFRT's dtype for the Python buffer protocol's type string.
Returns TFRT ' s dtype for the Python buffer protocol ' s type string .
DType FromPythonStructFormat(char dtype) {
  switch (dtype) {
    case 'B':
      return DType::UI8;
    case 'H':
      return DType::UI16;
    case 'I':
      return DType::UI32;
    case 'Q':
      return DType::UI64;
    case '?':
      return DType::I1;
    case 'b':
      return DType::I8;
    case 'h':
      return DType::I16;
    case 'i':
      return DType::I32;
    case 'q':
      return DType::I64;
    case 'f':
      return DType::F32;
    case 'd':
      return DType::F64;
    default:
      throw std::runtime_error("Unsupported python dtype.");
  }
}
DType FromPythonStructFormat ( char dtype ) { switch ( dtype ) { case ' ' : return DType :: UI8 ; case ' ' : return DType :: UI16 ; case ' ' : return DType :: UI32 ; case ' ' : return DType :: UI64 ; case ' ' : return DType :: I1 ; case ' ' : return DType :: I8 ; case ' ' : return DType :: I16 ; case ' ' : return DType :: I32 ; case ' ' : return DType :: I64 ; case ' ' : return DType :: F32 ; case ' ' : return DType :: F64 ; default : throw std :: runtime_error ( " " ) ; } }
Returns TFRT's dtype for the Python buffer protocol's type string.
Returns TFRT ' s dtype for the Python buffer protocol ' s type string .
// Reference: https://docs.python.org/3/library/struct.html