[caffe2][tiny] Add logging to report what the current lengths are when mismatched...
authorXinyi Zhang <xinyizhang@fb.com>
Thu, 9 Sep 2021 23:43:55 +0000 (16:43 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Thu, 9 Sep 2021 23:46:55 +0000 (16:46 -0700)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/64768

as title

Differential Revision: D30846637

fbshipit-source-id: 266768c81b315fdebba854135ea2db1faf67fd6a

caffe2/operators/gather_ranges_to_dense_op.h

index a58d948..0fdc430 100644 (file)
@@ -45,6 +45,7 @@ class GatherRangesToDenseOp final : public Operator<Context> {
     for (int i = 0; i < OutputSize(); ++i) {
       emptyRanges_.push_back(0);
       mismatchedRanges_.push_back(0);
+      mismatchedLengths_.push_back(set<int>());
     }
   }
 
@@ -128,6 +129,7 @@ class GatherRangesToDenseOp final : public Operator<Context> {
           // Note, empty ranges are not counted as mismatched because empty
           // are more common and more tolerable.
           mismatchedRanges_[j]++;
+          mismatchedLengths_[j].insert(rangeLength);
           continue;
         }
 
@@ -184,7 +186,9 @@ class GatherRangesToDenseOp final : public Operator<Context> {
             "/",
             totalRanges_,
             ") which exceeds ",
-            maxMismatchedRatio_);
+            maxMismatchedRatio_,
+            ". The incorrect lengths include: ",
+            mismatchedLengths_[j]);
       }
 
       // Only check when the ratio is not set to allow all examples to be empty.
@@ -216,6 +220,7 @@ class GatherRangesToDenseOp final : public Operator<Context> {
   int64_t totalRanges_ = 0;
   vector<int64_t> emptyRanges_;
   vector<int64_t> mismatchedRanges_;
+  vector<set<int>> mismatchedLengths_;
   // To avoid false alarm due to insufficient sample (e.g., first batch being
   // mismatched and causing 100% to be mismatched), use a threshold to ensure
   // enough samples are gathered before decideding whether there is an alarm or