csarofeen / pytorch

Tensors and Dynamic neural networks in Python with strong GPU acceleration
http://pytorch.org
Other
26 stars 7 forks source link

Segfault when using addcmul in the frontend #2506

Closed jacobhinkle closed 1 year ago

jacobhinkle commented 1 year ago

🐛 Describe the bug

The following test segfaults somewhere in nvfuser::python_frontend::OpRecord<nvfuser::TensorView*, nvfuser::TensorView*, nvfuser::TensorView*, nvfuser::TensorView*, nvfuser::TensorView*>::operator==():

    def test_addcmul(self):
        inputs = [
            torch.randn(4, device="cuda", dtype=torch.float32),
            torch.randn(4, device="cuda", dtype=torch.float32),
            torch.randn(4, device="cuda", dtype=torch.float32),
        ]

        def fusion_func(fd: FusionDefinition):
            t0 = fd.from_pytorch(inputs[0])
            t1 = fd.from_pytorch(inputs[1])
            t2 = fd.from_pytorch(inputs[2])
            c0 = fd.define_constant(0.1)

            t3 = fd.ops.addcmul(t0, t1, t2, c0)

            fd.add_output(t3)

        nvfout, _ = self.exec_nvfuser(fusion_func, inputs)

        torch_out = torch.addcmul(*inputs, 0.1)

        self.assertEqual(nvfout[0], torch_out)

Versions

TOT