tensorflow/lite/kernels/multinomial_test.cc
// Test that very low log odds are never sampled.
Test that very low log odds are never sampled.
Test that very low log odds are never sampled .
TYPED_TEST(MultinomialTest, TestVeryLowLogOdds) {
  const int kNumSamples = 1000;
  using Float = typename TestFixture::FloatType;
  using Int = typename TestFixture::IntegralType;
  tflite::MultinomialOpModel m({tflite::GetTTEnum<Float>(), {1, 3}},
                               kNumSamples, {tflite::GetTTEnum<Int>(), {}});
  m.PopulateTensor<Float>(
      m.logits(), {static_cast<Float>(-1000.0f), static_cast<Float>(-1000.0f),
                   static_cast<Float>(0.0f)});
  m.Invoke();
  auto output = m.GetOutput<Int>();
  EXPECT_EQ(output.size(), kNumSamples);
  int c0 = std::count(output.begin(), output.end(), 0);
  int c1 = std::count(output.begin(), output.end(), 1);
  int c2 = std::count(output.begin(), output.end(), 2);
  EXPECT_EQ(c0, 0);
  EXPECT_EQ(c1, 0);
  EXPECT_EQ(c2, kNumSamples);
}
TYPED_TEST ( MultinomialTest , TestVeryLowLogOdds ) { const int kNumSamples = 1000 ; using Float = typename TestFixture :: FloatType ; using Int = typename TestFixture :: IntegralType ; tflite :: MultinomialOpModel m ( { tflite :: GetTTEnum < Float > ( ) , { 1 , 3 } } , kNumSamples , { tflite :: GetTTEnum < Int > ( ) , { } } ) ; m . PopulateTensor < Float > ( m . logits ( ) , { static_cast < Float > ( -1000.0f ) , static_cast < Float > ( -1000.0f ) , static_cast < Float > ( 0.0f ) } ) ; m . Invoke ( ) ; auto output = m . GetOutput < Int > ( ) ; EXPECT_EQ ( output . size ( ) , kNumSamples ) ; int c0 = std :: count ( output . begin ( ) , output . end ( ) , 0 ) ; int c1 = std :: count ( output . begin ( ) , output . end ( ) , 1 ) ; int c2 = std :: count ( output . begin ( ) , output . end ( ) , 2 ) ; EXPECT_EQ ( c0 , 0 ) ; EXPECT_EQ ( c1 , 0 ) ; EXPECT_EQ ( c2 , kNumSamples ) ; }
Test that very low log odds are never sampled.
Test that very low log odds are never sampled .
// Add 1 batch of 3 logits.