How to efficiently check marked cells given their 8 corner indices

Hi there,

I want to know a memory efficient way of doing following behavior:
Suppose I know the indice of the 8 corners of the cells that’s being marked.
I was fed with a bunch of new cells with the indices of the 8 corners and I want to know if they are the marked cells or not.
This is easy to do if I just allocate the n^3 memory and keep a mask, but is there a more efficient way with just tensor operations(like no forloops)?

Thanks so much!