[jit] Add bool type to IR#11834
[jit] Add bool type to IR#11834driazati wants to merge 24 commits intopytorch:masterfrom driazati:ir_bool
bool type to IR#11834Conversation
facebook-github-bot
left a comment
There was a problem hiding this comment.
driazati has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
zdevito
left a comment
There was a problem hiding this comment.
This looks good -- I just have a bunch of small fixes.
test/test_jit.py
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torch/csrc/jit/constants.cpp
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torch/csrc/jit/type.h
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Summary: * Adds explicit bool type and removes previous coercion from bool to int * A couple tests now pass as a result Test Plan: Reviewers: Subscribers: Tasks: Tags:
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
|
Should the bool type be considered a scalar backed by an int? Would manifest in |
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
|
@driazati this needs a rebase |
| %other : float = prim::TensorToNum(%7) | ||
| %9 : Dynamic = aten::gt(%a.1_data, %other) | ||
| %10 : int = prim::TensorToNum(%9) | ||
| %10 : bool = prim::TensorToBool(%9) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
zdevito
left a comment
There was a problem hiding this comment.
This looks good to go once rebased. In a followup we should add the remaining numeric<->bool conversions to match python behavior.
torch/csrc/jit/type.h
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torch/onnx/utils.py
Outdated
| elif n.kindOf("value") == "is": | ||
| value = torch.stack([torch.tensor(v) for v in n["value"]]) if n["value"] else [] | ||
| return g.op("Constant", value_t=value) | ||
| elif n.kindOf("value") == "i": |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
|
@pytorchbot retest this please |
facebook-github-bot
left a comment
There was a problem hiding this comment.
driazati has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
facebook-github-bot
left a comment
There was a problem hiding this comment.
driazati has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
There was a problem hiding this comment.
driazati is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: This PR adds a bool type to `IValue` and puts it into place. * changes conds for `prim::If` and `prim::Loop` to use `bool` type * changes operators that take `bool`s to match their native ops * fixes ambiguous `aten` ops `aten::std` and `aten::var` * fixes tests in `test_jit.py TestJitGenerated` ``` 'test_std_dim', 'test_std_dim_1d', 'test_std_dim_1d_neg0', 'test_std_dim_neg0', 'test_var_dim', 'test_var_dim_1d', 'test_var_dim_1d_neg0', 'test_var_dim_neg0' ``` * adds `prim::BoolToTensor` and `prim::TensorToBool` apaszke zdevito Pull Request resolved: pytorch/pytorch#11834 Differential Revision: D9928570 Pulled By: driazati fbshipit-source-id: 373c53df2f1a8ffa9e33d9a517002fbeef25f3eb
This PR adds a bool type to
IValueand puts it into place.prim::Ifandprim::Loopto usebooltypebools to match their native opsatenopsaten::stdandaten::vartest_jit.py TestJitGeneratedprim::BoolToTensorandprim::TensorToBool@apaszke @zdevito