forked from mindspore-Ecosystem/mindspore
!29577 solve code format issue
Merge pull request !29577 from zhujingxuan/code_format
This commit is contained in:
commit
39fee2393d
|
@ -18,7 +18,6 @@
|
||||||
#include <Eigen/Dense>
|
#include <Eigen/Dense>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <type_traits>
|
|
||||||
namespace mindspore {
|
namespace mindspore {
|
||||||
namespace kernel {
|
namespace kernel {
|
||||||
using Eigen::ColMajor;
|
using Eigen::ColMajor;
|
||||||
|
@ -105,7 +104,7 @@ inline void solve(const MatrixBase<Derived_A> &A, const MatrixBase<Derived_b> &b
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool SolveTriangularCpuKernelMod<T>::Launch(const std::vector<AddressPtr> &inputs,
|
bool SolveTriangularCpuKernelMod<T>::Launch(const std::vector<AddressPtr> &inputs,
|
||||||
const std::vector<AddressPtr> &workspace,
|
const std::vector<AddressPtr> & /* workspace */,
|
||||||
const std::vector<AddressPtr> &outputs) {
|
const std::vector<AddressPtr> &outputs) {
|
||||||
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kSolveTriangularInputsNum, kernel_name_);
|
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kSolveTriangularInputsNum, kernel_name_);
|
||||||
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kSolveTriangularOutputsNum, kernel_name_);
|
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kSolveTriangularOutputsNum, kernel_name_);
|
||||||
|
|
|
@ -84,7 +84,7 @@ template <typename T>
|
||||||
void RankCpuKernelMod<T>::SetFunc() {
|
void RankCpuKernelMod<T>::SetFunc() {
|
||||||
switch (method_) {
|
switch (method_) {
|
||||||
case Method::Max: {
|
case Method::Max: {
|
||||||
func_ = [](size_t i, size_t duplicate_count, int culmutive_rank, const AxisIterator &axisIterator,
|
func_ = [](size_t i, size_t duplicate_count, int /* culmutive_rank */, const AxisIterator &axisIterator,
|
||||||
const size_t *const sort_idx, float *const output_addr) {
|
const size_t *const sort_idx, float *const output_addr) {
|
||||||
for (size_t j = i - duplicate_count + 1; j < i + 1; ++j) {
|
for (size_t j = i - duplicate_count + 1; j < i + 1; ++j) {
|
||||||
output_addr[axisIterator.GetPos(sort_idx[j])] = i + 1;
|
output_addr[axisIterator.GetPos(sort_idx[j])] = i + 1;
|
||||||
|
@ -92,7 +92,7 @@ void RankCpuKernelMod<T>::SetFunc() {
|
||||||
};
|
};
|
||||||
} break;
|
} break;
|
||||||
case Method::Min: {
|
case Method::Min: {
|
||||||
func_ = [](size_t i, size_t duplicate_count, int culmutive_rank, const AxisIterator &axisIterator,
|
func_ = [](size_t i, size_t duplicate_count, int /* culmutive_rank */, const AxisIterator &axisIterator,
|
||||||
const size_t *const sort_idx, float *const output_addr) {
|
const size_t *const sort_idx, float *const output_addr) {
|
||||||
for (size_t j = i - duplicate_count + 1; j < i + 1; ++j) {
|
for (size_t j = i - duplicate_count + 1; j < i + 1; ++j) {
|
||||||
output_addr[axisIterator.GetPos(sort_idx[j])] = i - duplicate_count + 2;
|
output_addr[axisIterator.GetPos(sort_idx[j])] = i - duplicate_count + 2;
|
||||||
|
@ -105,7 +105,7 @@ void RankCpuKernelMod<T>::SetFunc() {
|
||||||
// = duplicate_count * (2 * i - duplicate_count + 1) / 2
|
// = duplicate_count * (2 * i - duplicate_count + 1) / 2
|
||||||
// rank_sum = sum + duplicate_count = duplicate_count * (2 * i - duplicate_count + 3) / 2
|
// rank_sum = sum + duplicate_count = duplicate_count * (2 * i - duplicate_count + 3) / 2
|
||||||
// avg = rank_sum / duplicate_count = (2 * i - duplicate_count + 3) / 2
|
// avg = rank_sum / duplicate_count = (2 * i - duplicate_count + 3) / 2
|
||||||
func_ = [](size_t i, size_t duplicate_count, int culmutive_rank, const AxisIterator &axisIterator,
|
func_ = [](size_t i, size_t duplicate_count, int /* culmutive_rank */, const AxisIterator &axisIterator,
|
||||||
const size_t *const sort_idx, float *const output_addr) {
|
const size_t *const sort_idx, float *const output_addr) {
|
||||||
float avg = (2 * i - duplicate_count + 3) / 2.0;
|
float avg = (2 * i - duplicate_count + 3) / 2.0;
|
||||||
for (size_t j = i - duplicate_count + 1; j < i + 1; ++j) {
|
for (size_t j = i - duplicate_count + 1; j < i + 1; ++j) {
|
||||||
|
@ -114,7 +114,7 @@ void RankCpuKernelMod<T>::SetFunc() {
|
||||||
};
|
};
|
||||||
} break;
|
} break;
|
||||||
case Method::First: {
|
case Method::First: {
|
||||||
func_ = [](size_t i, size_t duplicate_count, int culmutive_rank, const AxisIterator &axisIterator,
|
func_ = [](size_t i, size_t duplicate_count, int /* culmutive_rank */, const AxisIterator &axisIterator,
|
||||||
const size_t *const sort_idx, float *const output_addr) {
|
const size_t *const sort_idx, float *const output_addr) {
|
||||||
for (size_t j = i - duplicate_count + 1; j < i + 1; ++j) {
|
for (size_t j = i - duplicate_count + 1; j < i + 1; ++j) {
|
||||||
output_addr[axisIterator.GetPos(sort_idx[j])] = j + 1;
|
output_addr[axisIterator.GetPos(sort_idx[j])] = j + 1;
|
||||||
|
@ -201,7 +201,7 @@ void RankCpuKernelMod<T>::Launch1D(const T *input_addr, size_t *sort_idx, T *val
|
||||||
|
|
||||||
int culmutive_rank = 1;
|
int culmutive_rank = 1;
|
||||||
size_t duplicate_count = 0;
|
size_t duplicate_count = 0;
|
||||||
int nans_count = 0;
|
size_t nans_count = 0;
|
||||||
|
|
||||||
for (size_t i = 0; i < n; ++i) {
|
for (size_t i = 0; i < n; ++i) {
|
||||||
duplicate_count++;
|
duplicate_count++;
|
||||||
|
@ -226,7 +226,7 @@ void RankCpuKernelMod<T>::Launch1D(const T *input_addr, size_t *sort_idx, T *val
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void RankCpuKernelMod<T>::PctConvert(float *output_addr, const AxisIterator &iter, int culmutive_rank,
|
void RankCpuKernelMod<T>::PctConvert(float *output_addr, const AxisIterator &iter, int culmutive_rank,
|
||||||
int nans_count) const {
|
size_t nans_count) const {
|
||||||
const size_t n = iter.AxisSize();
|
const size_t n = iter.AxisSize();
|
||||||
if (pct_) {
|
if (pct_) {
|
||||||
// pct calculation
|
// pct calculation
|
||||||
|
|
|
@ -79,7 +79,7 @@ class RankCpuKernelMod : public NativeCpuKernelMod {
|
||||||
return std::numeric_limits<T>::min();
|
return std::numeric_limits<T>::min();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void PctConvert(float *output_addr, const AxisIterator &iter, int culmutive_rank, int nans_count) const;
|
void PctConvert(float *output_addr, const AxisIterator &iter, int culmutive_rank, size_t nans_count) const;
|
||||||
void PctConvert(float *output_addr, const AxisIterator &iter, int culmutive_rank) const;
|
void PctConvert(float *output_addr, const AxisIterator &iter, int culmutive_rank) const;
|
||||||
// shape info
|
// shape info
|
||||||
AxisIterator axisIterator_{};
|
AxisIterator axisIterator_{};
|
||||||
|
|
Loading…
Reference in New Issue