   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;

        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();

        cudaFree(d_values);
        TV_CHECK_CUDA_ERR_V2("cudaFree failed");
        if (!res) {
          failed = true;
          return;
        }
        assignIndiceOutKernel<Index, NDim>
            <<<tv::cuda::getBlocks(numAct), tv::cuda::CUDA_NUM_THREADS, 0,
