@@ -88,3 +88,135 @@ def test_case_6():
8888 """
8989 )
9090 obj .run (pytorch_code , ["result" , "out" ])
91+
92+
93+ def test_case_7 ():
94+ """Mixed positional and keyword arguments"""
95+ pytorch_code = textwrap .dedent (
96+ """
97+ import torch
98+ a = torch.tensor([5, 10, 15])
99+ b = torch.tensor([3, 4, 5])
100+ result = torch.gcd(a, other=b)
101+ """
102+ )
103+ obj .run (pytorch_code , ["result" ])
104+
105+
106+ def test_case_8 ():
107+ """2D tensor input"""
108+ pytorch_code = textwrap .dedent (
109+ """
110+ import torch
111+ a = torch.tensor([[12, 18], [24, 36]])
112+ b = torch.tensor([[8, 6], [16, 12]])
113+ result = torch.gcd(a, b)
114+ """
115+ )
116+ obj .run (pytorch_code , ["result" ])
117+
118+
119+ def test_case_9 ():
120+ """Negative values"""
121+ pytorch_code = textwrap .dedent (
122+ """
123+ import torch
124+ a = torch.tensor([-5, 10, -15])
125+ b = torch.tensor([3, -4, -5])
126+ result = torch.gcd(a, b)
127+ """
128+ )
129+ obj .run (pytorch_code , ["result" ])
130+
131+
132+ def test_case_10 ():
133+ """Broadcasting"""
134+ pytorch_code = textwrap .dedent (
135+ """
136+ import torch
137+ a = torch.tensor([[12, 18, 24]])
138+ b = torch.tensor([6])
139+ result = torch.gcd(a, b)
140+ """
141+ )
142+ obj .run (pytorch_code , ["result" ])
143+
144+
145+ def test_case_11 ():
146+ """Out parameter with positional args"""
147+ pytorch_code = textwrap .dedent (
148+ """
149+ import torch
150+ a = torch.tensor([5, 10, 15])
151+ b = torch.tensor([3, 4, 5])
152+ out = torch.empty(3, dtype=torch.int64)
153+ result = torch.gcd(a, b, out=out)
154+ """
155+ )
156+ obj .run (pytorch_code , ["result" , "out" ])
157+
158+
159+ def test_case_12 ():
160+ """3D tensor input"""
161+ pytorch_code = textwrap .dedent (
162+ """
163+ import torch
164+ a = torch.tensor([[[12, 18], [24, 36]], [[8, 14], [20, 28]]])
165+ b = torch.tensor([[[4, 6], [8, 12]], [[2, 7], [10, 14]]])
166+ result = torch.gcd(a, b)
167+ """
168+ )
169+ obj .run (pytorch_code , ["result" ])
170+
171+
172+ def test_case_13 ():
173+ """int32 dtype"""
174+ pytorch_code = textwrap .dedent (
175+ """
176+ import torch
177+ a = torch.tensor([5, 10, 15], dtype=torch.int32)
178+ b = torch.tensor([3, 4, 5], dtype=torch.int32)
179+ result = torch.gcd(a, b)
180+ """
181+ )
182+ obj .run (pytorch_code , ["result" ])
183+
184+
185+ def test_case_14 ():
186+ """Variable arguments"""
187+ pytorch_code = textwrap .dedent (
188+ """
189+ import torch
190+ x = torch.tensor([12, 18, 24])
191+ y = torch.tensor([8, 6, 16])
192+ result = torch.gcd(x, y)
193+ """
194+ )
195+ obj .run (pytorch_code , ["result" ])
196+
197+
198+ def test_case_15 ():
199+ """Zero values"""
200+ pytorch_code = textwrap .dedent (
201+ """
202+ import torch
203+ a = torch.tensor([0, 10, 0])
204+ b = torch.tensor([5, 0, 0])
205+ result = torch.gcd(a, b)
206+ """
207+ )
208+ obj .run (pytorch_code , ["result" ])
209+
210+
211+ def test_case_16 ():
212+ """Expression as argument"""
213+ pytorch_code = textwrap .dedent (
214+ """
215+ import torch
216+ a = torch.tensor([5, 10, 15])
217+ result = torch.gcd(a, torch.tensor([3, 4, 5]))
218+ """
219+ )
220+ obj .run (pytorch_code , ["result" ])
221+
222+ obj .run (pytorch_code , ["result" ])
0 commit comments