cair / PyTsetlinMachineCUDA

Massively Parallel and Asynchronous Architecture for Logic-based AI
https://arxiv.org/abs/2009.04861
MIT License
41 stars 4 forks source link

problem with break in evaluate #1

Closed pedritolo closed 4 years ago

pedritolo commented 4 years ago

hi, the following block in the kernel's evaluate function is faulty. Btw, just swapping the "break" for a "continue" won't be enough to fix it. Commenting out the block is a temporary fix

            int all_exclude = 1;
            for (int la_chunk = 0; la_chunk < LA_CHUNKS-1; ++la_chunk) 
            {
                if (ta_state[la_chunk*STATE_BITS + STATE_BITS - 1] > 0) 
                {
                    all_exclude = 0;
                    break;
                }
            }
            if ((ta_state[(LA_CHUNKS-1)*STATE_BITS + STATE_BITS - 1] & FILTER) > 0) 
            {
                all_exclude = 0;
            }
            if (all_exclude) 
            {
                break;
            }
olegranmo commented 4 years ago

Nice catch, @pedritolo! That bug caused the remaining clauses in the outer for-loop to not be evaluated. If a clause is "all exclude" it should not take part in the evaluation at all. However, the outer for-loop should continue to the next clause. Fixed by changing the last 'break' to 'continue'.