| 558 | } |
| 559 | |
| 560 | TensorFormat get_tensor_format( |
| 561 | const fbs::v2::TensorFormat fformat_type, const void* fformat, |
| 562 | const CompNode& comp_node) { |
| 563 | switch (fformat_type) { |
| 564 | case fbs::v2::TensorFormat_DefaultTensorFormat: |
| 565 | return megdnn::DefaultTensorFormat::make(); |
| 566 | case fbs::v2::TensorFormat_Image2DPackedTensorFormat: { |
| 567 | auto image_format = |
| 568 | static_cast<const fbs::v2::Image2DPackedTensorFormat*>(fformat); |
| 569 | auto handle = |
| 570 | MegDNNHandle::get(CompNodeEnv::from_comp_node(comp_node)).handle(); |
| 571 | return megdnn::Image2DPack4TensorFormat::make( |
| 572 | image_format->align_axis(), handle); |
| 573 | } |
| 574 | case fbs::v2::TensorFormat_LowbitsAlignedTensorFormat: { |
| 575 | auto lowbit_format = |
| 576 | static_cast<const fbs::v2::LowbitsAlignedTensorFormat*>(fformat); |
| 577 | return megdnn::LowbitsAlignedToBytesTensorFormat::make( |
| 578 | lowbit_format->size_nbits()); |
| 579 | } |
| 580 | default: |
| 581 | mgb_throw( |
| 582 | SerializationError, "invalid tensor format type in serialization."); |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | TensorLayout load_tensor_layout_without_format(const fbs::v2::Tensor* tensor) { |
| 587 | TensorLayout layout; |
no test coverage detected