onnxruntime/test/fuzzing/src/OnnxPrediction.cpp
// Used to Generate data for predict
//
Used to Generate data for predict
Used to Generate data for predict
void GenerateDataForInputTypeTensor(OnnxPrediction& predict,
  size_t input_index, const std::string& input_name,
  ONNXTensorElementDataType elem_type, size_t elem_count, size_t seed)
{
  (void) input_name;
  (void) input_index;
  auto pretty_print = [&input_name](auto raw_data)
  {
    Logger::testLog << input_name << L" = ";
    Logger::testLog << L"[";
    std::wstring msg = L"";
    for(int i=0; i < raw_data.size(); i++)
    {
      Logger::testLog << msg << raw_data[i];
      msg = L", ";
    }
    Logger::testLog << L"]\n"; 
  };
  if ( elem_type == ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT)
  {
    auto raw_data = GenerateRandomData(0.0f, elem_count,seed);
    pretty_print(raw_data);
    predict << std::move(raw_data);
  }
  else if (elem_type == ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32)
  {
    int32_t initial = 0;
    auto raw_data = GenerateRandomData(initial, elem_count,seed);
    pretty_print(raw_data);
    predict << std::move(raw_data);
  }
  else
  {
    throw std::exception("only floats are implemented");
  }
}
void GenerateDataForInputTypeTensor ( OnnxPrediction & predict , size_t input_index , const std :: string & input_name , ONNXTensorElementDataType elem_type , size_t elem_count , size_t seed ) { ( void ) input_name ; ( void ) input_index ; auto pretty_print = [ & input_name ] ( auto raw_data ) { Logger :: testLog << input_name << L" " ; Logger :: testLog << L" " ; std :: wstring msg = L" " ; for ( int i = 0 ; i < raw_data . size ( ) ; i ++ ) { Logger :: testLog << msg << raw_data [ i ] ; msg = L" " ; } Logger :: testLog << L" \n " ; } ; if ( elem_type == ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT ) { auto raw_data = GenerateRandomData ( 0.0f , elem_count , seed ) ; pretty_print ( raw_data ) ; predict << std :: move ( raw_data ) ; } else if ( elem_type == ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32 ) { int32_t initial = 0 ; auto raw_data = GenerateRandomData ( initial , elem_count , seed ) ; pretty_print ( raw_data ) ; predict << std :: move ( raw_data ) ; } else { throw std :: exception ( " " ) ; } }
Used to Generate data for predict
Used to Generate data for predict