examples/cpp/tf_zendnn_client.cpp
void calc_softmax(const float* data, size_t size, double* result) {
  double sum = 0;

  auto max = data[0];
  for (size_t i = 1; i < size; i++) {
    if (data[i] > max) {
      max = data[i];
    }
  }

  for (size_t i = 0; i < size; i++) {
    result[i] = exp(data[i] - max);
    sum += result[i];
  }

  for (size_t i = 0; i < size; i++) {
    result[i] /= sum;
  }
}
/**
 * @brief Calculate softmax of the data
 *
 * @param data pointer to the raw data
 * @param size number of elements in the raw data
 * @param result pointer to store the computed results
 */
@brief Calculate softmax of the data
@param data pointer to the raw data
@param size number of elements in the raw data
@param result pointer to store the computed results
@brief Calculate softmax of the data @param data pointer to the raw data @param size number of elements in the raw data @param result pointer to store the computed results
void calc_softmax(const float* data, size_t size, double* result) {
  double sum = 0;
  auto max = data[0];
  for (size_t i = 1; i < size; i++) {
    if (data[i] > max) {
      max = data[i];
    }
  }
  for (size_t i = 0; i < size; i++) {
    result[i] = exp(data[i] - max);
    sum += result[i];
  }
  for (size_t i = 0; i < size; i++) {
    result[i] /= sum;
  }
}
void calc_softmax ( const float * data , size_t size , double * result ) { double sum = 0 ; auto max = data [ 0 ] ; for ( size_t i = 1 ; i < size ; i ++ ) { if ( data [ i ] > max ) { max = data [ i ] ; } } for ( size_t i = 0 ; i < size ; i ++ ) { result [ i ] = exp ( data [ i ] - max ) ; sum += result [ i ] ; } for ( size_t i = 0 ; i < size ; i ++ ) { result [ i ] /= sum ; } }
@brief Calculate softmax of the data
 @param data pointer to the raw data
 @param size number of elements in the raw data
 @param result pointer to store the computed results
@brief Calculate softmax of the data @param data pointer to the raw data @param size number of elements in the raw data @param result pointer to store the computed results