MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / processShapes

Function processShapes

samples/common/sampleOptions.cpp:414–495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412}
413
414void processShapes(BuildOptions::ShapeProfile& shapes, bool minShapes, bool optShapes, bool maxShapes, bool calib)
415{
416 // Only accept optShapes only or all three of minShapes, optShapes, maxShapes when calib is set
417 if (((minShapes || maxShapes) && !optShapes) // minShapes only, maxShapes only, both minShapes and maxShapes
418 || (minShapes && !maxShapes && optShapes) // both minShapes and optShapes
419 || (!minShapes && maxShapes && optShapes)) // both maxShapes and optShapes
420 {
421 if (calib)
422 {
423 throw std::invalid_argument(
424 "Must specify only --optShapesCalib or all of --minShapesCalib, --optShapesCalib, --maxShapesCalib");
425 }
426 }
427
428 if (!minShapes && !optShapes && !maxShapes)
429 {
430 return;
431 }
432
433 BuildOptions::ShapeProfile newShapes;
434 for (auto& s : shapes)
435 {
436 nvinfer1::OptProfileSelector minDimsSource, optDimsSource, maxDimsSource;
437 minDimsSource = nvinfer1::OptProfileSelector::kMIN;
438 optDimsSource = nvinfer1::OptProfileSelector::kOPT;
439 maxDimsSource = nvinfer1::OptProfileSelector::kMAX;
440
441 // Populate missing minShapes
442 if (!minShapes)
443 {
444 if (optShapes)
445 {
446 minDimsSource = optDimsSource;
447 sample::gLogWarning << "optShapes is being broadcasted to minShapes for tensor " << s.first
448 << std::endl;
449 }
450 else
451 {
452 minDimsSource = maxDimsSource;
453 sample::gLogWarning << "maxShapes is being broadcasted to minShapes for tensor " << s.first
454 << std::endl;
455 }
456 }
457
458 // Populate missing optShapes
459 if (!optShapes)
460 {
461 if (maxShapes)
462 {
463 optDimsSource = maxDimsSource;
464 sample::gLogWarning << "maxShapes is being broadcasted to optShapes for tensor " << s.first
465 << std::endl;
466 }
467 else
468 {
469 optDimsSource = minDimsSource;
470 sample::gLogWarning << "minShapes is being broadcasted to optShapes for tensor " << s.first
471 << std::endl;

Callers 1

parseMethod · 0.85

Calls 1

fillShapesFunction · 0.85

Tested by

no test coverage detected