Merge pull request !24184 from hwjiaorui/clean-code-master
This commit is contained in:
i-robot 2021-09-27 01:13:26 +00:00 committed by Gitee
commit c9bbe14fcc
11 changed files with 15 additions and 34 deletions

View File

@ -36,7 +36,6 @@ namespace mindspore {
namespace kernel {
namespace tbe {
namespace {
constexpr int kInvalid = -1;
constexpr int kFloat = 0;
constexpr int kFloat16 = 1;

View File

@ -15,8 +15,6 @@
*/
#include "backend/kernel_compiler/tbe/tbe_json/fusion_tbe_json_creator.h"
#include <memory>
#include <list>
#include <algorithm>
#include <string>
#include <vector>
@ -87,9 +85,7 @@ bool FusionBuildTbeJsonCreator::GenOpListJson(const FusionScopeInfo &fusion_scop
if (!TbeAdapter::GetSpecDataInput(fusion_scope_info, &spec_data_input)) {
return false;
}
if (!GenDataJson(compute_nodes, compute_list, fusion_json, spec_data_input)) {
MS_LOG(WARNING) << "Fusion Error: gen fusion data json failed. fusion scope name: " << fusion_scope_info.full_name;
}
GenDataJson(compute_nodes, compute_list, fusion_json, spec_data_input);
(*fusion_json).insert((*fusion_json).end(), compute_list.begin(), compute_list.end());
MS_LOG(DEBUG) << "End";
return true;
@ -124,7 +120,7 @@ bool FusionBuildTbeJsonCreator::CheckInput(const FusionScopeInfo &fusion_scope_i
return true;
}
bool FusionBuildTbeJsonCreator::GenDataJson(const std::vector<AnfNodePtr> &compute_nodes,
void FusionBuildTbeJsonCreator::GenDataJson(const std::vector<AnfNodePtr> &compute_nodes,
const std::vector<nlohmann::json> &compute_json,
std::vector<nlohmann::json> *op_list_json,
const ANodeFusionDataTypeMap &spec_data_input) {
@ -155,7 +151,6 @@ bool FusionBuildTbeJsonCreator::GenDataJson(const std::vector<AnfNodePtr> &compu
}
}
MS_LOG(DEBUG) << "End.";
return true;
}
AnfNodePtr FusionBuildTbeJsonCreator::GetInputCNode(const AnfNodePtr &node, const nlohmann::json &input_desc) {
auto input_name = GetJsonValue<std::string>(input_desc, kJName);

View File

@ -34,7 +34,7 @@ class FusionBuildTbeJsonCreator : public TbeJsonCreator {
std::vector<size_t> GetDescOutputIndex(const std::vector<int64_t> &output_used_nums);
void GenReusedOutputDesc(const AnfNodePtr &anf_node, size_t index, size_t output_index, nlohmann::json *output_desc,
size_t out_size);
bool GenDataJson(const std::vector<AnfNodePtr> &compute_nodes, const std::vector<nlohmann::json> &compute_json,
void GenDataJson(const std::vector<AnfNodePtr> &compute_nodes, const std::vector<nlohmann::json> &compute_json,
std::vector<nlohmann::json> *op_list_json, const ANodeFusionDataTypeMap &spec_data_input);
bool AttrsJsonPostProcessing(const AnfNodePtr &anf_node, const OpInfoPtr &op_info_ptr,
nlohmann::json *attrs_json) override;

View File

@ -15,10 +15,6 @@
*/
#include "backend/kernel_compiler/tbe/tbe_json/single_tbe_json_creator.h"
#include <memory>
#include <list>
#include <string>
#include <algorithm>
#include "frontend/parallel/ops_info/ops_utils.h"
#include "backend/session/anf_runtime_algorithm.h"
#include "backend/kernel_compiler/tbe/tbe_adapter.h"

View File

@ -216,7 +216,6 @@ bool ParseAttrDefaultValue(const std::string &type, const std::string &value, nl
}
return true;
}
} // namespace
bool TbeJsonCreator::GenComputeJson(const AnfNodePtr &anf_node, nlohmann::json *compute_json) {
@ -534,7 +533,7 @@ bool TbeJsonCreator::AttrsJsonPreProcessing(const AnfNodePtr &anf_node, std::vec
tbe::TbeAdapter::CastAttrJsonPrePass(anf_node, attrs_ptr, attrs_json);
return true;
}
bool TbeJsonCreator::GenOutputDataDescJson(const AnfNodePtr &anf_node, nlohmann::json *compute_json) {
void TbeJsonCreator::GenOutputDataDescJson(const AnfNodePtr &anf_node, nlohmann::json *compute_json) {
MS_EXCEPTION_IF_NULL(anf_node);
MS_EXCEPTION_IF_NULL(compute_json);
auto op_desc = AnfAlgo::GetOutputDataDesc(anf_node);
@ -552,7 +551,6 @@ bool TbeJsonCreator::GenOutputDataDescJson(const AnfNodePtr &anf_node, nlohmann:
}
(*compute_json)[kJOutputDataDesc] = outputs_data_desc;
}
return true;
}
bool TbeJsonCreator::AttrsJsonPostProcessing(const AnfNodePtr &anf_node, const OpInfoPtr &op_info_ptr,

View File

@ -75,7 +75,7 @@ class TbeJsonCreator {
bool GenComputeJson(const AnfNodePtr &anf_node, nlohmann::json *compute_json);
virtual bool GenInputsJson(const AnfNodePtr &anf_node, nlohmann::json *compute_json) { return false; }
virtual bool GenOutputsJson(const AnfNodePtr &anf_node, nlohmann::json *compute_json) { return false; }
bool GenOutputDataDescJson(const AnfNodePtr &anf_node, nlohmann::json *compute_json);
void GenOutputDataDescJson(const AnfNodePtr &anf_node, nlohmann::json *compute_json);
void GenComputeCommonJson(const AnfNodePtr &anf_node, nlohmann::json *compute_json);
virtual void GenOtherJson(const AnfNodePtr &anf_node, nlohmann::json *compute_json) {}
void GenAttrsDescJson(const AnfNodePtr &anf_node, nlohmann::json *compute_json);

View File

@ -15,9 +15,6 @@
*/
#include "backend/kernel_compiler/tbe/tbe_json/tbe_json_utils.h"
#include <memory>
#include <string>
#include <vector>
#include "base/core_ops.h"
#include "backend/session/anf_runtime_algorithm.h"
#include "backend/kernel_compiler/tbe/tbe_convert_utils.h"

View File

@ -877,7 +877,7 @@ void GetOutputSizeList(const nlohmann::json &output_json, std::vector<size_t> *o
}
bool TbeKernelBuild::GetIOSize(const nlohmann::json &kernel_json, std::vector<size_t> *input_size_list,
std::vector<size_t> *output_size_list, const AnfNodePtr &anf_node) {
std::vector<size_t> *output_size_list) {
MS_EXCEPTION_IF_NULL(output_size_list);
MS_EXCEPTION_IF_NULL(input_size_list);
if (input_size_list == nullptr || output_size_list == nullptr) {
@ -891,8 +891,7 @@ bool TbeKernelBuild::GetIOSize(const nlohmann::json &kernel_json, std::vector<si
return true;
}
void GetRealInputSize(const nlohmann::json &input_json, const AnfNodePtr &anf_node, size_t i,
std::vector<size_t> *input_size_list, size_t *size_i) {
void GetRealInputSize(const nlohmann::json &input_json, std::vector<size_t> *input_size_list, size_t *size_i) {
for (size_t j = 0; j < input_json[kJShape].size(); ++j) {
if (input_json[kJShape][j] == -1) {
auto input_max_shape = input_json[kJRange];
@ -918,24 +917,22 @@ void GetInputSizeList2(const nlohmann::json &input_json, std::vector<size_t> *in
for (size_t m = 0; m < input_json[i].size(); m++) {
size_t size_i = 1;
if (input_json[i][m][kJValid] == false) {
std::string input_name = input_json[i][m][kJName];
continue;
}
GetRealInputSize(input_json[i][m], anf_node, i, input_size_list, &size_i);
GetRealInputSize(input_json[i][m], input_size_list, &size_i);
}
} else {
size_t size_i = 1;
if (input_json[i][kJValid] == false) {
std::string input_name = input_json[i][kJName];
continue;
}
GetRealInputSize(input_json[i], anf_node, i, input_size_list, &size_i);
GetRealInputSize(input_json[i], input_size_list, &size_i);
}
}
}
void GetRealOutputSize(const nlohmann::json &output_json, const AnfNodePtr &anf_node, size_t i,
std::vector<size_t> *output_size_list, size_t *size_i) {
void GetRealOutputSize(const nlohmann::json &output_json, size_t i, std::vector<size_t> *output_size_list,
size_t *size_i) {
for (size_t j = 0; j < output_json[kJShape].size(); ++j) {
if (output_json[kJShape][j] == -1) {
auto output_max_shape = output_json[kJRange];
@ -965,7 +962,7 @@ void GetOutputSizeList2(const nlohmann::json &output_json, std::vector<size_t> *
MS_LOG(INFO) << "Output name:" << output_name << " is optional, valid is false.";
continue;
}
GetRealOutputSize(output_json[i][m], anf_node, i, output_size_list, &size_i);
GetRealOutputSize(output_json[i][m], i, output_size_list, &size_i);
}
} else {
size_t size_i = 1;
@ -974,7 +971,7 @@ void GetOutputSizeList2(const nlohmann::json &output_json, std::vector<size_t> *
MS_LOG(INFO) << "Output name:" << output_name << " is optional, valid is false.";
continue;
}
GetRealOutputSize(output_json[i], anf_node, i, output_size_list, &size_i);
GetRealOutputSize(output_json[i], i, output_size_list, &size_i);
}
}
}

View File

@ -40,7 +40,7 @@ class TbeKernelBuild {
static bool GetIOSize2(const nlohmann::json &kernel_json, std::vector<size_t> *input_size_list,
std::vector<size_t> *output_size_list, const AnfNodePtr &anf_node);
static bool GetIOSize(const nlohmann::json &kernel_json, std::vector<size_t> *input_size_list,
std::vector<size_t> *output_size_list, const AnfNodePtr &anf_node);
std::vector<size_t> *output_size_list);
// Ub Fuison
static bool GenFusionScopeJson(const std::vector<AnfNodePtr> &input_nodes,
const std::vector<AnfNodePtr> &compute_nodes, nlohmann::json *fusion_json,

View File

@ -15,7 +15,6 @@
*/
#include "backend/kernel_compiler/tbe/tbe_kernel_mod.h"
#include <algorithm>
#include "runtime/rt.h"
#include "utils/ms_context.h"
#include "runtime/device/ascend/ge_runtime/task_info.h"

View File

@ -69,7 +69,7 @@ bool TbeOpParallelBuild(const std::vector<AnfNodePtr> &anf_nodes) {
// get size
std::vector<size_t> input_size_list;
std::vector<size_t> output_size_list;
(void)TbeKernelBuild::GetIOSize(kernel_json, &input_size_list, &output_size_list, anf_node);
(void)TbeKernelBuild::GetIOSize(kernel_json, &input_size_list, &output_size_list);
// search cache
const std::string &json_name = creator.json_name();
if (build_manger->SearchInCache(json_name, input_size_list, output_size_list, anf_node.get()) &&