-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[jit] add 'all' builtin #20521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[jit] add 'all' builtin #20521
Conversation
* jit-all: implementation for all working progress test
* master: test line
|
@driazati I have removed the ops and left in the builtin line. Is this what you were after? Thanks |
|
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. |
torch/csrc/jit/register_prim_ops.cpp
Outdated
|
|
||
| //all is a function that takes an iterable and returns True if all are True | ||
| Operator( | ||
| "aten::all(Tensor x) -> bool", |
There was a problem hiding this comment.
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 , oh sorry I see you already fixed thisaten::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.
There was a problem hiding this comment.
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
driazati
left a comment
There was a problem hiding this 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
removed whitespace
There was a problem hiding this 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) {
facebook-github-bot
left a comment
There was a problem hiding this 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.
|
@driazati I have allowed edits from maintainers. Thank you for helping me work through my first issue! |
facebook-github-bot
left a comment
There was a problem hiding this 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.
[jit] add 'all' builtin