Reads a single field value from a CodedInputStream into a tensor.
| 397 | |
| 398 | // Reads a single field value from a CodedInputStream into a tensor. |
| 399 | inline Status ReadValue(CodedInputStream* input, |
| 400 | WireFormatLite::FieldType field_type, int field_number, |
| 401 | DataType dtype, int index, void* datap) { |
| 402 | // Dispatch to the appropriately typed field reader based on the schema type. |
| 403 | switch (field_type) { |
| 404 | case WireFormatLite::TYPE_DOUBLE: |
| 405 | return ReadPrimitive<double, double, WireFormatLite::TYPE_DOUBLE>( |
| 406 | input, index, datap); |
| 407 | case WireFormatLite::TYPE_FLOAT: |
| 408 | switch (dtype) { |
| 409 | case DataType::DT_DOUBLE: |
| 410 | return ReadPrimitive<float, double, WireFormatLite::TYPE_FLOAT>( |
| 411 | input, index, datap); |
| 412 | case DataType::DT_FLOAT: |
| 413 | return ReadPrimitive<float, float, WireFormatLite::TYPE_FLOAT>( |
| 414 | input, index, datap); |
| 415 | default: |
| 416 | return errors::DataLoss("Failed reading TYPE_FLOAT for ", |
| 417 | DataTypeString(dtype)); |
| 418 | } |
| 419 | case WireFormatLite::TYPE_INT64: |
| 420 | return ReadPrimitive<protobuf_int64, int64, WireFormatLite::TYPE_INT64>( |
| 421 | input, index, datap); |
| 422 | case WireFormatLite::TYPE_UINT64: |
| 423 | return ReadPrimitive<protobuf_uint64, uint64, |
| 424 | WireFormatLite::TYPE_UINT64>(input, index, datap); |
| 425 | case WireFormatLite::TYPE_INT32: |
| 426 | switch (dtype) { |
| 427 | case DataType::DT_INT64: |
| 428 | return ReadPrimitive<int32, int64, WireFormatLite::TYPE_INT32>( |
| 429 | input, index, datap); |
| 430 | case DataType::DT_INT32: |
| 431 | return ReadPrimitive<int32, int32, WireFormatLite::TYPE_INT32>( |
| 432 | input, index, datap); |
| 433 | default: |
| 434 | return errors::DataLoss("Failed reading TYPE_INT32 for ", |
| 435 | DataTypeString(dtype)); |
| 436 | } |
| 437 | case WireFormatLite::TYPE_FIXED64: |
| 438 | return ReadPrimitive<protobuf_uint64, uint64, |
| 439 | WireFormatLite::TYPE_FIXED64>(input, index, datap); |
| 440 | case WireFormatLite::TYPE_FIXED32: |
| 441 | switch (dtype) { |
| 442 | case DataType::DT_UINT64: |
| 443 | return ReadPrimitive<uint32, uint64, WireFormatLite::TYPE_FIXED32>( |
| 444 | input, index, datap); |
| 445 | case DataType::DT_UINT32: |
| 446 | return ReadPrimitive<uint32, uint32, WireFormatLite::TYPE_FIXED32>( |
| 447 | input, index, datap); |
| 448 | default: |
| 449 | return errors::DataLoss("Failed reading TYPE_FIXED32 for ", |
| 450 | DataTypeString(dtype)); |
| 451 | } |
| 452 | case WireFormatLite::TYPE_BOOL: |
| 453 | return ReadPrimitive<bool, bool, WireFormatLite::TYPE_BOOL>(input, index, |
| 454 | datap); |
| 455 | case WireFormatLite::TYPE_STRING: |
| 456 | return ReadBytes(input, index, datap); |
nothing calls this directly
no test coverage detected