| 1334 | } |
| 1335 | |
| 1336 | Status Converter::GetWeightRange(const TRT_ShapedWeights& weights, |
| 1337 | float* out_min, float* out_max) const { |
| 1338 | switch (weights.TrtDType()) { |
| 1339 | case nvinfer1::DataType::kFLOAT: { |
| 1340 | auto inp = static_cast<float const*>(weights.GetValues()); |
| 1341 | auto result = std::minmax_element(inp, inp + weights.count()); |
| 1342 | *out_min = *result.first; |
| 1343 | *out_max = *result.second; |
| 1344 | break; |
| 1345 | } |
| 1346 | case nvinfer1::DataType::kHALF: { |
| 1347 | auto inp = static_cast<Eigen::half const*>(weights.GetValues()); |
| 1348 | auto result = std::minmax_element(inp, inp + weights.count()); |
| 1349 | *out_min = Eigen::half_impl::half_to_float(*result.first); |
| 1350 | *out_max = Eigen::half_impl::half_to_float(*result.second); |
| 1351 | break; |
| 1352 | } |
| 1353 | case nvinfer1::DataType::kINT32: { |
| 1354 | auto inp = static_cast<int const*>(weights.GetValues()); |
| 1355 | auto result = std::minmax_element(inp, inp + weights.count()); |
| 1356 | *out_min = static_cast<float>(*result.first); |
| 1357 | *out_max = static_cast<float>(*result.second); |
| 1358 | break; |
| 1359 | } |
| 1360 | default: |
| 1361 | return errors::Unimplemented( |
| 1362 | "Data type not supported for GetWeightRange: ", |
| 1363 | DebugString(weights.TrtDType())); |
| 1364 | } |
| 1365 | return Status::OK(); |
| 1366 | } |
| 1367 | |
| 1368 | Status Converter::PrepareTensorForShape(const TRT_TensorOrWeights& input, |
| 1369 | const nvinfer1::Dims& dims, |
nothing calls this directly
no test coverage detected