MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / GetWeightRange

Method GetWeightRange

tensorflow/compiler/tf2tensorrt/convert/convert_nodes.cc:1336–1366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1334}
1335
1336Status 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
1368Status Converter::PrepareTensorForShape(const TRT_TensorOrWeights& input,
1369 const nvinfer1::Dims& dims,

Callers

nothing calls this directly

Calls 5

UnimplementedFunction · 0.85
TrtDTypeMethod · 0.80
DebugStringFunction · 0.70
GetValuesMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected