Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented May 15, 2019

[jit] add 'all' builtin

@pytorchbot pytorchbot added the oncall: jit Add this issue/PR to JIT oncall triage queue label May 15, 2019
@ghost ghost mentioned this pull request May 16, 2019
76 tasks
@ghost
Copy link
Author

ghost commented May 17, 2019

@driazati I have removed the ops and left in the builtin line. Is this what you were after? Thanks

@ezyang
Copy link
Contributor

ezyang commented May 17, 2019

Could you please cleanup the spurious whitespace changes in this patch, and add a test? I don't know the code so I don't know if the change is right, but it looks reasonable.


//all is a function that takes an iterable and returns True if all are True
Operator(
"aten::all(Tensor x) -> bool",
Copy link
Contributor

@driazati driazati May 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's already an operator for aten::all that's generated from an ATen operator (tensor.all()), you can find it in register_generated_aten_ops_1.cpp after you build the code. For that reason I don't think we need any code here for this op, just adding it to the list of globals in compiler.cpp should be enough., oh sorry I see you already fixed this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I'm such a noob but hopefully this looks ok. If not can you give me a little bit more detail on the whitespace cleanup. Thanks

Copy link
Contributor

@driazati driazati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good to go if you can add back in the test you had earlier and clean up the whitespace changes

@driazati driazati self-requested a review May 24, 2019 20:41
@driazati driazati changed the title Jit all [jit] add 'all' builtin May 28, 2019
Copy link
Contributor

@driazati driazati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, the merge conflict looks easy to fix; could you either check the "Allow edits from maintainers" checkbox on the GitHub sidebar or apply this patch yourself to remove the trailing whitespace (our linters will complain)

diff --git a/test/test_jit.py b/test/test_jit.py
index 4e8e55804..b36db1870 100644
--- a/test/test_jit.py
+++ b/test/test_jit.py
@@ -6288,9 +6288,9 @@ a")
         m = M()
         self.assertEqual(m(), 10)
 
-    def test_script_module_for2(self):  
+    def test_script_module_for2(self):
         class Sub(torch.jit.ScriptModule):
-            def __init__(self):            
+            def __init__(self):
                 super(Sub, self).__init__(False)
                 self.weight = nn.Parameter(torch.randn(2))
 
diff --git a/torch/csrc/jit/register_prim_ops.cpp b/torch/csrc/jit/register_prim_ops.cpp
index e0ca021ec..27393d2ea 100644
--- a/torch/csrc/jit/register_prim_ops.cpp
+++ b/torch/csrc/jit/register_prim_ops.cpp
@@ -1842,7 +1842,7 @@ RegisterOperators reg2({
     DEFINE_INT_OP(aten::__and__, a& b),
     DEFINE_INT_OP(aten::__or__, a | b),
     DEFINE_INT_OP(aten::__xor__, a ^ b),
-    
+
     Operator(
         "prim::abs(int x) -> int",
         [](Stack& stack) {

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@driazati has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@ghost
Copy link
Author

ghost commented May 29, 2019

@driazati I have allowed edits from maintainers. Thank you for helping me work through my first issue!

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@driazati has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@driazati merged this pull request in 6ea9044.

@ghost ghost deleted the jit-all branch May 30, 2019 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged oncall: jit Add this issue/PR to JIT oncall triage queue open source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants