Skip to content

[JIT] Cannot index into tuple with non constant integer #16962

@sidazhang

Description

@sidazhang

🐛 Bug

[JIT] Cannot index into tuple with non constant integer. Constant array turns it the array into tuple

To Reproduce

 import torch
 
 
 class Normalize(torch.jit.ScriptModule):
     __constants__ = ['mean', 'std']
 
     def __init__(self):
         super(Normalize, self).__init__()
         self.mean = [1, 1, 1]
         self.std = [1, 1, 1]
 
     @torch.jit.script_method
     def forward(self, image):
         # type: (torch.Tensor) -> torch.Tensor
         for i in range(3):
             image[:, i] = image[:, i].sub_(self.mean[i]).div_(self.   std[i])
 
         return image
 
 
 Normalize()

tuple indices must be integer constants:
@torch.jit.script_method
def forward(self, image):
    # type: (torch.Tensor) -> torch.Tensor
    for i in range(3):
        image[:, i] = image[:, i].sub_(self.mean[i]).div_(self.std[i])
                                       ~~~~~~~~~~~ <--- HERE

    return image

Metadata

Metadata

Assignees

Labels

oncall: jitAdd this issue/PR to JIT oncall triage queue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions