tensorflow/lite/kernels/internal/logsoftmax_quantized_test.cc
// See TryOneUniformLogSoftmax() for a general description.
//
// Tests with "skyscraper" input patterns are included for two reasons. (a)
// Bimodal distributions are potentially challenging and perhaps more
// realistic than simple uniform random inputs.  (b) Some implementations of
// LogSoftmax may adapt as they traverse the depth, and so we test handling of
// cases where relatively small values are encountered at the beginning and end.
See TryOneUniformLogSoftmax() for a general description.
Tests with "skyscraper" input patterns are included for two reasons. (a)
Bimodal distributions are potentially challenging and perhaps more
realistic than simple uniform random inputs.  (b) Some implementations of
LogSoftmax may adapt as they traverse the depth, and so we test handling of
cases where relatively small values are encountered at the beginning and end.
See TryOneUniformLogSoftmax () for a general description . Tests with " skyscraper " input patterns are included for two reasons . ( a ) Bimodal distributions are potentially challenging and perhaps more realistic than simple uniform random inputs . ( b ) Some implementations of LogSoftmax may adapt as they traverse the depth and so we test handling of cases where relatively small values are encountered at the beginning and end .
bool TryOneSkyscraperLogSoftmax(bool small_depth) {
  const int batch = ExponentialRandomPositiveInt(0.9f, 3, 20);
  const int input_depth = small_depth
                              ? ExponentialRandomPositiveInt(0.75f, 40, 500)
                              : ExponentialRandomPositiveInt(0.75f, 175, 500);
  const int input_width = ExponentialRandomPositiveInt(0.7f, 20, 200);
  const int input_height = ExponentialRandomPositiveInt(0.7f, 20, 200);
  const int stride = ExponentialRandomPositiveInt(0.9f, 3, 8);
  const double input_scale = std::pow(10.0, UniformRandomFloat(-2.0, 1.0));
  const int32 input_offset = UniformRandomInt(-256, 0);
  static constexpr float beta = 1.0f;
  const double middle_proportion =
      ExponentialRandomPositiveFloat(0.65f, 0.1, 1.0);
  const int middle_min = UniformRandomInt(0, 255);
  const int sides_max = UniformRandomInt(0, middle_min);
  auto shape_common =
      RuntimeShape({batch, input_height, input_width, input_depth});
  const int buffer_size = shape_common.FlatSize();
  std::vector<uint8> input_data(buffer_size);
  FillRandomSkyscraper(&input_data, input_depth, middle_proportion, middle_min,
                       sides_max);
  RunOneLogSoftmaxTest(input_data.data(), shape_common, input_offset,
                       input_scale, stride, beta);
  return true;
}
bool TryOneSkyscraperLogSoftmax ( bool small_depth ) { const int batch = ExponentialRandomPositiveInt ( 0.9f , 3 , 20 ) ; const int input_depth = small_depth ? ExponentialRandomPositiveInt ( 0.75f , 40 , 500 ) : ExponentialRandomPositiveInt ( 0.75f , 175 , 500 ) ; const int input_width = ExponentialRandomPositiveInt ( 0.7f , 20 , 200 ) ; const int input_height = ExponentialRandomPositiveInt ( 0.7f , 20 , 200 ) ; const int stride = ExponentialRandomPositiveInt ( 0.9f , 3 , 8 ) ; const double input_scale = std :: pow ( 10.0 , UniformRandomFloat ( -2.0 , 1.0 ) ) ; const int32 input_offset = UniformRandomInt ( -256 , 0 ) ; static constexpr float beta = 1.0f ; const double middle_proportion = ExponentialRandomPositiveFloat ( 0.65f , 0.1 , 1.0 ) ; const int middle_min = UniformRandomInt ( 0 , 255 ) ; const int sides_max = UniformRandomInt ( 0 , middle_min ) ; auto shape_common = RuntimeShape ( { batch , input_height , input_width , input_depth } ) ; const int buffer_size = shape_common . FlatSize ( ) ; std :: vector < uint8 > input_data ( buffer_size ) ; FillRandomSkyscraper ( & input_data , input_depth , middle_proportion , middle_min , sides_max ) ; RunOneLogSoftmaxTest ( input_data . data ( ) , shape_common , input_offset , input_scale , stride , beta ) ; return true ; }
See TryOneUniformLogSoftmax() for a general description.
See TryOneUniformLogSoftmax () for a general description .
// We pick mostly positive values, on the whole emphasizing smaller values and // therefore faster tests.  We test a wider range of depths.  In the case of // LogSoftmax, the width and height really just create test repetitions. // Extra parameters for skyscraper input patterns.