tensorflow/lite/kernels/internal/logsoftmax_quantized_test.cc
// Same as above except for the following change:
// - input and output data type
// - Dequnatize function
// - clamping values
Same as above except for the following change:
input and output data type
Dequnatize function
clamping values
Same as above except for the following change : input and output data type Dequnatize function clamping values
void RunLogSoftmaxFloatReference(const int8* input_data,
                                 const RuntimeShape& shape_common,
                                 int32 input_offset, const double input_scale,
                                 int stride, float beta,
                                 int8* reference_output_data) {
  const int ref_buffer_size = shape_common.FlatSize();
  std::vector<float> reference_dequant_data(ref_buffer_size);
  std::vector<float> reference_output_float_data(ref_buffer_size);
  DequantizationParams dq_params;
  dq_params.zero_point = input_offset;
  dq_params.scale = input_scale;
  reference_integer_ops::Dequantize(dq_params, shape_common, input_data,
                                    shape_common,
                                    reference_dequant_data.data());
  SoftmaxParams sm_params;
  optimized_ops::LogSoftmax(sm_params, shape_common,
                            reference_dequant_data.data(), shape_common,
                            reference_output_float_data.data());
  for (int i = 0; i < ref_buffer_size; i++) {
    reference_output_data[i] = std::max(
        -128, static_cast<int>(
                  127 + std::round(16.0f * reference_output_float_data[i])));
  }
}
void RunLogSoftmaxFloatReference ( const int8 * input_data , const RuntimeShape & shape_common , int32 input_offset , const double input_scale , int stride , float beta , int8 * reference_output_data ) { const int ref_buffer_size = shape_common . FlatSize ( ) ; std :: vector < float > reference_dequant_data ( ref_buffer_size ) ; std :: vector < float > reference_output_float_data ( ref_buffer_size ) ; DequantizationParams dq_params ; dq_params . zero_point = input_offset ; dq_params . scale = input_scale ; reference_integer_ops :: Dequantize ( dq_params , shape_common , input_data , shape_common , reference_dequant_data . data ( ) ) ; SoftmaxParams sm_params ; optimized_ops :: LogSoftmax ( sm_params , shape_common , reference_dequant_data . data ( ) , shape_common , reference_output_float_data . data ( ) ) ; for ( int i = 0 ; i < ref_buffer_size ; i ++ ) { reference_output_data [ i ] = std :: max ( -128 , static_cast < int > ( 127 + std :: round ( 16.0f * reference_output_float_data [ i ] ) ) ) ; } }
Same as above except for the following change:
 input and output data type
 Dequnatize function
 clamping values
Same as above except for the following change : input and output data type Dequnatize function clamping values
// Reference data generated via Dequant of input into float, and then applying // float LogSoftmax. // Work with quantized scaling for LogSoftmax, under which 255 represents 0, // and -16 gets nudged up to 0.