parent
da9452ee5e
commit
c577952c9a
@ -0,0 +1,15 @@
|
||||
{
|
||||
"DumpSettings": {
|
||||
"net_name": "ResNet50",
|
||||
"mode": 1,
|
||||
"iteration": 0,
|
||||
"kernels": ["Default/Conv2D-op2", "Default/TensorAdd-op10"]
|
||||
},
|
||||
|
||||
"DumpSettingsSpec": {
|
||||
"net_name": "net name eg:ResNet50",
|
||||
"mode": "0: dump all kernels, 1: dump kernels in kernels list",
|
||||
"iteration": "specified iteration ",
|
||||
"kernels": "op's full scope name which need to be dump"
|
||||
}
|
||||
}
|
@ -1 +1 @@
|
||||
Subproject commit 1c2672868fda8b1d012c99e5aca73725ac869ba9
|
||||
Subproject commit 18cf690152add623ffbddfbbb4674d1b34484ca7
|
@ -0,0 +1,125 @@
|
||||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "debug/common.h"
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include "utils/system/env.h"
|
||||
#include "utils/system/file_system.h"
|
||||
#include "utils/log_adapter.h"
|
||||
#include "utils/context/ms_context.h"
|
||||
|
||||
namespace mindspore {
|
||||
std::optional<std::string> Common::GetRealPath(const std::string &input_path) {
|
||||
std::string out_path;
|
||||
auto path_split_pos = input_path.find_last_of('/');
|
||||
if (path_split_pos == std::string::npos) {
|
||||
path_split_pos = input_path.find_last_of('\\');
|
||||
}
|
||||
// get real path
|
||||
char real_path[PATH_MAX] = {0};
|
||||
if (path_split_pos != std::string::npos) {
|
||||
std::string prefix_path = input_path.substr(0, path_split_pos);
|
||||
if (prefix_path.length() >= PATH_MAX) {
|
||||
MS_LOG(ERROR) << "Prefix path is too longer!";
|
||||
return std::nullopt;
|
||||
}
|
||||
std::string last_path = input_path.substr(path_split_pos, input_path.length() - path_split_pos);
|
||||
auto ret = CreateNotExistDirs(prefix_path);
|
||||
if (!ret) {
|
||||
MS_LOG(ERROR) << "CreateNotExistDirs Failed!";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (nullptr == realpath(prefix_path.c_str(), real_path)) {
|
||||
MS_LOG(ERROR) << "dir " << prefix_path << " does not exit.";
|
||||
return std::nullopt;
|
||||
}
|
||||
out_path = std::string(real_path) + last_path;
|
||||
}
|
||||
|
||||
if (path_split_pos == std::string::npos) {
|
||||
if (input_path.length() >= PATH_MAX) {
|
||||
MS_LOG(ERROR) << "Prefix path is too longer!";
|
||||
return std::nullopt;
|
||||
}
|
||||
if (nullptr == realpath(input_path.c_str(), real_path)) {
|
||||
MS_LOG(ERROR) << "File " << input_path << " does not exit, it will be created.";
|
||||
}
|
||||
out_path = std::string(real_path);
|
||||
}
|
||||
return out_path;
|
||||
}
|
||||
|
||||
bool Common::CreateNotExistDirs(const std::string &path) {
|
||||
std::shared_ptr<system::FileSystem> fs = system::Env::GetFileSystem();
|
||||
MS_EXCEPTION_IF_NULL(fs);
|
||||
char temp_path[PATH_MAX] = {0};
|
||||
if (path.length() > PATH_MAX) {
|
||||
MS_LOG(ERROR) << "Path lens is max than " << PATH_MAX;
|
||||
return false;
|
||||
}
|
||||
for (uint32_t i = 0; i < path.length(); i++) {
|
||||
temp_path[i] = path[i];
|
||||
if (temp_path[i] == '\\' || temp_path[i] == '/') {
|
||||
if (i != 0) {
|
||||
char tmp_char = temp_path[i];
|
||||
temp_path[i] = '\0';
|
||||
std::string path_handle(temp_path);
|
||||
if (!fs->FileExist(temp_path)) {
|
||||
MS_LOG(INFO) << "Dir " << path_handle << " does not exit, creating...";
|
||||
if (!fs->CreateDir(temp_path)) {
|
||||
MS_LOG(ERROR) << "Create " << path_handle << " dir error";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
temp_path[i] = tmp_char;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!fs->FileExist(path)) {
|
||||
MS_LOG(INFO) << "Dir " << path << " does not exit, creating...";
|
||||
if (!fs->CreateDir(path)) {
|
||||
MS_LOG(ERROR) << "Create " << path << " dir error";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::optional<std::string> Common::GetConfigFile(const std::string &env) {
|
||||
if (env.empty()) {
|
||||
MS_LOG(EXCEPTION) << "Invalid env";
|
||||
}
|
||||
auto config_path_str = std::getenv(env.c_str());
|
||||
if (config_path_str == nullptr) {
|
||||
MS_LOG(ERROR) << "Please export env:" << env;
|
||||
return {};
|
||||
}
|
||||
MS_LOG(INFO) << "Async Dump Getenv env:" << env << "=" << config_path_str;
|
||||
|
||||
std::string dump_config_file(config_path_str);
|
||||
std::shared_ptr<system::FileSystem> fs = system::Env::GetFileSystem();
|
||||
MS_EXCEPTION_IF_NULL(fs);
|
||||
if (!fs->FileExist(dump_config_file)) {
|
||||
MS_LOG(ERROR) << dump_config_file << " not exist.";
|
||||
return {};
|
||||
}
|
||||
return dump_config_file;
|
||||
}
|
||||
} // namespace mindspore
|
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef MINDSPORE_MINDSPORE_CCSRC_DEBUG_COMMON_H_
|
||||
#define MINDSPORE_MINDSPORE_CCSRC_DEBUG_COMMON_H_
|
||||
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include "utils/contract.h"
|
||||
|
||||
namespace mindspore {
|
||||
class Common {
|
||||
public:
|
||||
Common() = default;
|
||||
~Common() = default;
|
||||
static std::optional<std::string> GetRealPath(const std::string &input_path);
|
||||
static std::optional<std::string> GetConfigFile(const std::string &env);
|
||||
|
||||
private:
|
||||
static bool CreateNotExistDirs(const std::string &path);
|
||||
};
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_MINDSPORE_CCSRC_DEBUG_COMMON_H_
|
@ -0,0 +1,152 @@
|
||||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "debug/data_dump_parser.h"
|
||||
|
||||
#include <fstream>
|
||||
#include "utils/context/ms_context.h"
|
||||
#include "debug/common.h"
|
||||
|
||||
constexpr auto kDataDumpConfigPtah = "DATA_DUMP_CONFIG_PATH";
|
||||
constexpr auto kEnableDataDump = "ENABLE_DATA_DUMP";
|
||||
constexpr auto kDataDumpPath = "DATA_DUMP_PATH";
|
||||
namespace mindspore {
|
||||
void DataDumpParser::ResetParam() {
|
||||
enable_ = false;
|
||||
net_name_.clear();
|
||||
dump_mode_ = 0;
|
||||
dump_step_ = 0;
|
||||
kernel_set_.clear();
|
||||
}
|
||||
|
||||
bool DataDumpParser::DumpEnabled() const {
|
||||
auto enable_dump = std::getenv(kEnableDataDump);
|
||||
if (!enable_dump) {
|
||||
MS_LOG(WARNING) << "[DataDump] enable dump is null. Please export ENABLE_DATA_DUMP";
|
||||
return false;
|
||||
}
|
||||
|
||||
auto enabled = std::atoi(enable_dump);
|
||||
if (enabled != 1) {
|
||||
MS_LOG(WARNING) << "[DataDump] Please export ENABLE_DATA_DUMP=1";
|
||||
return false;
|
||||
}
|
||||
|
||||
auto context = MsContext::GetInstance();
|
||||
MS_EXCEPTION_IF_NULL(context);
|
||||
if (context->execution_mode() == kPynativeMode) {
|
||||
MS_LOG(EXCEPTION) << "[DataDump] PyNative mode not support data dump";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::optional<std::string> DataDumpParser::GetDumpPath() const {
|
||||
auto dump_path = std::getenv(kDataDumpPath);
|
||||
if (!dump_path) {
|
||||
MS_LOG(ERROR) << "[DataDump] dump path is null. Please export DATA_DUMP_PATH";
|
||||
return {};
|
||||
}
|
||||
std::string dump_path_str(dump_path);
|
||||
return dump_path_str;
|
||||
}
|
||||
|
||||
void DataDumpParser::ParseDumpConfig() {
|
||||
std::lock_guard<std::mutex> guard(lock_);
|
||||
MS_LOG(INFO) << "[DataDump] parse start";
|
||||
if (!DumpEnabled()) {
|
||||
MS_LOG(INFO) << "[DataDump] dump not enable";
|
||||
return;
|
||||
}
|
||||
|
||||
ResetParam();
|
||||
|
||||
auto dump_config_file = Common::GetConfigFile(kDataDumpConfigPtah);
|
||||
if (!dump_config_file.has_value()) {
|
||||
MS_LOG(EXCEPTION) << "[DataDump] Get config file failed";
|
||||
}
|
||||
|
||||
std::ifstream json_file(dump_config_file.value());
|
||||
if (!json_file.is_open()) {
|
||||
MS_LOG(EXCEPTION) << "[DataDump] " << dump_config_file.value() << " open failed.";
|
||||
}
|
||||
|
||||
nlohmann::json j;
|
||||
json_file >> j;
|
||||
if (j.find("DumpSettings") == j.end()) {
|
||||
MS_LOG(EXCEPTION) << "[DataDump] DumpSettings is not exist.";
|
||||
}
|
||||
|
||||
nlohmann::json dump_settings = j.at("DumpSettings");
|
||||
// convert json to string
|
||||
std::stringstream ss;
|
||||
ss << dump_settings;
|
||||
std::string cfg = ss.str();
|
||||
MS_LOG(INFO) << "[DataDump] Async dump settings Json: " << cfg;
|
||||
if (!IsConfigExist(dump_settings)) {
|
||||
MS_LOG(EXCEPTION) << "[DataDump] Async dump json invalid";
|
||||
}
|
||||
|
||||
if (!ParseDumpSetting(dump_settings)) {
|
||||
MS_LOG(EXCEPTION) << "[DataDump] Parse dump json failed";
|
||||
}
|
||||
}
|
||||
|
||||
bool DataDumpParser::NeedDump(const std::string &op_full_name) const {
|
||||
if (!DumpEnabled()) {
|
||||
return false;
|
||||
}
|
||||
if (dump_mode_ == 0) {
|
||||
return true;
|
||||
}
|
||||
auto iter = kernel_set_.find(op_full_name);
|
||||
return iter != kernel_set_.end();
|
||||
}
|
||||
|
||||
bool DataDumpParser::IsConfigExist(const nlohmann::json &dump_settings) const {
|
||||
if (dump_settings.find("mode") == dump_settings.end() || dump_settings.find("net_name") == dump_settings.end() ||
|
||||
dump_settings.find("iteration") == dump_settings.end() || dump_settings.find("kernels") == dump_settings.end()) {
|
||||
MS_LOG(ERROR) << "[DataDump] DumpSettings keys are not exist.";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DataDumpParser::ParseDumpSetting(const nlohmann::json &dump_settings) {
|
||||
auto mode = dump_settings.at("mode");
|
||||
auto net_name = dump_settings.at("net_name");
|
||||
auto iteration = dump_settings.at("iteration");
|
||||
auto kernels = dump_settings.at("kernels");
|
||||
if (!(mode.is_number() && net_name.is_string() && iteration.is_number() && kernels.is_array())) {
|
||||
MS_LOG(ERROR) << "[DataDump] Element's type in Dump config json is invalid.";
|
||||
enable_ = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
enable_ = true;
|
||||
auto context_ptr = MsContext::GetInstance();
|
||||
MS_EXCEPTION_IF_NULL(context_ptr);
|
||||
dump_mode_ = mode;
|
||||
net_name_ = net_name;
|
||||
dump_step_ = iteration;
|
||||
for (const auto &kernel : kernels) {
|
||||
auto kernel_str = kernel.dump();
|
||||
kernel_str.erase(std::remove(kernel_str.begin(), kernel_str.end(), '\"'), kernel_str.end());
|
||||
MS_LOG(INFO) << "[DataDump] Need dump kernel:" << kernel_str;
|
||||
kernel_set_.insert(kernel_str);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace mindspore
|
@ -0,0 +1,61 @@
|
||||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef MINDSPORE_MINDSPORE_CCSRC_DEBUG_ASYNC_DUMP_JSON_PARE_H_
|
||||
#define MINDSPORE_MINDSPORE_CCSRC_DEBUG_ASYNC_DUMP_JSON_PARE_H_
|
||||
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "common/utils.h"
|
||||
|
||||
namespace mindspore {
|
||||
class DataDumpParser {
|
||||
public:
|
||||
static DataDumpParser &GetInstance() {
|
||||
static DataDumpParser instance;
|
||||
return instance;
|
||||
}
|
||||
void ParseDumpConfig();
|
||||
bool NeedDump(const std::string &op_full_name) const;
|
||||
bool DumpEnabled() const;
|
||||
std::optional<std::string> GetDumpPath() const;
|
||||
bool enable() const { return enable_; }
|
||||
const std::string &net_name() const { return net_name_; }
|
||||
uint32_t dump_mode() const { return dump_mode_; }
|
||||
uint32_t dump_step() const { return dump_step_; }
|
||||
const std::set<std::string> &kernel_set() const { return kernel_set_; }
|
||||
|
||||
private:
|
||||
DataDumpParser() = default;
|
||||
virtual ~DataDumpParser() = default;
|
||||
DISABLE_COPY_AND_ASSIGN(DataDumpParser);
|
||||
|
||||
void ResetParam();
|
||||
bool IsConfigExist(const nlohmann::json &dump_settings) const;
|
||||
bool ParseDumpSetting(const nlohmann::json &dump_settings);
|
||||
|
||||
std::mutex lock_;
|
||||
bool enable_{false};
|
||||
std::string net_name_;
|
||||
uint32_t dump_mode_{0};
|
||||
uint32_t dump_step_{0};
|
||||
std::set<std::string> kernel_set_;
|
||||
};
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_MINDSPORE_CCSRC_DEBUG_ASYNC_DUMP_JSON_PARE_H_
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef MINDSPORE_MINDSPORE_CCSRC_DEVICE_ASCEND_DUMP_DATADUMP_H_
|
||||
#define MINDSPORE_MINDSPORE_CCSRC_DEVICE_ASCEND_DUMP_DATADUMP_H_
|
||||
#ifdef ENABLE_DATA_DUMP
|
||||
#include <tuple>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "session/kernel_graph.h"
|
||||
|
||||
namespace aicpu {
|
||||
namespace dump {
|
||||
class OpMappingInfo;
|
||||
class Task;
|
||||
} // namespace dump
|
||||
} // namespace aicpu
|
||||
namespace mindspore {
|
||||
namespace device {
|
||||
namespace ascend {
|
||||
// tuple(op_name, task_id, stream_id, args)
|
||||
using RuntimeInfo = std::tuple<uint32_t, uint32_t, void *>;
|
||||
class DataDumper {
|
||||
public:
|
||||
DataDumper(const session::KernelGraph *kernel_graph,
|
||||
const std::map<std::string, std::shared_ptr<RuntimeInfo>> &runtime_info_map)
|
||||
: load_flag_(false),
|
||||
dev_load_mem_(nullptr),
|
||||
dev_unload_mem_(nullptr),
|
||||
kernel_graph_(kernel_graph),
|
||||
runtime_info_map_(runtime_info_map) {}
|
||||
~DataDumper();
|
||||
void LoadDumpInfo();
|
||||
|
||||
void UnloadDumpInfo();
|
||||
|
||||
private:
|
||||
void ReleaseDevMem(void **ptr) const;
|
||||
bool KernelNeedDump(const CNodePtr &kernel) const;
|
||||
void SetOpMappingInfo(NotNull<aicpu::dump::OpMappingInfo *> dump_info) const;
|
||||
void ConstructDumpTask(NotNull<const CNodePtr &> kernel, NotNull<aicpu::dump::Task *> dump_task) const;
|
||||
|
||||
bool load_flag_;
|
||||
void *dev_load_mem_;
|
||||
void *dev_unload_mem_;
|
||||
std::vector<std::string> dump_kernel_names_;
|
||||
const session::KernelGraph *kernel_graph_;
|
||||
std::map<std::string, std::shared_ptr<RuntimeInfo>> runtime_info_map_;
|
||||
};
|
||||
} // namespace ascend
|
||||
} // namespace device
|
||||
} // namespace mindspore
|
||||
#endif
|
||||
#endif // MINDSPORE_MINDSPORE_CCSRC_DEVICE_ASCEND_DUMP_DATADUMP_H_
|
@ -0,0 +1,120 @@
|
||||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef MINDSPORE_MINDSPORE_CCSRC_DEVICE_ASCEND_DUMP_GE_DUMP_H_
|
||||
#define MINDSPORE_MINDSPORE_CCSRC_DEVICE_ASCEND_DUMP_GE_DUMP_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "proto/ge_dtype.pb.h"
|
||||
#include "ir/dtype/type_id.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace device {
|
||||
namespace ascend {
|
||||
static ge::proto::DataType GetGeDataType(TypeId type_id) {
|
||||
static const std::map<TypeId, ge::proto::DataType> data_type_map = {
|
||||
{TypeId::kTypeUnknown, ge::proto::DT_UNDEFINED}, {TypeId::kNumberTypeFloat32, ge::proto::DT_FLOAT},
|
||||
{TypeId::kNumberTypeFloat16, ge::proto::DT_FLOAT16}, {TypeId::kNumberTypeInt8, ge::proto::DT_INT8},
|
||||
{TypeId::kNumberTypeUInt8, ge::proto::DT_UINT8}, {TypeId::kNumberTypeInt16, ge::proto::DT_INT16},
|
||||
{TypeId::kNumberTypeUInt16, ge::proto::DT_UINT16}, {TypeId::kNumberTypeInt32, ge::proto::DT_INT32},
|
||||
{TypeId::kNumberTypeInt64, ge::proto::DT_INT64}, {TypeId::kNumberTypeUInt32, ge::proto::DT_UINT32},
|
||||
{TypeId::kNumberTypeUInt64, ge::proto::DT_UINT64}, {TypeId::kNumberTypeBool, ge::proto::DT_BOOL},
|
||||
{TypeId::kNumberTypeFloat64, ge::proto::DT_DOUBLE},
|
||||
};
|
||||
MS_LOG(INFO) << "Vm origin type_id:" << type_id;
|
||||
auto iter = data_type_map.find(type_id);
|
||||
if (iter == data_type_map.end()) {
|
||||
MS_LOG(EXCEPTION) << "Invalid data type:" << type_id;
|
||||
}
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
enum GeFormat {
|
||||
kFormat_NCHW = 0, // NCHW
|
||||
kFormat_NHWC, // NHWC
|
||||
kFormat_ND, // Nd Tensor
|
||||
kFormat_NC1HWC0, // NC1HWC0
|
||||
kFormat_FRACTAL_Z, // FRACTAL_Z
|
||||
kFormat_NC1C0HWPAD,
|
||||
kFormat_NHWC1C0,
|
||||
kFormat_FSR_NCHW,
|
||||
kFormat_FRACTAL_DECONV,
|
||||
kFormat_C1HWNC0,
|
||||
kFormat_FRACTAL_DECONV_TRANSPOSE,
|
||||
kFormat_FRACTAL_DECONV_SP_STRIDE_TRANS,
|
||||
kFormat_NC1HWC0_C04, // NC1HWC0, C0 =4
|
||||
kFormat_FRACTAL_Z_C04, // FRACZ, C0 =4
|
||||
kFormat_CHWN,
|
||||
kFormat_FRACTAL_DECONV_SP_STRIDE8_TRANS,
|
||||
kFormat_HWCN,
|
||||
kFormat_NC1KHKWHWC0, // KH,KW kernel h& kernel w maxpooling max output format
|
||||
kFormat_BN_WEIGHT,
|
||||
kFormat_FILTER_HWCK, // filter input tensor format
|
||||
kFormat_HASHTABLE_LOOKUP_LOOKUPS = 20,
|
||||
kFormat_HASHTABLE_LOOKUP_KEYS,
|
||||
kFormat_HASHTABLE_LOOKUP_VALUE,
|
||||
kFormat_HASHTABLE_LOOKUP_OUTPUT,
|
||||
kFormat_HASHTABLE_LOOKUP_HITS = 24,
|
||||
kFormat_C1HWNCoC0,
|
||||
kFormat_MD,
|
||||
kFormat_NDHWC,
|
||||
kFormat_FRACTAL_ZZ,
|
||||
kFormat_FRACTAL_NZ,
|
||||
kFormat_NCDHW,
|
||||
kFormat_DHWCN, // 3D filter input tensor format
|
||||
kFormat_NDC1HWC0,
|
||||
kFormat_FRACTAL_Z_3D,
|
||||
kFormat_CN,
|
||||
kFormat_NC,
|
||||
kFormat_DHWNC,
|
||||
kFormat_FRACTAL_Z_3D_TRANSPOSE, // 3D filter(transpose) input tensor format
|
||||
kFormat_RESERVED,
|
||||
kFormat_ALL
|
||||
};
|
||||
|
||||
static GeFormat GetGeFormat(const std::string &format, size_t shape_size) {
|
||||
static const std::map<std::string, GeFormat> format_map = {
|
||||
// default format: nchw, fractal_nz?
|
||||
{kOpFormat_DEFAULT, kFormat_NCHW},
|
||||
{kOpFormat_NC1KHKWHWC0, kFormat_NC1KHKWHWC0},
|
||||
{kOpFormat_ND, kFormat_ND},
|
||||
{kOpFormat_NCHW, kFormat_NCHW},
|
||||
{kOpFormat_NHWC, kFormat_NHWC},
|
||||
{kOpFormat_HWCN, kFormat_HWCN},
|
||||
{kOpFormat_NC1HWC0, kFormat_NC1HWC0},
|
||||
{kOpFormat_FRAC_Z, kFormat_FRACTAL_Z},
|
||||
{kOpFormat_FRAC_NZ, kFormat_FRACTAL_NZ},
|
||||
{kOpFormat_C1HWNCoC0, kFormat_C1HWNCoC0},
|
||||
{kOpFormat_NC1HWC0_C04, kFormat_NC1HWC0_C04},
|
||||
{kOpFormat_FRACTAL_Z_C04, kFormat_FRACTAL_Z_C04},
|
||||
{kOpFormat_NDHWC, kFormat_NDHWC},
|
||||
};
|
||||
MS_LOG(INFO) << "GetGeFormat format:" << format << " shape_size:" << shape_size;
|
||||
if (format == kOpFormat_DEFAULT) {
|
||||
return shape_size == 4 ? kFormat_NCHW : kFormat_ND;
|
||||
}
|
||||
auto iter = format_map.find(format);
|
||||
if (iter == format_map.end()) {
|
||||
MS_LOG(EXCEPTION) << "Invalid format:" << format;
|
||||
}
|
||||
return iter->second;
|
||||
}
|
||||
} // namespace ascend
|
||||
} // namespace device
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_MINDSPORE_CCSRC_DEVICE_ASCEND_DUMP_GE_DUMP_H_
|
@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package ge.proto;
|
||||
|
||||
enum DataType
|
||||
{
|
||||
DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set.
|
||||
DT_FLOAT = 1; // float type
|
||||
DT_FLOAT16 = 2; // fp16 type
|
||||
DT_INT8 = 3; // int8 type
|
||||
DT_UINT8 = 4; // uint8 type
|
||||
DT_INT16 = 5; // int16 type
|
||||
DT_UINT16 = 6; // uint16 type
|
||||
DT_INT32 = 7; //
|
||||
DT_INT64 = 8; // int64 type
|
||||
DT_UINT32 = 9; // unsigned int32
|
||||
DT_UINT64 = 10; // unsigned int64
|
||||
DT_BOOL = 11; // bool type
|
||||
DT_DOUBLE = 12; // double type
|
||||
DT_STRING = 13; // string type
|
||||
DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */
|
||||
DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */
|
||||
DT_COMPLEX64 = 16; // complex64 type
|
||||
DT_COMPLEX128 = 17; // complex128 type
|
||||
DT_QINT8 = 18; // qint8 type
|
||||
DT_QINT16 = 19; // qint16 type
|
||||
DT_QINT32 = 20; // qint32 type
|
||||
DT_QUINT8 = 21; // quint8 type
|
||||
DT_QUINT16 = 22; // quint16 type
|
||||
DT_RESOURCE = 23; // resource type
|
||||
DT_STRING_REF = 24; // string_ref type
|
||||
DT_DUAL = 25; /**< dual output type */
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
syntax = "proto3";
|
||||
package aicpu.dump;
|
||||
|
||||
message Shape {
|
||||
repeated uint64 dim = 1;
|
||||
}
|
||||
|
||||
message Output {
|
||||
int32 data_type = 1;
|
||||
int32 format = 2;
|
||||
Shape shape = 3;
|
||||
uint64 address = 4;
|
||||
string original_name = 5;
|
||||
int32 original_output_index = 6;
|
||||
int32 original_output_data_type = 7;
|
||||
int32 original_output_format = 8;
|
||||
uint64 size = 9;
|
||||
};
|
||||
|
||||
message Input {
|
||||
int32 data_type = 1;
|
||||
int32 format = 2;
|
||||
Shape shape = 3;
|
||||
uint64 address = 4;
|
||||
uint64 size = 5;
|
||||
}
|
||||
|
||||
message Op {
|
||||
string op_name = 1;
|
||||
string op_type = 2;
|
||||
};
|
||||
|
||||
message Task {
|
||||
uint32 task_id = 1;
|
||||
uint32 stream_id = 2;
|
||||
Op op = 3;
|
||||
repeated Output output = 4;
|
||||
bool end_graph = 5;
|
||||
repeated Input input = 6;
|
||||
};
|
||||
|
||||
message OpMappingInfo {
|
||||
string dump_path = 1;
|
||||
oneof model_name_param {
|
||||
string model_name = 2;
|
||||
}
|
||||
oneof model_id_param {
|
||||
uint32 model_id = 3;
|
||||
}
|
||||
oneof step_id {
|
||||
uint64 step_id_addr = 4;
|
||||
}
|
||||
oneof iterations_per_loop {
|
||||
uint64 iterations_per_loop_addr = 5;
|
||||
}
|
||||
oneof loop_cond {
|
||||
uint64 loop_cond_addr = 6;
|
||||
}
|
||||
uint32 flag = 7; // 0x01 load, 0x00 unload
|
||||
repeated Task task = 8;
|
||||
string dump_step = 9;
|
||||
};
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue