tensorflow/lite/kernels/internal/depthwiseconv_float_test.cc
// Runs the DepthwiseConv and compares against the reference implementation.
Runs the DepthwiseConv and compares against the reference implementation.
Runs the DepthwiseConv and compares against the reference implementation .
void TestOneDepthwiseConv(
    const DepthwiseParams& params, const RuntimeShape& input_shape,
    const float* input_data, const RuntimeShape& filter_shape,
    const float* filter_data, const RuntimeShape& bias_shape,
    const float* bias_data, const RuntimeShape& output_shape) {
  const int output_buffer_size = output_shape.FlatSize();
  std::vector<float> output_data(output_buffer_size);
  std::vector<float> reference_output_data(output_buffer_size);
  reference_ops::DepthwiseConv(params, input_shape, input_data, filter_shape,
                               filter_data, bias_shape, bias_data, output_shape,
                               reference_output_data.data());
  optimized_ops::DepthwiseConvImpl(
      params, input_shape, input_data, filter_shape, filter_data, bias_shape,
      bias_data, output_shape, output_data.data(), CpuFlags(),
      0,
      output_shape.Dims(1), 1);
  double sum_abs_diff = 0;
  float max_abs_val = 0;
  for (int i = 0; i < output_buffer_size; i++) {
    sum_abs_diff += std::abs(output_data[i] - reference_output_data[i]);
    max_abs_val = std::max(max_abs_val, std::abs(reference_output_data[i]));
  }
  if (sum_abs_diff != 0.f) {
    const float mean_diff =
        static_cast<float>(sum_abs_diff / output_buffer_size);
    const float relative_error = std::abs(mean_diff) / max_abs_val;
    ASSERT_LT(relative_error, 1e-5f);
  }
}
void TestOneDepthwiseConv ( const DepthwiseParams & params , const RuntimeShape & input_shape , const float * input_data , const RuntimeShape & filter_shape , const float * filter_data , const RuntimeShape & bias_shape , const float * bias_data , const RuntimeShape & output_shape ) { const int output_buffer_size = output_shape . FlatSize ( ) ; std :: vector < float > output_data ( output_buffer_size ) ; std :: vector < float > reference_output_data ( output_buffer_size ) ; reference_ops :: DepthwiseConv ( params , input_shape , input_data , filter_shape , filter_data , bias_shape , bias_data , output_shape , reference_output_data . data ( ) ) ; optimized_ops :: DepthwiseConvImpl ( params , input_shape , input_data , filter_shape , filter_data , bias_shape , bias_data , output_shape , output_data . data ( ) , CpuFlags ( ) , 0 , output_shape . Dims ( 1 ) , 1 ) ; double sum_abs_diff = 0 ; float max_abs_val = 0 ; for ( int i = 0 ; i < output_buffer_size ; i ++ ) { sum_abs_diff += std :: abs ( output_data [ i ] - reference_output_data [ i ] ) ; max_abs_val = std :: max ( max_abs_val , std :: abs ( reference_output_data [ i ] ) ) ; } if ( sum_abs_diff != 0.f ) { const float mean_diff = static_cast < float > ( sum_abs_diff / output_buffer_size ) ; const float relative_error = std :: abs ( mean_diff ) / max_abs_val ; ASSERT_LT ( relative_error , 1e-5f ) ; } }
Runs the DepthwiseConv and compares against the reference implementation.
Runs the DepthwiseConv and compares against the reference implementation .
/*thread_start=*/ /*thread_end=*/ /*thread_dim=*/