diff --git a/src/main/scala/fhetest/Checker/Utils.scala b/src/main/scala/fhetest/Checker/Utils.scala index 51361d0..26762ef 100644 --- a/src/main/scala/fhetest/Checker/Utils.scala +++ b/src/main/scala/fhetest/Checker/Utils.scala @@ -29,6 +29,7 @@ case class ResultInvalidInfo( programId: Int, program: T2Program, result: String, + outputs: List[Failure], invalidFilters: List[String], SEAL: String, OpenFHE: String, @@ -160,10 +161,11 @@ implicit val resultValidInfoDecoder: Decoder[ResultValidInfo] = )(ResultValidInfo.apply) implicit val resultInvalidInfoEncoder: Encoder[ResultInvalidInfo] = - Encoder.forProduct6( + Encoder.forProduct7( "programId", "program", "result", + "outputs", "invalidFilters", "SEAL", "OpenFHE", @@ -172,16 +174,18 @@ implicit val resultInvalidInfoEncoder: Encoder[ResultInvalidInfo] = ri.programId, ri.program, ri.result, + ri.outputs, ri.invalidFilters, ri.SEAL, ri.OpenFHE, ), ) implicit val resultInvalidInfoDecoder: Decoder[ResultInvalidInfo] = - Decoder.forProduct6( + Decoder.forProduct7( "programId", "program", "result", + "outputs", "invalidFilters", "SEAL", "OpenFHE", @@ -211,18 +215,22 @@ object DumpUtil { ): Unit = res match { case InvalidResults(results) => { val resultString = "InvalidResults" + val outputs = results.map(backendResultPair => + Failure(backendResultPair.backend, backendResultPair.result.toString()), + ) val validFilters = classOf[ValidFilter].getDeclaredClasses.toList .filter { cls => classOf[ValidFilter] .isAssignableFrom(cls) && cls != classOf[ValidFilter] } val invalidFilters = program.invalidFilterIdxList.map { - case i => validFilters.apply(i).toString() + case i => validFilters.apply(i).getSimpleName.replace("$", "") } val resultValidInfo = ResultInvalidInfo( i, program, resultString, + outputs, invalidFilters, sealVersion, openfheVersion, diff --git a/src/main/scala/fhetest/Generate/LibConfigGenerator.scala b/src/main/scala/fhetest/Generate/LibConfigGenerator.scala index 97df77e..0edd720 100644 --- a/src/main/scala/fhetest/Generate/LibConfigGenerator.scala +++ b/src/main/scala/fhetest/Generate/LibConfigGenerator.scala @@ -4,6 +4,7 @@ import fhetest.Utils.* import fhetest.Generate.Utils.* import scala.util.Random import scala.util.control.Breaks._ +import cats.conversions.all val ringDimCandidates: List[Int] = // also in ValidFilter List(8192, 16384, 32768) @@ -87,15 +88,15 @@ case class InvalidLibConfigGenerator(encType: ENC_TYPE) val totalNumOfFilters = validFilters.length val allCombinations = (1 to totalNumOfFilters).toList.flatMap(combinations(_, totalNumOfFilters)) - // TODO: currently generate only 1 test case for each class - // val numOfTC = 10 - val allCombinations_lazy = LazyList.from(allCombinations) + // TODO: currently generate only 1 test case for each class in each iteration + val numOfTC = 1 + val allCombinationsNtimes = allCombinations.flatMap { List.fill(numOfTC)(_) } + val allCombinations_lazy = LazyList.from(allCombinationsNtimes) def getLibConfigGenerators() : LazyList[List[AbsStmt] => Option[(LibConfig, List[InvalidFilterIdx])]] = for { combination <- allCombinations_lazy } yield { - println(combination) val libConfigGeneratorFromAbsStmts = (absStmts: List[AbsStmt]) => { val randomScheme = if encType == ENC_TYPE.ENC_INT then Scheme.values(Random.nextInt(2)) @@ -113,16 +114,13 @@ case class InvalidLibConfigGenerator(encType: ENC_TYPE) f.getFilteredLibConfigDomain() } }) + println(s"* Indexes of valid filters which are negated: $combination") val libConfigOpt = randomLibConfigFromDomain( false, absStmts, randomScheme, filteredLibConfigDomain, ) - libConfigOpt match { - case None => println("NO DOMAIN") - case Some(_) => () - } libConfigOpt match { case None => None case Some(libConfig) => Some((libConfig, combination)) @@ -151,7 +149,6 @@ def randomLibConfigFromDomain( val realMulDepth: Int = absStmts.count { case Mul(_, _) | MulP(_, _) => true; case _ => false } - println(s"realMulDepth: $realMulDepth") getRandomElementOrBreak( (filteredLibConfigDomain.mulDepth)(realMulDepth), ) diff --git a/src/main/scala/fhetest/Generate/ValidFilter.scala b/src/main/scala/fhetest/Generate/ValidFilter.scala index 7bcd7ff..6edb326 100644 --- a/src/main/scala/fhetest/Generate/ValidFilter.scala +++ b/src/main/scala/fhetest/Generate/ValidFilter.scala @@ -9,17 +9,17 @@ import fhetest.Utils.* // * defined & used in LibConfigGenerator // * automatically arranged in alphabetical order // val validFilters = List( -// FilterBoundIsLessThanPlainMod, // 0 -// FilterBoundIsLessThanPowerOfModSize, // 1 -// FilterFirstModSizeIsLargest, // 2 -// FilterLenIsLessThanRingDim, // 3 -// FilterModSizeIsBeteween14And60bits, // 4 -// FilterMulDepthIsEnough, // 5 -// FilterOpenFHEBFVModuli, // 6 +// FilterBoundIsLessThanPlainMod, +// FilterBoundIsLessThanPowerOfModSize, +// FilterFirstModSizeIsLargest, +// FilterLenIsLessThanRingDim, +// FilterModSizeIsBeteween14And60bits, +// FilterMulDepthIsEnough, +// FilterOpenFHEBFVModuli, // FilterPlainModEnableBatching, /* commented */ // FilterPlainModIsPositive, /* commented */ // FilterRingDimIsPowerOfTwo, /* commented */ -// FilterScalingTechniqueByScheme // 7 +// FilterScalingTechniqueByScheme // ) trait ValidFilter(prev: LibConfigDomain, validFilter: Boolean) {