-
Ted Themistokleous authored
We can't change the behaviour of the nonzero op and we currently pad the output with zeros. This unfortunately obfuscates the following cases: 1. When the only nonzero element is the first index - the whole tensor is padded with zeros its not obvious if the first value is valid index or padded 2. When the nonzero elements vector is used for indicies. The resulting vector with the padded value of 0 is still a valid index thus gather/gatherND and other ops will assume the 0 index is valid and operate accordingly. In this case, by adding a sentinel value of the number of static elements used by the desired shape, the resulting nonzero output can now track how many elements are valid by determining the value in the correct range. Originally I intended to use -1 but not all datatypes use this if say, we're dealing with unsigned values in our vectors or booleans.
28727db2