Skip to content
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

[Vulkan] Vulkan backend supports Call::reinterpret and vectorized comparison. #3795

Merged
merged 1 commit into from
Aug 30, 2019

Conversation

ajtulloch
Copy link
Contributor

See unit test. This allows us to generate vectorized code for common pointwise operations, which is helpful on some platforms. For e.g. Metal, this lowers to select(true, false, cond), glsl to the vectorized versions, etc. This fixes a bug where we'd unconditionally set the result type of comparison operations to a scalar boolean, which leads to failures downstream.

From the SPIR-V specification, vectorized selections (and comparisons) are explicitly supported.

OpSelect

Select between two objects.

Result Type must be a scalar or vector.

The type of Object 1 must be the same as Result Type. Object 1 is selected as the result if Condition is true.

The type of Object 2 must be the same as Result Type. Object 2 is selected as the result if Condition is false.

Condition must be a scalar or vector of Boolean type. 

It must have the same number of components as Result Type.

Results are computed per component.

 
and

OpUGreaterThan

Unsigned-integer comparison if Operand 1 is greater than Operand 2.

Result Type must be a scalar or vector of Boolean type. 

The type of Operand 1 and Operand 2 must be a scalar or vector of integer type. 

They must have the same component width, and they must have the same number of components as Result Type. 

Results are computed per component.

 

@ajtulloch
Copy link
Contributor Author

cc @jwfromm, @tqchen

Copy link
Contributor

@jwfromm jwfromm left a comment

Choose a reason for hiding this comment

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

LGTM, I'm glad you're taking a look at improving Vulkan efficiency. I think it's one of the most important targets we need to support.

src/codegen/spirv/ir_builder.cc Show resolved Hide resolved
@ajtulloch
Copy link
Contributor Author

ajtulloch commented Aug 28, 2019

@jwfromm I've rebased and applied clang-format on the other macro decls for consistency.

@ajtulloch
Copy link
Contributor Author

@tqchen this should be good to go?

@tqchen tqchen merged commit a5def36 into apache:master Aug 30, 2019
@tqchen
Copy link
Member

tqchen commented Aug 30, 2019

Merged! Thanks @ajtulloch @jwfromm

wweic pushed a commit to wweic/tvm that referenced this pull request Sep 16, 2019
wweic pushed a commit to wweic/tvm that referenced this pull request Sep 16, 2019
wweic pushed a commit to neo-ai/tvm that referenced this pull request Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants