fix code warnings for grid_sampler_2d_grad_cpu_kernel

Fix some errors for debug_services
This commit is contained in:
maning202007 2022-08-08 16:23:01 +08:00
parent 3021176441
commit d009d83dd2
5 changed files with 48 additions and 36 deletions

View File

@ -860,7 +860,7 @@ void DebugServices::ReadTensorFromNpy(const std::string &tensor_name, const std:
* Description: This function is to convert files in each directory from device format to host format and append the
* converted npy file name into NPYFilePool. It's for Ascend async dump only.
*/
void DebugServices::ConvertToHostFormat(const DirMap &dir_to_files_map, NPYFilePool *const result_list) {
void DebugServices::ConvertToHostFormat(const DirMap &dir_to_files_map, NPYFilePool *const result_list) const {
for (auto const &d : dir_to_files_map) {
std::vector<std::string> files_to_convert_in_dir;
std::vector<std::string> files_after_convert_in_dir;
@ -910,7 +910,7 @@ void DebugServices::ConvertToHostFormat(const DirMap &dir_to_files_map, NPYFileP
* append into NPYFilePool. It's for Ascend async dump only.
*/
void DebugServices::ProcessConvertToHostFormat(const std::vector<std::string> &files_after_convert_in_dir,
const std::string &dump_key, NPYFilePool *const result_list) {
const std::string &dump_key, NPYFilePool *const result_list) const {
std::string real_dump_iter_dir = RealPath(dump_key);
DIR *d_handle = opendir(real_dump_iter_dir.c_str());
if (d_handle == nullptr) {
@ -1003,7 +1003,7 @@ void DebugServices::ConvertReadTensors(std::vector<std::string> backend_name, st
void DebugServices::ConvertWatchPointNodes(const DumpFileMap &dump_dir_mapped_files,
const std::vector<ProtoDump> &proto_dump,
const std::string &specific_dump_dir, NPYFilePool *const result_list) {
const std::string &specific_dump_dir, NPYFilePool *const result_list) const {
DirMap dir_to_files_map;
for (const auto &node : proto_dump) {
std::string dump_name = node.dump_name;
@ -1114,7 +1114,7 @@ DebugServices::NPYFilePool DebugServices::PreProcessDumpDirSync(const std::strin
void DebugServices::ProcessConvertList(const DumpFileMap &dump_dir_mapped_files,
const std::string &prefix_dump_file_name, const std::string &specific_dump_dir,
DirMap *dir_to_files_map, NPYFilePool *const result_list) {
DirMap *dir_to_files_map, NPYFilePool *const result_list) const {
MS_EXCEPTION_IF_NULL(dir_to_files_map);
auto it = dump_dir_mapped_files.find(specific_dump_dir);
if (it == dump_dir_mapped_files.end()) {
@ -2158,7 +2158,7 @@ bool DebugServices::GetAttrsFromFilename(const std::string &file_name, std::stri
return true;
}
std::string DebugServices::RealPath(const std::string &input_path) {
std::string DebugServices::RealPath(const std::string &input_path) const {
if (input_path.length() >= PATH_MAX) {
MS_LOG(EXCEPTION) << "The length of path: " << input_path << " exceeds limit: " << PATH_MAX;
}
@ -2195,14 +2195,6 @@ std::string DebugServices::RealPath(const std::string &input_path) {
return std::string(real_path);
}
uint64_t DebugServices::BytestoUInt64(const std::vector<char> &buffer) {
#if defined(__APPLE__)
return *reinterpret_cast<const uint64_t *>(buffer.data());
#else
return le64toh(*reinterpret_cast<const uint64_t *>(buffer.data()));
#endif
}
bool DebugServices::TensorExistsInCurrent(const std::string &tensor_name) {
return tensor_loader_->TensorExistsInCurrent(tensor_name);
}

View File

@ -400,21 +400,21 @@ class DebugServices {
ProcessedNPYFiles ProcessNPYFilePool(const NPYFilePool &npy_file_pool) const;
static void ConvertToHostFormat(const DirMap &dir_to_files_map, NPYFilePool *const result_list);
void ConvertToHostFormat(const DirMap &dir_to_files_map, NPYFilePool *const result_list) const;
static void ProcessConvertToHostFormat(const std::vector<std::string> &files_after_convert_in_dir,
const std::string &dump_key, NPYFilePool *const result_list);
void ProcessConvertToHostFormat(const std::vector<std::string> &files_after_convert_in_dir,
const std::string &dump_key, NPYFilePool *const result_list) const;
void ConvertReadTensors(std::vector<std::string> backend_name, std::vector<size_t> slot,
std::vector<unsigned int> device_id, std::vector<unsigned int> iteration,
std::vector<unsigned int> root_graph_id, NPYFilePool *const result_list);
static void ConvertWatchPointNodes(const DumpFileMap &dump_dir_mapped_files, const std::vector<ProtoDump> &proto_dump,
const std::string &specific_dump_dir, NPYFilePool *const result_list);
void ConvertWatchPointNodes(const DumpFileMap &dump_dir_mapped_files, const std::vector<ProtoDump> &proto_dump,
const std::string &specific_dump_dir, NPYFilePool *const result_list) const;
static void ProcessConvertList(const DumpFileMap &dump_dir_mapped_files, const std::string &prefix_dump_file_name,
const std::string &specific_dump_dir, DirMap *dir_to_files_map,
NPYFilePool *const result_list);
void ProcessConvertList(const DumpFileMap &dump_dir_mapped_files, const std::string &prefix_dump_file_name,
const std::string &specific_dump_dir, DirMap *dir_to_files_map,
NPYFilePool *const result_list) const;
void GetTensorDataInfoAsync(const std::vector<ProtoDump> &proto_dump, const std::string &specific_dump_dir,
uint32_t iteration, uint32_t device_id, uint32_t root_graph_id,
@ -482,9 +482,7 @@ class DebugServices {
bool GetAttrsFromFilename(const std::string &file_name, std::string *const node_name, uint64_t *const task_id,
uint64_t *const stream_id) const;
static std::string RealPath(const std::string &input_path);
static uint64_t BytestoUInt64(const std::vector<char> &buffer);
std::string RealPath(const std::string &input_path) const;
bool TensorExistsInCurrent(const std::string &tensor_name);

View File

@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* Copyright 2020-2022 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.
@ -339,7 +339,7 @@ void DataDumper::OpDebugRegister() {
is_op_debug_ = true;
int64_t value = 0;
rtError_t rt_ret = rtGetRtCapability(FEATURE_TYPE_MEMORY, MEMORY_INFO_TS_LIMITED, &value);
rtError_t rt_ret = rtGetRtCapability(FEATURE_TYPE_MEMORY, static_cast<int32_t>(MEMORY_INFO_TS_LIMITED), &value);
if (rt_ret != RT_ERROR_NONE) {
MS_LOG(EXCEPTION) << "[DataDump] Call rt api rtGetRtCapability failed, ret = " << rt_ret;
}

View File

@ -1,5 +1,5 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
* Copyright 2021-2022 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.
@ -76,12 +76,13 @@ void GridSampler2DGradCpuKernelMod::ComputeTask(const std::vector<AddressPtr> &i
} else if (interpolation_mode_ == "nearest") {
interp = GridSamplerInterpolation::Nearest;
}
if (padding_mode_ == "zeros")
if (padding_mode_ == "zeros") {
padding = GridSamplerPadding::Zeros;
else if (padding_mode_ == "border")
} else if (padding_mode_ == "border") {
padding = GridSamplerPadding::Border;
else
} else {
padding = GridSamplerPadding::Reflection;
}
int64_t N = x_shape_[kZero];

View File

@ -1,5 +1,5 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
* Copyright 2021-2022 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.
@ -135,15 +135,26 @@ struct Vec256 {
Vec256<T> trunc() const { return map(std::trunc); }
static Vec256<T> LoadU(const void *ptr) {
Vec256 vec;
std::memcpy(vec.values, ptr, 32); // 32
auto cp_ret = memcpy_s(static_cast<void *>(vec.values), 32, ptr, 32);
if (cp_ret != EOK) {
MS_LOG(ERROR) << "memcpy_s failed. errorno is: " << cp_ret;
}
return vec;
}
static Vec256<T> LoadU(const void *ptr, int64_t count) {
Vec256 vec;
std::memcpy(vec.values, ptr, count * sizeof(T));
auto cp_ret = memcpy_s(static_cast<void *>(vec.values), count * sizeof(T), ptr, count * sizeof(T));
if (cp_ret != EOK) {
MS_LOG(ERROR) << "memcpy_s failed. errorno is: " << cp_ret;
}
return vec;
}
void store(void *ptr, int count = size()) const { std::memcpy(ptr, values, count * sizeof(T)); }
void store(void *ptr, int count = size()) const {
auto cp_ret = memcpy_s(ptr, count * sizeof(T), values, count * sizeof(T));
if (cp_ret != EOK) {
MS_LOG(ERROR) << "memcpy_s failed. errorno is: " << cp_ret;
}
}
const T &operator[](int idx) const { return values[idx]; }
T &operator[](int idx) { return values[idx]; }
int zero_mask() const {
@ -234,9 +245,15 @@ struct Vec256 {
Vec256<T> vec;
for (int64_t i = 0; i != size(); i++) {
if (op(values[i], other.values[i])) {
std::memset(static_cast<void *>(vec.values + i), 0xFF, sizeof(T));
auto ret = memset_s(static_cast<void *>(vec.values + i), sizeof(T), 0xFF, sizeof(T));
if (ret != 0) {
MS_LOG(ERROR) << "memset_s error, errorno(" << ret << ")";
}
} else {
std::memset(static_cast<void *>(vec.values + i), 0, sizeof(T));
auto ret = memset_s(static_cast<void *>(vec.values + i), sizeof(T), 0, sizeof(T));
if (ret != 0) {
MS_LOG(ERROR) << "memset_s error, errorno(" << ret << ")";
}
}
}
return vec;
@ -862,6 +879,10 @@ struct ApplyGridSample2D<T, hTwo, GridSamplerInterpolation::Nearest, padding, al
}
auto GGridPtr = (*GGridSlice)[0].data() + offset * 2;
std::memset(GGridPtr, 0, sizeof(T) * len * hTwo);
auto ret = memset_s(static_cast<void *>(GGridPtr), sizeof(T) * len * hTwo, 0, sizeof(T) * len * hTwo);
if (ret != 0) {
MS_LOG(ERROR) << "memset_s error, errorno(" << ret << ")";
}
}
};