Skip to content

Conversation

@masahi
Copy link
Member

@masahi masahi commented Mar 4, 2021

SPIR-V spec says we cannot physically address boolean buffers, but right now we are generating code like this:

%_runtimearr_bool = OpTypeRuntimeArray %bool
...
%_ptr_StorageBuffer_bool = OpTypePointer StorageBuffer %bool
...
         %36 = OpInBoundsAccessChain %_ptr_StorageBuffer_bool %16 %int_0 %24
         %37 = OpLoad %bool %36 None

This is generating garbage outputs. Actually we hit an error at

int nbits = value_type.type.bits() * value_type.type.lanes();
ICHECK_EQ(nbits % 8, 0);
so boolean buffers are not supported at all.

I updated SPIR-V codegen to make a char buffer when the input is a bool tensor, and add cast to bool after loading the char.

If this change looks good, I should probably update the visitor for storing bool buffer output as well.

This enables running the cumsum test on a boolean flag array, which is explicitly disabled for vulkan in #7572 due to the lack of this fix.

@tqchen @tmoreau89 @jwfromm

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, thanks masa!

@masahi
Copy link
Member Author

masahi commented Mar 5, 2021

@tqchen please have a look, I'll update #7572 after this is merged, to enable the cumsum test on boolean input.

@tqchen tqchen merged commit d7f5753 into apache:main Mar 5, 2021
@tqchen
Copy link
Member

tqchen commented Mar 5, 2021

Thanks @masahi @jwfromm

trevor-m pushed a commit to trevor-m/tvm that referenced this pull request May 6, 2021
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request May 11, 2021
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