| 109 | |
| 110 | template <> |
| 111 | nvinfer1::TensorFormats stringToValue<nvinfer1::TensorFormats>(const std::string& option) |
| 112 | { |
| 113 | std::vector<std::string> optionStrings = splitToStringVec(option, '+'); |
| 114 | const std::unordered_map<std::string, nvinfer1::TensorFormat> strToFmt{{"chw", nvinfer1::TensorFormat::kLINEAR}, |
| 115 | {"chw2", nvinfer1::TensorFormat::kCHW2}, {"chw4", nvinfer1::TensorFormat::kCHW4}, |
| 116 | {"hwc8", nvinfer1::TensorFormat::kHWC8}, {"chw16", nvinfer1::TensorFormat::kCHW16}, |
| 117 | {"chw32", nvinfer1::TensorFormat::kCHW32}, {"dhwc8", nvinfer1::TensorFormat::kDHWC8}, |
| 118 | {"cdhw32", nvinfer1::TensorFormat::kCDHW32}, {"hwc", nvinfer1::TensorFormat::kHWC}, |
| 119 | {"dhwc", nvinfer1::TensorFormat::kDHWC}, {"dla_linear", nvinfer1::TensorFormat::kDLA_LINEAR}, |
| 120 | {"dla_hwc4", nvinfer1::TensorFormat::kDLA_HWC4}}; |
| 121 | nvinfer1::TensorFormats formats{}; |
| 122 | for (auto f : optionStrings) |
| 123 | { |
| 124 | const auto& tf = strToFmt.find(f); |
| 125 | if (tf == strToFmt.end()) |
| 126 | { |
| 127 | throw std::invalid_argument(std::string("Invalid TensorFormat ") + f); |
| 128 | } |
| 129 | formats |= 1U << static_cast<int32_t>(tf->second); |
| 130 | } |
| 131 | |
| 132 | return formats; |
| 133 | } |
| 134 | |
| 135 | template <> |
| 136 | IOFormat stringToValue<IOFormat>(const std::string& option) |
nothing calls this directly
no test coverage detected