MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / TensorFormats>

Method TensorFormats>

samples/common/sampleOptions.cpp:111–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109
110template <>
111nvinfer1::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
135template <>
136IOFormat stringToValue<IOFormat>(const std::string& option)

Callers

nothing calls this directly

Calls 2

splitToStringVecFunction · 0.85
findMethod · 0.45

Tested by

no test coverage detected