fix ppl (#10996)
This commit is contained in:
		
							parent
							
								
									04d5a900e1
								
							
						
					
					
						commit
						99255fe36e
					
				
					 2 changed files with 4 additions and 3 deletions
				
			
		| 
						 | 
					@ -74,8 +74,9 @@ class BigDLPPL:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            ppl_mean = np.mean(np.array(ppls)[~np.isnan(np.array(ppls))])
 | 
					            ppl_mean = np.mean(np.array(ppls)[~np.isnan(np.array(ppls))])
 | 
				
			||||||
        finally:
 | 
					        finally:
 | 
				
			||||||
            torch.xpu.synchronize()
 | 
					            if self.device == "xpu":
 | 
				
			||||||
            torch.xpu.empty_cache()
 | 
					                torch.xpu.synchronize()
 | 
				
			||||||
 | 
					                torch.xpu.empty_cache()
 | 
				
			||||||
            del self.model
 | 
					            del self.model
 | 
				
			||||||
            gc.collect()
 | 
					            gc.collect()
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -100,7 +100,7 @@ def main():
 | 
				
			||||||
        dumped = json.dumps(results, indent=2)
 | 
					        dumped = json.dumps(results, indent=2)
 | 
				
			||||||
        print(dumped)
 | 
					        print(dumped)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if args.output_path:
 | 
					        if output_path:
 | 
				
			||||||
            with open(f"{log_dir}/result.json", "w") as f:
 | 
					            with open(f"{log_dir}/result.json", "w") as f:
 | 
				
			||||||
                f.write(dumped)
 | 
					                f.write(dumped)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue