| 468 | } |
| 469 | |
| 470 | literal tf_parser::parse_tensor(const tensorflow::TensorProto& t) const |
| 471 | { |
| 472 | std::vector<size_t> dims = parse_dims(t.tensor_shape()); |
| 473 | size_t shape_size = std::accumulate(dims.begin(), dims.end(), 1, std::multiplies<size_t>()); |
| 474 | if(not t.tensor_content().empty()) // has raw data |
| 475 | { |
| 476 | const std::string& s = t.tensor_content(); |
| 477 | switch(t.dtype()) |
| 478 | { |
| 479 | case tensorflow::DataType::DT_FLOAT: return literal{{shape::float_type, dims}, s.data()}; |
| 480 | case tensorflow::DataType::DT_BOOL: |
| 481 | case tensorflow::DataType::DT_INT8: return literal{{shape::int8_type, dims}, s.data()}; |
| 482 | case tensorflow::DataType::DT_UINT16: |
| 483 | case tensorflow::DataType::DT_INT16: return literal{{shape::int16_type, dims}, s.data()}; |
| 484 | case tensorflow::DataType::DT_INT32: return literal{{shape::int32_type, dims}, s.data()}; |
| 485 | case tensorflow::DataType::DT_INT64: return literal{{shape::int64_type, dims}, s.data()}; |
| 486 | case tensorflow::DataType::DT_HALF: return literal{{shape::half_type, dims}, s.data()}; |
| 487 | case tensorflow::DataType::DT_DOUBLE: return literal{{shape::double_type, dims}, s.data()}; |
| 488 | case tensorflow::DataType::DT_INVALID: |
| 489 | case tensorflow::DataType::DT_UINT8: |
| 490 | case tensorflow::DataType::DT_STRING: |
| 491 | case tensorflow::DataType::DT_UINT32: |
| 492 | case tensorflow::DataType::DT_UINT64: |
| 493 | case tensorflow::DataType::DT_COMPLEX64: |
| 494 | case tensorflow::DataType::DT_COMPLEX128: |
| 495 | case tensorflow::DataType::DT_QINT8: |
| 496 | case tensorflow::DataType::DT_QUINT8: |
| 497 | case tensorflow::DataType::DT_QINT32: |
| 498 | case tensorflow::DataType::DT_BFLOAT16: |
| 499 | case tensorflow::DataType::DT_QINT16: |
| 500 | case tensorflow::DataType::DT_QUINT16: |
| 501 | case tensorflow::DataType::DT_RESOURCE: |
| 502 | case tensorflow::DataType::DT_VARIANT: |
| 503 | case tensorflow::DataType::DT_FLOAT_REF: |
| 504 | case tensorflow::DataType::DT_DOUBLE_REF: |
| 505 | case tensorflow::DataType::DT_INT32_REF: |
| 506 | case tensorflow::DataType::DT_UINT8_REF: |
| 507 | case tensorflow::DataType::DT_INT16_REF: |
| 508 | case tensorflow::DataType::DT_INT8_REF: |
| 509 | case tensorflow::DataType::DT_STRING_REF: |
| 510 | case tensorflow::DataType::DT_COMPLEX64_REF: |
| 511 | case tensorflow::DataType::DT_INT64_REF: |
| 512 | case tensorflow::DataType::DT_BOOL_REF: |
| 513 | case tensorflow::DataType::DT_QINT8_REF: |
| 514 | case tensorflow::DataType::DT_QUINT8_REF: |
| 515 | case tensorflow::DataType::DT_QINT32_REF: |
| 516 | case tensorflow::DataType::DT_BFLOAT16_REF: |
| 517 | case tensorflow::DataType::DT_QINT16_REF: |
| 518 | case tensorflow::DataType::DT_QUINT16_REF: |
| 519 | case tensorflow::DataType::DT_UINT16_REF: |
| 520 | case tensorflow::DataType::DT_COMPLEX128_REF: |
| 521 | case tensorflow::DataType::DT_HALF_REF: |
| 522 | case tensorflow::DataType::DT_RESOURCE_REF: |
| 523 | case tensorflow::DataType::DT_VARIANT_REF: |
| 524 | case tensorflow::DataType::DT_UINT32_REF: |
| 525 | case tensorflow::DataType::DT_UINT64_REF: |
| 526 | case tensorflow::DataType::DataType_INT_MAX_SENTINEL_DO_NOT_USE_: |
| 527 | case tensorflow::DataType::DataType_INT_MIN_SENTINEL_DO_NOT_USE_: |
no test coverage detected