@@ -91,11 +91,8 @@ TEST_CASE("CompileContext::createSession with CPU backend",
9191 FUSILLI_REQUIRE_ASSIGN (auto *context, CompileContext::create ());
9292 REQUIRE (context != nullptr );
9393
94- // Create a handle for CPU backend.
95- FUSILLI_REQUIRE_ASSIGN (Handle handle, Handle::create (Backend::CPU ));
96-
9794 // Create a session.
98- auto maybeSession = context->createSession (handle. getBackend () );
95+ auto maybeSession = context->createSession (Backend:: CPU );
9996 FUSILLI_REQUIRE_OK (maybeSession);
10097
10198 FUSILLI_REQUIRE_ASSIGN (CompileSession session, std::move (maybeSession));
@@ -111,11 +108,8 @@ TEST_CASE("CompileContext::createSession with AMDGPU backend",
111108 FUSILLI_REQUIRE_ASSIGN (auto *context, CompileContext::create ());
112109 REQUIRE (context != nullptr );
113110
114- // Create a handle for AMDGPU backend.
115- FUSILLI_REQUIRE_ASSIGN (Handle handle, Handle::create (Backend::AMDGPU ));
116-
117111 // Create a session.
118- auto maybeSession = context->createSession (handle. getBackend () );
112+ auto maybeSession = context->createSession (Backend:: AMDGPU );
119113 FUSILLI_REQUIRE_OK (maybeSession);
120114
121115 FUSILLI_REQUIRE_ASSIGN (CompileSession session, std::move (maybeSession));
@@ -131,16 +125,13 @@ TEST_CASE("CompileContext supports multiple sessions",
131125 FUSILLI_REQUIRE_ASSIGN (auto *context, CompileContext::create ());
132126 REQUIRE (context != nullptr );
133127
134- // Create a handle.
135- FUSILLI_REQUIRE_ASSIGN (Handle handle, Handle::create (kDefaultBackend ));
136-
137128 // Create multiple sessions from the same context.
138129 FUSILLI_REQUIRE_ASSIGN (auto session1,
139- context->createSession (handle. getBackend () ));
130+ context->createSession (kDefaultBackend ));
140131 FUSILLI_REQUIRE_ASSIGN (auto session2,
141- context->createSession (handle. getBackend () ));
132+ context->createSession (kDefaultBackend ));
142133 FUSILLI_REQUIRE_ASSIGN (auto session3,
143- context->createSession (handle. getBackend () ));
134+ context->createSession (kDefaultBackend ));
144135
145136 // All sessions should be valid.
146137 SUCCEED (" Multiple sessions created successfully" );
@@ -150,9 +141,7 @@ TEST_CASE("CompileSession::addFlag", "[CompileSession]") {
150141 // Get the shared compiler context and create a session.
151142 FUSILLI_REQUIRE_ASSIGN (auto *context, CompileContext::create ());
152143 REQUIRE (context != nullptr );
153- FUSILLI_REQUIRE_ASSIGN (Handle handle, Handle::create (kDefaultBackend ));
154- FUSILLI_REQUIRE_ASSIGN (auto session,
155- context->createSession (handle.getBackend ()));
144+ FUSILLI_REQUIRE_ASSIGN (auto session, context->createSession (kDefaultBackend ));
156145
157146 // Add a flag.
158147 FUSILLI_REQUIRE_OK (session.addFlag (" --iree-opt-level=O3" ));
@@ -165,9 +154,7 @@ TEST_CASE("CompileSession::addFlags", "[CompileSession]") {
165154 // Get the shared compiler context and create a session.
166155 FUSILLI_REQUIRE_ASSIGN (auto *context, CompileContext::create ());
167156 REQUIRE (context != nullptr );
168- FUSILLI_REQUIRE_ASSIGN (Handle handle, Handle::create (kDefaultBackend ));
169- FUSILLI_REQUIRE_ASSIGN (auto session,
170- context->createSession (handle.getBackend ()));
157+ FUSILLI_REQUIRE_ASSIGN (auto session, context->createSession (kDefaultBackend ));
171158
172159 // Add multiple flags.
173160 std::vector<std::string> flags = {
@@ -185,9 +172,7 @@ TEST_CASE("CompileSession::compile with valid MLIR",
185172 // Get the shared compiler context and create a session.
186173 FUSILLI_REQUIRE_ASSIGN (auto *context, CompileContext::create ());
187174 REQUIRE (context != nullptr );
188- FUSILLI_REQUIRE_ASSIGN (Handle handle, Handle::create (kDefaultBackend ));
189- FUSILLI_REQUIRE_ASSIGN (auto session,
190- context->createSession (handle.getBackend ()));
175+ FUSILLI_REQUIRE_ASSIGN (auto session, context->createSession (kDefaultBackend ));
191176
192177 // Create temporary cache files.
193178 FUSILLI_REQUIRE_ASSIGN (
@@ -220,9 +205,7 @@ TEST_CASE("CompileSession::compile with custom flags",
220205 // Get the shared compiler context and create a session.
221206 FUSILLI_REQUIRE_ASSIGN (auto *context, CompileContext::create ());
222207 REQUIRE (context != nullptr );
223- FUSILLI_REQUIRE_ASSIGN (Handle handle, Handle::create (kDefaultBackend ));
224- FUSILLI_REQUIRE_ASSIGN (auto session,
225- context->createSession (handle.getBackend ()));
208+ FUSILLI_REQUIRE_ASSIGN (auto session, context->createSession (kDefaultBackend ));
226209
227210 // Add custom optimization flags.
228211 FUSILLI_REQUIRE_OK (session.addFlag (" --iree-opt-level=O3" ));
@@ -260,9 +243,7 @@ TEST_CASE("CompileSession::compile with invalid MLIR",
260243 // Get the shared compiler context and create a session.
261244 FUSILLI_REQUIRE_ASSIGN (auto *context, CompileContext::create ());
262245 REQUIRE (context != nullptr );
263- FUSILLI_REQUIRE_ASSIGN (Handle handle, Handle::create (kDefaultBackend ));
264- FUSILLI_REQUIRE_ASSIGN (auto session,
265- context->createSession (handle.getBackend ()));
246+ FUSILLI_REQUIRE_ASSIGN (auto session, context->createSession (kDefaultBackend ));
266247
267248 // Create temporary cache files.
268249 FUSILLI_REQUIRE_ASSIGN (
@@ -292,9 +273,7 @@ TEST_CASE("CompileSession::compile with missing input file",
292273 // Get the shared compiler context and create a session.
293274 FUSILLI_REQUIRE_ASSIGN (auto *context, CompileContext::create ());
294275 REQUIRE (context != nullptr );
295- FUSILLI_REQUIRE_ASSIGN (Handle handle, Handle::create (kDefaultBackend ));
296- FUSILLI_REQUIRE_ASSIGN (auto session,
297- context->createSession (handle.getBackend ()));
276+ FUSILLI_REQUIRE_ASSIGN (auto session, context->createSession (kDefaultBackend ));
298277
299278 // Create cache files but don't write to input.
300279 FUSILLI_REQUIRE_ASSIGN (
@@ -319,9 +298,8 @@ TEST_CASE("CompileSession move semantics", "[CompileSession]") {
319298 // Get the shared compiler context and create sessions.
320299 FUSILLI_REQUIRE_ASSIGN (auto *context, CompileContext::create ());
321300 REQUIRE (context != nullptr );
322- FUSILLI_REQUIRE_ASSIGN (Handle handle, Handle::create (kDefaultBackend ));
323301 FUSILLI_REQUIRE_ASSIGN (auto session1,
324- context->createSession (handle. getBackend () ));
302+ context->createSession (kDefaultBackend ));
325303
326304 // Add a flag to session1.
327305 FUSILLI_REQUIRE_OK (session1.addFlag (" --iree-opt-level=O3" ));
@@ -341,9 +319,7 @@ TEST_CASE("CompileSession::compile with AMDGPU backend",
341319 // Get the shared compiler context and create a session for AMDGPU.
342320 FUSILLI_REQUIRE_ASSIGN (auto *context, CompileContext::create ());
343321 REQUIRE (context != nullptr );
344- FUSILLI_REQUIRE_ASSIGN (Handle handle, Handle::create (Backend::AMDGPU ));
345- FUSILLI_REQUIRE_ASSIGN (auto session,
346- context->createSession (handle.getBackend ()));
322+ FUSILLI_REQUIRE_ASSIGN (auto session, context->createSession (Backend::AMDGPU ));
347323
348324 // Create temporary cache files.
349325 FUSILLI_REQUIRE_ASSIGN (
@@ -376,12 +352,11 @@ TEST_CASE("CompileSession cleanup on destruction", "[CompileSession]") {
376352 // Get the shared compiler context.
377353 FUSILLI_REQUIRE_ASSIGN (auto *context, CompileContext::create ());
378354 REQUIRE (context != nullptr );
379- FUSILLI_REQUIRE_ASSIGN (Handle handle, Handle::create (kDefaultBackend ));
380355
381356 // Create a session in a nested scope.
382357 {
383358 FUSILLI_REQUIRE_ASSIGN (auto session,
384- context->createSession (handle. getBackend () ));
359+ context->createSession (kDefaultBackend ));
385360
386361 // Use the session.
387362 FUSILLI_REQUIRE_OK (session.addFlag (" --iree-opt-level=O3" ));
@@ -392,7 +367,7 @@ TEST_CASE("CompileSession cleanup on destruction", "[CompileSession]") {
392367 // Should be able to create a new session after the previous one was
393368 // destroyed.
394369 FUSILLI_REQUIRE_ASSIGN (auto session2,
395- context->createSession (handle. getBackend () ));
370+ context->createSession (kDefaultBackend ));
396371 FUSILLI_REQUIRE_OK (session2.addFlag (" --iree-opt-level=O2" ));
397372
398373 SUCCEED (" Session cleanup and recreation works correctly" );
@@ -402,9 +377,7 @@ TEST_CASE("CompileSession with invalid flag", "[CompileSession][error]") {
402377 // Get the shared compiler context and create a session.
403378 FUSILLI_REQUIRE_ASSIGN (auto *context, CompileContext::create ());
404379 REQUIRE (context != nullptr );
405- FUSILLI_REQUIRE_ASSIGN (Handle handle, Handle::create (kDefaultBackend ));
406- FUSILLI_REQUIRE_ASSIGN (auto session,
407- context->createSession (handle.getBackend ()));
380+ FUSILLI_REQUIRE_ASSIGN (auto session, context->createSession (kDefaultBackend ));
408381
409382 // Try to add an invalid flag.
410383 auto result = session.addFlag (" --this-is-not-a-valid-iree-flag-xyz123" );
@@ -442,7 +415,6 @@ TEST_CASE("Multiple CompileContexts can coexist", "[CompileContext]") {
442415// ===========================================================================
443416
444417TEST_CASE (" CompileSession::build with CPU backend" , " [CompileSession]" ) {
445- FUSILLI_REQUIRE_ASSIGN (Handle handle, Handle::create (Backend::CPU ));
446418 FUSILLI_REQUIRE_ASSIGN (CacheFile input,
447419 CacheFile::create (kGraphName , " input.mlir" , true ));
448420 FUSILLI_REQUIRE_ASSIGN (CacheFile output,
@@ -457,7 +429,7 @@ TEST_CASE("CompileSession::build with CPU backend", "[CompileSession]") {
457429
458430 FUSILLI_REQUIRE_ASSIGN (
459431 CompileSession session,
460- CompileSession::build (handle. getBackend () , input, output, statistics));
432+ CompileSession::build (Backend:: CPU , input, output, statistics));
461433
462434 // Verify that flags were added (including statistics flags).
463435 const auto &args = session.getArgs ();
@@ -481,7 +453,6 @@ TEST_CASE("CompileSession::build with CPU backend", "[CompileSession]") {
481453}
482454
483455TEST_CASE (" CompileSession::toString format" , " [CompileSession]" ) {
484- FUSILLI_REQUIRE_ASSIGN (Handle handle, Handle::create (kDefaultBackend ));
485456 FUSILLI_REQUIRE_ASSIGN (CacheFile input,
486457 CacheFile::create (kGraphName , " input.mlir" , true ));
487458 FUSILLI_REQUIRE_ASSIGN (CacheFile output,
@@ -496,7 +467,7 @@ TEST_CASE("CompileSession::toString format", "[CompileSession]") {
496467
497468 FUSILLI_REQUIRE_ASSIGN (
498469 CompileSession session,
499- CompileSession::build (handle. getBackend () , input, output, statistics));
470+ CompileSession::build (kDefaultBackend , input, output, statistics));
500471
501472 std::string cmdStr = session.toString ();
502473
@@ -507,7 +478,6 @@ TEST_CASE("CompileSession::toString format", "[CompileSession]") {
507478}
508479
509480TEST_CASE (" CompileSession::writeTo" , " [CompileSession]" ) {
510- FUSILLI_REQUIRE_ASSIGN (Handle handle, Handle::create (kDefaultBackend ));
511481 FUSILLI_REQUIRE_ASSIGN (CacheFile input,
512482 CacheFile::create (kGraphName , " input.mlir" , true ));
513483 FUSILLI_REQUIRE_ASSIGN (CacheFile output,
@@ -524,7 +494,7 @@ TEST_CASE("CompileSession::writeTo", "[CompileSession]") {
524494
525495 FUSILLI_REQUIRE_ASSIGN (
526496 CompileSession session,
527- CompileSession::build (handle. getBackend () , input, output, statistics));
497+ CompileSession::build (kDefaultBackend , input, output, statistics));
528498
529499 FUSILLI_REQUIRE_OK (session.writeTo (commandFile));
530500
@@ -534,7 +504,6 @@ TEST_CASE("CompileSession::writeTo", "[CompileSession]") {
534504}
535505
536506TEST_CASE (" CompileSession::execute with valid MLIR" , " [CompileSession]" ) {
537- FUSILLI_REQUIRE_ASSIGN (Handle handle, Handle::create (kDefaultBackend ));
538507 FUSILLI_REQUIRE_ASSIGN (CacheFile input,
539508 CacheFile::create (kGraphName , " input.mlir" , true ));
540509 FUSILLI_REQUIRE_ASSIGN (CacheFile output,
@@ -552,7 +521,7 @@ TEST_CASE("CompileSession::execute with valid MLIR", "[CompileSession]") {
552521
553522 FUSILLI_REQUIRE_ASSIGN (
554523 CompileSession session,
555- CompileSession::build (handle. getBackend () , input, output, statistics));
524+ CompileSession::build (kDefaultBackend , input, output, statistics));
556525
557526 // Execute compilation.
558527 FUSILLI_REQUIRE_OK (session.execute ());
@@ -567,7 +536,6 @@ TEST_CASE("CompileSession::execute with valid MLIR", "[CompileSession]") {
567536}
568537
569538TEST_CASE (" CompileSession::getArgs" , " [CompileSession]" ) {
570- FUSILLI_REQUIRE_ASSIGN (Handle handle, Handle::create (kDefaultBackend ));
571539 FUSILLI_REQUIRE_ASSIGN (CacheFile input,
572540 CacheFile::create (kGraphName , " input.mlir" , true ));
573541 FUSILLI_REQUIRE_ASSIGN (CacheFile output,
@@ -582,7 +550,7 @@ TEST_CASE("CompileSession::getArgs", "[CompileSession]") {
582550
583551 FUSILLI_REQUIRE_ASSIGN (
584552 CompileSession session,
585- CompileSession::build (handle. getBackend () , input, output, statistics));
553+ CompileSession::build (kDefaultBackend , input, output, statistics));
586554
587555 const auto &args = session.getArgs ();
588556
@@ -600,9 +568,8 @@ TEST_CASE("CompileSession::addFlag with tuning spec path",
600568 // Verify tuning spec path flag is accepted by C API.
601569 FUSILLI_REQUIRE_ASSIGN (CompileContext * context, CompileContext::create ());
602570 REQUIRE (context != nullptr );
603- FUSILLI_REQUIRE_ASSIGN (Handle handle, Handle::create (kDefaultBackend ));
604571 FUSILLI_REQUIRE_ASSIGN (CompileSession session,
605- context->createSession (handle. getBackend () ));
572+ context->createSession (kDefaultBackend ));
606573
607574 ErrorObject result =
608575 session.addFlag (" --iree-codegen-tuning-spec-path=" +
@@ -622,9 +589,8 @@ TEST_CASE("CompileSession::compile with tuning spec",
622589 // End-to-end compilation with tuning spec via C API.
623590 FUSILLI_REQUIRE_ASSIGN (CompileContext * context, CompileContext::create ());
624591 REQUIRE (context != nullptr );
625- FUSILLI_REQUIRE_ASSIGN (Handle handle, Handle::create (kDefaultBackend ));
626592 FUSILLI_REQUIRE_ASSIGN (CompileSession session,
627- context->createSession (handle. getBackend () ));
593+ context->createSession (kDefaultBackend ));
628594
629595 FUSILLI_REQUIRE_OK (session.addFlag (" --iree-codegen-tuning-spec-path=" +
630596 getTestTuningSpecPath ().generic_string ()));
0 commit comments