       }
     });
   });
+  if (failed){
+    return -1;
+  }
+
   return numActIn;
 }
 

        cudaFree(d_keyvalues);
        TV_CHECK_CUDA_ERR_V2("cudaFree failed");
        if (!res) {
          return -1; // use -1 to tell outside use CPU implementation
        }
        auto tableSize = table.get_table_size();
        auto tableData = table.data();

  auto kernelVolume = indiceNum.size(0);
  if (numActIn == 0)
    return 0;
  bool failed = false;

  tv::dispatch_torch<int32_t>(indicesIn.scalar_type(), [&](auto IndexValue) {
    using Index = TV_DECLTYPE(IndexValue);
    using IndexGrid = int32_t;
