| 40 | } |
| 41 | |
| 42 | flatbuffers::Offset<void> GraphDumperOSSV2::build_tensor_format( |
| 43 | const TensorLayout::Format& format) { |
| 44 | using Type = megdnn::TensorFormat::Type; |
| 45 | switch (format.type()) { |
| 46 | case Type::DEFAULT: |
| 47 | return fbs::v2::CreateDefaultTensorFormat(m_builder).Union(); |
| 48 | case Type::IMAGE2D_PACK4: |
| 49 | return fbs::v2::CreateImage2DPackedTensorFormat( |
| 50 | m_builder, format.as_impl<megdnn::Image2DPack4TensorFormat>() |
| 51 | .align_axis()) |
| 52 | .Union(); |
| 53 | case Type::LOWBITS_ALIGNED_TO_BYTE: { |
| 54 | auto size_bite = format.as_impl<megdnn::LowbitsAlignedToBytesTensorFormat>() |
| 55 | .size_nbits(); |
| 56 | auto align_size_in_bits = |
| 57 | format.as_impl<megdnn::LowbitsAlignedToBytesTensorFormat>() |
| 58 | .align_size_in_bits(); |
| 59 | return fbs::v2::CreateLowbitsAlignedTensorFormat( |
| 60 | m_builder, size_bite, align_size_in_bits) |
| 61 | .Union(); |
| 62 | } |
| 63 | default: |
| 64 | mgb_throw( |
| 65 | SerializationError, "invalid tensor format type in serialization."); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | flatbuffers::Offset<fbs::v2::MiddleTensor> GraphDumperOSSV2::build_middle_tensor( |
| 70 | const SymbolVar var) { |
nothing calls this directly
no test coverage detected