MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ParseDouble

Method ParseDouble

tensorflow/compiler/xla/service/hlo_parser.cc:4067–4098  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4065}
4066
4067bool HloParserImpl::ParseDouble(double* result) {
4068 switch (lexer_.GetKind()) {
4069 case TokKind::kDecimal: {
4070 double val = lexer_.GetDecimalVal();
4071 // If GetDecimalVal returns +/-inf, that means that we overflowed
4072 // `double`.
4073 if (std::isinf(val)) {
4074 return TokenError(StrCat("Constant is out of range for double (+/-",
4075 std::numeric_limits<double>::max(),
4076 ") and so is unparsable."));
4077 }
4078 *result = val;
4079 break;
4080 }
4081 case TokKind::kInt:
4082 *result = static_cast<double>(lexer_.GetInt64Val());
4083 break;
4084 case TokKind::kw_nan:
4085 *result = std::numeric_limits<double>::quiet_NaN();
4086 break;
4087 case TokKind::kw_inf:
4088 *result = std::numeric_limits<double>::infinity();
4089 break;
4090 case TokKind::kNegInf:
4091 *result = -std::numeric_limits<double>::infinity();
4092 break;
4093 default:
4094 return TokenError("expects decimal or integer");
4095 }
4096 lexer_.Lex();
4097 return true;
4098}
4099
4100bool HloParserImpl::ParseComplex(std::complex<double>* result) {
4101 if (lexer_.GetKind() != TokKind::kLparen) {

Callers

nothing calls this directly

Calls 8

isinfClass · 0.85
infinityFunction · 0.85
GetKindMethod · 0.80
GetDecimalValMethod · 0.80
GetInt64ValMethod · 0.80
LexMethod · 0.80
StrCatFunction · 0.50
maxFunction · 0.50

Tested by

no test coverage detected