!24184 clean code
Merge pull request !24184 from hwjiaorui/clean-code-master
This commit is contained in:
commit
c9bbe14fcc
|
@ -36,7 +36,6 @@ namespace mindspore {
|
||||||
namespace kernel {
|
namespace kernel {
|
||||||
namespace tbe {
|
namespace tbe {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr int kInvalid = -1;
|
constexpr int kInvalid = -1;
|
||||||
constexpr int kFloat = 0;
|
constexpr int kFloat = 0;
|
||||||
constexpr int kFloat16 = 1;
|
constexpr int kFloat16 = 1;
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "backend/kernel_compiler/tbe/tbe_json/fusion_tbe_json_creator.h"
|
#include "backend/kernel_compiler/tbe/tbe_json/fusion_tbe_json_creator.h"
|
||||||
#include <memory>
|
|
||||||
#include <list>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -87,9 +85,7 @@ bool FusionBuildTbeJsonCreator::GenOpListJson(const FusionScopeInfo &fusion_scop
|
||||||
if (!TbeAdapter::GetSpecDataInput(fusion_scope_info, &spec_data_input)) {
|
if (!TbeAdapter::GetSpecDataInput(fusion_scope_info, &spec_data_input)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!GenDataJson(compute_nodes, compute_list, fusion_json, spec_data_input)) {
|
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;
|
|
||||||
}
|
|
||||||
(*fusion_json).insert((*fusion_json).end(), compute_list.begin(), compute_list.end());
|
(*fusion_json).insert((*fusion_json).end(), compute_list.begin(), compute_list.end());
|
||||||
MS_LOG(DEBUG) << "End";
|
MS_LOG(DEBUG) << "End";
|
||||||
return true;
|
return true;
|
||||||
|
@ -124,7 +120,7 @@ bool FusionBuildTbeJsonCreator::CheckInput(const FusionScopeInfo &fusion_scope_i
|
||||||
return true;
|
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,
|
const std::vector<nlohmann::json> &compute_json,
|
||||||
std::vector<nlohmann::json> *op_list_json,
|
std::vector<nlohmann::json> *op_list_json,
|
||||||
const ANodeFusionDataTypeMap &spec_data_input) {
|
const ANodeFusionDataTypeMap &spec_data_input) {
|
||||||
|
@ -155,7 +151,6 @@ bool FusionBuildTbeJsonCreator::GenDataJson(const std::vector<AnfNodePtr> &compu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MS_LOG(DEBUG) << "End.";
|
MS_LOG(DEBUG) << "End.";
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
AnfNodePtr FusionBuildTbeJsonCreator::GetInputCNode(const AnfNodePtr &node, const nlohmann::json &input_desc) {
|
AnfNodePtr FusionBuildTbeJsonCreator::GetInputCNode(const AnfNodePtr &node, const nlohmann::json &input_desc) {
|
||||||
auto input_name = GetJsonValue<std::string>(input_desc, kJName);
|
auto input_name = GetJsonValue<std::string>(input_desc, kJName);
|
||||||
|
|
|
@ -34,7 +34,7 @@ class FusionBuildTbeJsonCreator : public TbeJsonCreator {
|
||||||
std::vector<size_t> GetDescOutputIndex(const std::vector<int64_t> &output_used_nums);
|
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,
|
void GenReusedOutputDesc(const AnfNodePtr &anf_node, size_t index, size_t output_index, nlohmann::json *output_desc,
|
||||||
size_t out_size);
|
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);
|
std::vector<nlohmann::json> *op_list_json, const ANodeFusionDataTypeMap &spec_data_input);
|
||||||
bool AttrsJsonPostProcessing(const AnfNodePtr &anf_node, const OpInfoPtr &op_info_ptr,
|
bool AttrsJsonPostProcessing(const AnfNodePtr &anf_node, const OpInfoPtr &op_info_ptr,
|
||||||
nlohmann::json *attrs_json) override;
|
nlohmann::json *attrs_json) override;
|
||||||
|
|
|
@ -15,10 +15,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "backend/kernel_compiler/tbe/tbe_json/single_tbe_json_creator.h"
|
#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 "frontend/parallel/ops_info/ops_utils.h"
|
||||||
#include "backend/session/anf_runtime_algorithm.h"
|
#include "backend/session/anf_runtime_algorithm.h"
|
||||||
#include "backend/kernel_compiler/tbe/tbe_adapter.h"
|
#include "backend/kernel_compiler/tbe/tbe_adapter.h"
|
||||||
|
|
|
@ -216,7 +216,6 @@ bool ParseAttrDefaultValue(const std::string &type, const std::string &value, nl
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
bool TbeJsonCreator::GenComputeJson(const AnfNodePtr &anf_node, nlohmann::json *compute_json) {
|
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);
|
tbe::TbeAdapter::CastAttrJsonPrePass(anf_node, attrs_ptr, attrs_json);
|
||||||
return true;
|
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(anf_node);
|
||||||
MS_EXCEPTION_IF_NULL(compute_json);
|
MS_EXCEPTION_IF_NULL(compute_json);
|
||||||
auto op_desc = AnfAlgo::GetOutputDataDesc(anf_node);
|
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;
|
(*compute_json)[kJOutputDataDesc] = outputs_data_desc;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TbeJsonCreator::AttrsJsonPostProcessing(const AnfNodePtr &anf_node, const OpInfoPtr &op_info_ptr,
|
bool TbeJsonCreator::AttrsJsonPostProcessing(const AnfNodePtr &anf_node, const OpInfoPtr &op_info_ptr,
|
||||||
|
|
|
@ -75,7 +75,7 @@ class TbeJsonCreator {
|
||||||
bool GenComputeJson(const AnfNodePtr &anf_node, nlohmann::json *compute_json);
|
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 GenInputsJson(const AnfNodePtr &anf_node, nlohmann::json *compute_json) { return false; }
|
||||||
virtual bool GenOutputsJson(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);
|
void GenComputeCommonJson(const AnfNodePtr &anf_node, nlohmann::json *compute_json);
|
||||||
virtual void GenOtherJson(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);
|
void GenAttrsDescJson(const AnfNodePtr &anf_node, nlohmann::json *compute_json);
|
||||||
|
|
|
@ -15,9 +15,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "backend/kernel_compiler/tbe/tbe_json/tbe_json_utils.h"
|
#include "backend/kernel_compiler/tbe/tbe_json/tbe_json_utils.h"
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include "base/core_ops.h"
|
#include "base/core_ops.h"
|
||||||
#include "backend/session/anf_runtime_algorithm.h"
|
#include "backend/session/anf_runtime_algorithm.h"
|
||||||
#include "backend/kernel_compiler/tbe/tbe_convert_utils.h"
|
#include "backend/kernel_compiler/tbe/tbe_convert_utils.h"
|
||||||
|
|
|
@ -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,
|
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(output_size_list);
|
||||||
MS_EXCEPTION_IF_NULL(input_size_list);
|
MS_EXCEPTION_IF_NULL(input_size_list);
|
||||||
if (input_size_list == nullptr || output_size_list == nullptr) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetRealInputSize(const nlohmann::json &input_json, const AnfNodePtr &anf_node, size_t i,
|
void GetRealInputSize(const nlohmann::json &input_json, std::vector<size_t> *input_size_list, size_t *size_i) {
|
||||||
std::vector<size_t> *input_size_list, size_t *size_i) {
|
|
||||||
for (size_t j = 0; j < input_json[kJShape].size(); ++j) {
|
for (size_t j = 0; j < input_json[kJShape].size(); ++j) {
|
||||||
if (input_json[kJShape][j] == -1) {
|
if (input_json[kJShape][j] == -1) {
|
||||||
auto input_max_shape = input_json[kJRange];
|
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++) {
|
for (size_t m = 0; m < input_json[i].size(); m++) {
|
||||||
size_t size_i = 1;
|
size_t size_i = 1;
|
||||||
if (input_json[i][m][kJValid] == false) {
|
if (input_json[i][m][kJValid] == false) {
|
||||||
std::string input_name = input_json[i][m][kJName];
|
|
||||||
continue;
|
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 {
|
} else {
|
||||||
size_t size_i = 1;
|
size_t size_i = 1;
|
||||||
if (input_json[i][kJValid] == false) {
|
if (input_json[i][kJValid] == false) {
|
||||||
std::string input_name = input_json[i][kJName];
|
|
||||||
continue;
|
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,
|
void GetRealOutputSize(const nlohmann::json &output_json, size_t i, std::vector<size_t> *output_size_list,
|
||||||
std::vector<size_t> *output_size_list, size_t *size_i) {
|
size_t *size_i) {
|
||||||
for (size_t j = 0; j < output_json[kJShape].size(); ++j) {
|
for (size_t j = 0; j < output_json[kJShape].size(); ++j) {
|
||||||
if (output_json[kJShape][j] == -1) {
|
if (output_json[kJShape][j] == -1) {
|
||||||
auto output_max_shape = output_json[kJRange];
|
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.";
|
MS_LOG(INFO) << "Output name:" << output_name << " is optional, valid is false.";
|
||||||
continue;
|
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 {
|
} else {
|
||||||
size_t size_i = 1;
|
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.";
|
MS_LOG(INFO) << "Output name:" << output_name << " is optional, valid is false.";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
GetRealOutputSize(output_json[i], anf_node, i, output_size_list, &size_i);
|
GetRealOutputSize(output_json[i], i, output_size_list, &size_i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ class TbeKernelBuild {
|
||||||
static bool GetIOSize2(const nlohmann::json &kernel_json, std::vector<size_t> *input_size_list,
|
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);
|
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,
|
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
|
// Ub Fuison
|
||||||
static bool GenFusionScopeJson(const std::vector<AnfNodePtr> &input_nodes,
|
static bool GenFusionScopeJson(const std::vector<AnfNodePtr> &input_nodes,
|
||||||
const std::vector<AnfNodePtr> &compute_nodes, nlohmann::json *fusion_json,
|
const std::vector<AnfNodePtr> &compute_nodes, nlohmann::json *fusion_json,
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "backend/kernel_compiler/tbe/tbe_kernel_mod.h"
|
#include "backend/kernel_compiler/tbe/tbe_kernel_mod.h"
|
||||||
#include <algorithm>
|
|
||||||
#include "runtime/rt.h"
|
#include "runtime/rt.h"
|
||||||
#include "utils/ms_context.h"
|
#include "utils/ms_context.h"
|
||||||
#include "runtime/device/ascend/ge_runtime/task_info.h"
|
#include "runtime/device/ascend/ge_runtime/task_info.h"
|
||||||
|
|
|
@ -69,7 +69,7 @@ bool TbeOpParallelBuild(const std::vector<AnfNodePtr> &anf_nodes) {
|
||||||
// get size
|
// get size
|
||||||
std::vector<size_t> input_size_list;
|
std::vector<size_t> input_size_list;
|
||||||
std::vector<size_t> output_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
|
// search cache
|
||||||
const std::string &json_name = creator.json_name();
|
const std::string &json_name = creator.json_name();
|
||||||
if (build_manger->SearchInCache(json_name, input_size_list, output_size_list, anf_node.get()) &&
|
if (build_manger->SearchInCache(json_name, input_size_list, output_size_list, anf_node.get()) &&
|
||||||
|
|
Loading…
Reference in New Issue