KEMBAR78
[jit] Add `bool` type to IR by driazati · Pull Request #11834 · pytorch/pytorch · GitHub
Skip to content

Conversation

@driazati
Copy link
Contributor

@driazati driazati commented Sep 18, 2018

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

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.

Copy link
Contributor

@zdevito zdevito left a comment

Choose a reason for hiding this comment

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

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.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

David Riazati added 10 commits September 19, 2018 09:23
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:
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
@driazati
Copy link
Contributor Author

Should the bool type be considered a scalar backed by an int? Would manifest in IValue::isScalar and IValue::toScalar

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
David Riazati added 2 commits September 19, 2018 16:11
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
@fmassa
Copy link
Member

fmassa commented Sep 25, 2018

@driazati this needs a rebase

David Riazati added 5 commits September 26, 2018 17:02
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
%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.

Copy link
Contributor

@zdevito zdevito left a comment

Choose a reason for hiding this comment

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

This looks good to go once rebased. In a followup we should add the remaining numeric<->bool conversions to match python behavior.

This comment was marked as off-topic.

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.

David Riazati added 2 commits September 28, 2018 13:35
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
@driazati
Copy link
Contributor Author

driazati commented Oct 1, 2018

@pytorchbot retest this please

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.

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
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.

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 is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

zdevito pushed a commit to zdevito/ATen that referenced this pull request Oct 3, 2018
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
@ezyang ezyang added the merged label Jun 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants