=================== ReformatManager::ReformatKey ====================*/
| 65 | |
| 66 | // =================== ReformatManager::ReformatKey ====================*/ |
| 67 | std::string ReformatManager::ReformatKey::to_string() const { |
| 68 | auto&& i = tensor_formats_to_named_tensor_shape(input_format); |
| 69 | auto&& o = tensor_formats_to_named_tensor_shape(output_format); |
| 70 | std::string input_name, output_name; |
| 71 | |
| 72 | #define cb(_name) \ |
| 73 | if (input_dtype == DTypeEnum::_name) { \ |
| 74 | input_name = #_name; \ |
| 75 | } else |
| 76 | MEGDNN_FOREACH_DTYPE_NAME(cb) |
| 77 | MEGDNN_FOREACH_PARAMETERIZED_DTYPE(cb) { |
| 78 | mgb_throw( |
| 79 | MegBrainError, "invalid input dtype enum(%u)", |
| 80 | static_cast<uint32_t>(input_dtype)); |
| 81 | } |
| 82 | #undef cb |
| 83 | #define cb(_name) \ |
| 84 | if (output_dtype == DTypeEnum::_name) { \ |
| 85 | output_name = #_name; \ |
| 86 | } else |
| 87 | MEGDNN_FOREACH_DTYPE_NAME(cb) |
| 88 | MEGDNN_FOREACH_PARAMETERIZED_DTYPE(cb) { |
| 89 | mgb_throw( |
| 90 | MegBrainError, "invalid output dtype enum(%u)", |
| 91 | static_cast<uint32_t>(output_dtype)); |
| 92 | } |
| 93 | #undef cb |
| 94 | return ssprintf( |
| 95 | "%s;%s;%s;%s;%s", i.to_string().c_str(), o.to_string().c_str(), |
| 96 | std::to_string(static_cast<uint32_t>(attribute)).c_str(), |
| 97 | input_name.c_str(), output_name.c_str()); |
| 98 | } |
| 99 | |
| 100 | size_t ReformatManager::ReformatKey::Hash::operator()(const ReformatKey& key) const { |
| 101 | auto enumhash = mgb::enumhash(); |
no test coverage detected