Skip to content
Permalink
Browse files Browse the repository at this point in the history
Prevent division by 0 in LSH projection.
PiperOrigin-RevId: 387225857
Change-Id: Iaeb572a763618c64f503e0026f6dd9fd769bf50c
  • Loading branch information
mihaimaruseac authored and tensorflower-gardener committed Jul 27, 2021
1 parent 13aec9e commit 0575b64
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tensorflow/lite/kernels/lsh_projection.cc
Expand Up @@ -28,7 +28,7 @@ limitations under the License.
//
// Input:
// Tensor[0]: Hash functions. Dim.size == 2, DataType: Float.
// Tensor[0].Dim[0]: Num of hash functions.
// Tensor[0].Dim[0]: Num of hash functions. Must be at least 1.
// Tensor[0].Dim[1]: Num of projected output bits generated by
// each hash function.
// In sparse case, Tensor[0].Dim[1] + ceil( log2(Tensor[0].Dim[0] )) <= 32.
Expand Down Expand Up @@ -82,6 +82,7 @@ TfLiteStatus Resize(TfLiteContext* context, TfLiteNode* node) {
const TfLiteTensor* input;
TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 1, &input));
TF_LITE_ENSURE(context, NumDimensions(input) >= 1);
TF_LITE_ENSURE(context, SizeOfDimension(input, 0) >= 1);

if (NumInputs(node) == 3) {
const TfLiteTensor* weight;
Expand Down

0 comments on commit 0575b64

Please sign in to comment.