kimm240 opened a new pull request, #18240:
URL: https://github.com/apache/tvm/pull/18240

   This commit extends the make_fused_bias_activation_pattern function to 
support  
   PyTorch frontend's specific IR generation pattern for convolution operations 
 
   with bias. When PyTorch models with bias=True are converted to Relax IR, the 
 
   frontend generates a conv2d -> reshape -> add -> relu sequence instead of 
the  
   simpler conv2d -> add -> relu pattern that existing fusion logic expected.  
     
   The key changes include:  
     
   1. Add allow_reshape parameter to make_fused_bias_activation_pattern in both 
 
      dpl/pattern.py and backend/patterns.py with default value False to 
maintain  
      backward compatibility.  
     
   2. When allow_reshape=True, the pattern matcher now recognizes and fuses the 
 
      complete conv2d -> reshape -> add -> relu sequence into a single 
composite  
      function, eliminating intermediate tensor allocations and kernel launch  
      overhead.  
     
   3. The original pattern (allow_reshape=False) only fuses conv2d -> add -> 
relu,  
      leaving the reshape operation outside the fused function, which results 
in  
      suboptimal performance for PyTorch-originated models.  
     
   This enhancement enables more efficient operator fusion for PyTorch models,  
   reducing memory usage and improving execution performance by capturing the  
   complete computation pattern in a single fused kernel. The implementation  
   maintains full backward compatibility while extending support for PyTorch  
   frontend's specific IR generation patterns.  
     
   Comprehensive tests are added to verify the fusion behavior with both old 
and  
   new patterns, ensuring correctness across different convolution types 
(Conv1d,  
   Conv2d, Conv3d) and validating that fusion only occurs when appropriate  
   conditions are met.  


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to