@@ -46,11 +46,13 @@ def add_stage(self, stage: lhs.Stage) -> None:
4646 # Users can derive their own classes from Stage and add them to the pipeline with this method.
4747 self .stages .append (stage )
4848
49- def apply (self , module : ir .Module ) -> ir .Module :
49+ def apply (self , module : ir .Module , print_after_all : bool = False ) -> ir .Module :
5050 if module .context != self .context :
5151 raise ValueError ("Module context does not match driver context." )
5252 for stage in self .stages :
5353 module = stage .apply (module )
54+ if print_after_all :
55+ print (f"After stage { stage } :\n { module } " )
5456 return module
5557
5658 def __len__ (self ):
@@ -173,14 +175,14 @@ def reset(self) -> None:
173175 self .module = None
174176 self .pipeline_fixed = False
175177
176- def run (self ) -> ir .Module :
178+ def run (self , print_after_all : bool = False ) -> ir .Module :
177179 if self .module is None :
178180 raise ValueError ("Module must not be empty." )
179181 if len (self .pipeline ) == 0 :
180182 raise ValueError ("Pipeline must have at least one stage." )
181183
182184 # Apply the whole pipeline.
183- self .pipeline .apply (self .module )
185+ self .pipeline .apply (self .module , print_after_all = print_after_all )
184186
185187 # The pipeline is now fixed and cannot be modified until reset is called.
186188 # This is to prevent accidental modifications to the pipeline after it has been run,
0 commit comments