-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
for (uint32_t j = 0; j < 8; j++) {
int32_t in=*activations_idx++;
int32_t tmpsum = (weightChunk & 0x80000000) ? -in : in;
sum += tmpsum; // sign*in*1
if (weightChunk & 0x40000000) sum += tmpsum<<3; // sign*in*8
if (weightChunk & 0x20000000) sum += tmpsum<<2; // sign*in*4
if (weightChunk & 0x10000000) sum += tmpsum<<1; // sign*in*2
weightChunk <<= 4;
}
I'm having some concerns about the line of code 'sum += tmpsum;'.
Is it redundant, perhaps?
If the weight element is in SDDD format, then the sum of three shifts should be sufficient. Here's the relevant code section:
int32_t tmpsum = (weightChunk & 0x80000000) ? -in : in;
if (weightChunk & 0x10000000) sum += tmpsum; // sign*in*1
if (weightChunk & 0x20000000) sum += tmpsum<<1; // sign*in*2
if (weightChunk & 0x40000000) sum += tmpsum<<2; // sign*in*3
weightChunk <<= 4;
upd: It appears that I overlooked the fact that the value 0 is not used...
Metadata
Metadata
Assignees
Labels
No labels