!40713 fix build op error

Merge pull request !40713 from jjfeing/update_hisi_run_822
This commit is contained in:
i-robot 2022-08-24 01:51:08 +00:00 committed by Gitee
commit 4ca32882d0
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
9 changed files with 30 additions and 22 deletions

View File

@ -14,6 +14,7 @@
* limitations under the License.
*/
#include "backend/common/session/anf_runtime_algorithm.h"
#include <memory>
#include <algorithm>
#include <map>
@ -669,19 +670,6 @@ void AnfRuntimeAlgorithm::SetCoreType(const AnfNodePtr &node, const std::string
AnfAlgo::SetSelectKernelBuildInfo(builder->Build(), node.get());
}
std::string AnfRuntimeAlgorithm::GetCoreType(const AnfNodePtr &node) {
MS_EXCEPTION_IF_NULL(node);
auto kernel_info = dynamic_cast<device::KernelInfo *>(node->kernel_info());
if (kernel_info == nullptr) {
return "";
}
auto build_info = kernel_info->select_kernel_build_info();
if (build_info == nullptr) {
return "";
}
return build_info->core_type();
}
void AnfRuntimeAlgorithm::SetOutputDataDesc(const AnfNodePtr &node, const std::vector<nlohmann::json> &desc) {
MS_EXCEPTION_IF_NULL(node);
auto builder =

View File

@ -128,7 +128,6 @@ class BACKEND_EXPORT AnfRuntimeAlgorithm {
static std::vector<nlohmann::json> GetOutputDataDesc(const AnfNodePtr &node);
// core type
static void SetCoreType(const AnfNodePtr &node, const std::string &core_type);
static std::string GetCoreType(const AnfNodePtr &node);
// set select kernel_build_info
static void SetSelectKernelBuildInfo(const kernel::KernelBuildInfoPtr &select_kernel_build_info, AnfNode *node);
// get select kernel_build_info

View File

@ -38,6 +38,7 @@
#include "include/common/utils/anfalgo.h"
#include "backend/common/session/kernel_build_client.h"
#include "plugin/device/ascend/kernel/aicpu/aicpu_kernel_load.h"
#include "plugin/device/ascend/hal/hardware/ascend_utils.h"
#ifndef ENABLE_SECURITY
#include "plugin/device/ascend/hal/device/profiling/profiling_manager.h"
#include "plugin/device/ascend/hal/device/profiling/profiling_utils.h"
@ -388,6 +389,7 @@ bool AscendKernelRuntime::Init() {
if (rt_ret != RT_ERROR_NONE) {
MS_LOG(EXCEPTION) << "Reg SetTaskFailCallback failed, error: " << rt_ret;
}
PlatformInfoInitialization();
} catch (const std::exception &e) {
const string &error_message = ErrorManager::GetInstance().GetErrorMessage();
if (!error_message.empty() && error_message.find(kUnknowErrorString) == string::npos) {

View File

@ -115,9 +115,6 @@ void AscendGraphOptimization::OptimizeGraphWithoutDeviceInfo(const KernelGraphPt
// add all graphs to manager first, so that don't have to make new manager in following passes.
memo_.clear();
AddGraphToManager(NOT_NULL(graph), NOT_NULL(graph_manager_));
PlatformInfoInitialization();
memo_.clear();
IRFusionOptimization(graph);
}

View File

@ -35,7 +35,7 @@ bool FusionBuildTbeJsonCreator::GenJson(const FusionScopeInfo &fusion_scope_info
MS_EXCEPTION_IF_NULL(fusion_json);
MS_LOG(DEBUG) << "Start Generate Fusion Json, Fusion Node: " << fusion_scope_info.full_name;
nlohmann::json soc_info_json = kernel::tbe::TbeUtils::GenSocInfo();
soc_info_json[kJCoreType] = fusion_scope_info.core_type;
soc_info_json[kJCoreType] = GetCoreType(fusion_scope_info.compute_nodes.front());
(*fusion_json)[kJSocInfo] = soc_info_json;
std::vector<nlohmann::json> op_list_json;

View File

@ -42,7 +42,7 @@ bool SingleTbeJsonCreator::GenJson(const AnfNodePtr &anf_node, nlohmann::json *k
MS_LOG(ERROR) << "Anf Node [" << op_name << "] generate op_list json failed";
return false;
}
auto core_type = AnfAlgo::GetCoreType(anf_node);
auto core_type = GetCoreType(anf_node);
soc_info_json[kJCoreType] = core_type;
(*kernel_json)[kJSocInfo] = soc_info_json;
(*kernel_json)[kJOpList] = op_list;

View File

@ -19,6 +19,7 @@
#include <map>
#include <utility>
#include <algorithm>
#include "common/util/platform_info.h"
#include "backend/common/session/anf_runtime_algorithm.h"
#include "include/common/utils/anfalgo.h"
#include "kernel/common_utils.h"
@ -34,6 +35,8 @@
namespace mindspore::kernel {
namespace {
constexpr auto kAICORE = "AiCore";
constexpr auto kVectorCore = "VectorCore";
static std::unordered_map<std::string, ATTR_DTYPE> type_attr_dtype_map = {
{kVTypeInt, ATTR_DTYPE::ATTR_INT32},
{kVTypeInt64, ATTR_DTYPE::ATTR_INT64},
@ -228,6 +231,26 @@ bool ParseAttrDefaultValue(const std::string &type, const std::string &value, nl
}
} // namespace
std::string TbeJsonCreator::GetCoreType(const AnfNodePtr &node) {
MS_EXCEPTION_IF_NULL(node);
std::string core_type;
auto kernel_info = dynamic_cast<device::KernelInfo *>(node->kernel_info());
if (kernel_info != nullptr && kernel_info->select_kernel_build_info() != nullptr) {
core_type = kernel_info->select_kernel_build_info()->core_type();
}
if (core_type.empty()) {
fe::PlatformInfo platform_info;
fe::OptionalInfo optional_info;
if (fe::PlatformInfoManager::Instance().GetPlatformInfoWithOutSocVersion(platform_info, optional_info) != 0) {
MS_LOG(WARNING) << "Get platform info failed.";
core_type = kAICORE;
} else {
core_type = (platform_info.ai_core_spec.cube_vector_split == 1) ? kVectorCore : kAICORE;
}
}
return core_type;
}
bool TbeJsonCreator::GenComputeJson(const AnfNodePtr &anf_node, nlohmann::json *compute_json) {
MS_EXCEPTION_IF_NULL(anf_node);
MS_EXCEPTION_IF_NULL(compute_json);

View File

@ -73,6 +73,7 @@ class TbeJsonCreator {
virtual bool GenInputsJson(const AnfNodePtr &anf_node, nlohmann::json *compute_json) { return false; }
protected:
static std::string GetCoreType(const AnfNodePtr &node);
bool GenComputeJson(const AnfNodePtr &anf_node, nlohmann::json *compute_json);
virtual bool GenOutputsJson(const AnfNodePtr &anf_node, nlohmann::json *compute_json) { return false; }
void GenOutputDataDescJson(const AnfNodePtr &anf_node, nlohmann::json *compute_json) const;

View File

@ -332,12 +332,10 @@ void GetFusionScopeOutputNodeList(session::KernelGraph *kernel_graph,
fusion_info.all_outputs_from_last_node = true;
for (size_t node_idx = 0; node_idx < fusion_info.anf_nodes.size(); ++node_idx) {
const auto &node = fusion_info.anf_nodes[node_idx];
auto core_type = AnfAlgo::GetCoreType(node);
fusion_info.core_type = core_type;
size_t old_output_num = fusion_info.outputs_list.size();
if (common::AnfAlgo::GetOutputTensorNum(node) == 1) {
auto use_nodes = manager->node_users()[node];
for (auto use_node : use_nodes) {
for (const auto &use_node : use_nodes) {
// Do not think of updatestate as real output,
// Ensuring normal fusion requires eliminating the node of the updatestate
if (common::AnfAlgo::CheckPrimitiveType(use_node.first, prim::kPrimUpdateState)) {