How can I use Modulo Operation?
              
              #1502
            
            
              
                
                  
                  
                    Answered
                  
                  by
                    laggui
                  
              
          
                  
                    
                      zemelLeong
                    
                  
                
                  asked this question in
                Q&A
              
            -
| 
         In pytorch: >>> t = torch.rand(5) * 21
>>> t
tensor([ 1.3367, 14.8231,  7.2101,  1.0962, 19.3178])
>>> t % 4
tensor([1.3367, 2.8231, 3.2101, 1.0962, 3.3178])Is there any example for  fn modula_ac<B: Backend>(tensor: Tensor<B, 3, Int>, divisor: i32) -> Tensor<B, 3> {
    let tensor_f = tensor.clone().float();
    let div_res = tensor / divisor;
    let div_res_f = tensor_f / divisor;
    (div_res_f - div_res.float()) * divisor
} | 
  
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            laggui
          
      
      
        Mar 22, 2024 
      
    
    Replies: 1 comment 1 reply
-
| 
         The modulo (or  Should be fairly easy to implement, feel free to open an issue! :)  | 
  
Beta Was this translation helpful? Give feedback.
                  
                    1 reply
                  
                
            
      Answer selected by
        laggui
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
The modulo (or
torch.remainder) operator is not implemented yet for Tensors.Should be fairly easy to implement, feel free to open an issue! :)