gemini-code-assist[bot] commented on code in PR #68:
URL: https://github.com/apache/tvm-ffi/pull/68#discussion_r2384406477


##########
tests/python/test_load_inline.py:
##########
@@ -193,9 +195,18 @@ def test_load_inline_cuda() -> None:
     )
 
     if torch is not None:
+        # test with raw stream
         x_cuda = torch.asarray([1, 2, 3, 4, 5], dtype=torch.float32, 
device="cuda")
         y_cuda = torch.empty_like(x_cuda)
-        mod.add_one_cuda(x_cuda, y_cuda)
+        mod.add_one_cuda(x_cuda, y_cuda, 0)
+        torch.testing.assert_close(x_cuda + 1, y_cuda)
+
+        # test with torch stream
+        y_cuda = torch.empty_like(x_cuda)
+        stream = torch.cuda.Stream()
+        with torch.cuda.stream(stream):
+            mod.add_one_cuda(x_cuda, y_cuda, stream.cuda_stream)
+        stream.synchronize()
         torch.testing.assert_close(x_cuda + 1, y_cuda)

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   The `if torch is not None:` check is redundant. The `test_load_inline_cuda` 
function is already decorated with `@pytest.mark.skipif(torch is None or not 
torch.cuda.is_available(), ...)` on line 156, which ensures `torch` is 
available when this code is executed. You can remove the `if` statement and 
unindent its contents to improve readability.
   
   ```python
       # test with raw stream
       x_cuda = torch.asarray([1, 2, 3, 4, 5], dtype=torch.float32, 
device="cuda")
       y_cuda = torch.empty_like(x_cuda)
       mod.add_one_cuda(x_cuda, y_cuda, 0)
       torch.testing.assert_close(x_cuda + 1, y_cuda)
   
       # test with torch stream
       y_cuda = torch.empty_like(x_cuda)
       stream = torch.cuda.Stream()
       with torch.cuda.stream(stream):
           mod.add_one_cuda(x_cuda, y_cuda, stream.cuda_stream)
       stream.synchronize()
       torch.testing.assert_close(x_cuda + 1, y_cuda)
   ```



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to