forked from huawei/mindspore2022
Code fix
This commit is contained in:
parent
c9af7643d7
commit
d2a44c02da
|
|
@ -296,8 +296,8 @@ bool Common::FileExists(const std::string &filepath) {
|
|||
|
||||
struct GlogLogDirRegister {
|
||||
GlogLogDirRegister() {
|
||||
const char *logtostderr = ::getenv("GLOG_logtostderr");
|
||||
const char *log_dir = ::getenv("GLOG_log_dir");
|
||||
const char *logtostderr = std::getenv("GLOG_logtostderr");
|
||||
const char *log_dir = std::getenv("GLOG_log_dir");
|
||||
if (logtostderr != nullptr && log_dir != nullptr) {
|
||||
std::string logtostderr_str = std::string(logtostderr);
|
||||
std::string log_dir_str = std::string(log_dir);
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class DumpJsonParser {
|
|||
void UpdateNeedDumpKernels(NotNull<const session::KernelGraph *> kernel_graph);
|
||||
|
||||
void ClearGraph() { graphs_.clear(); }
|
||||
void SaveGraph(session::KernelGraph *graph) { graphs_.emplace_back(graph); }
|
||||
void SaveGraph(session::KernelGraph *graph) { (void)graphs_.emplace_back(graph); }
|
||||
std::vector<session::KernelGraph *> &graphs() { return graphs_; }
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -405,8 +405,9 @@ void DebugServices::ReadTensorFromNpy(const std::string &file_name, std::string
|
|||
MS_LOG(ERROR) << "Failed to read file (In ReadTensorFromNpy) " << file_path;
|
||||
return;
|
||||
}
|
||||
uint16_t header_len = *reinterpret_cast<uint16_t *>(buffer->data() + 8);
|
||||
std::string header(buffer->data() + 9, header_len);
|
||||
constexpr int header_len_offset = 8;
|
||||
uint16_t header_len = *reinterpret_cast<uint16_t *>(buffer->data() + header_len_offset);
|
||||
std::string header(buffer->data() + header_len_offset + 1, header_len);
|
||||
std::size_t type_i = header.find("descr") + 10;
|
||||
*tensor_type = header.substr(type_i, 2);
|
||||
std::size_t shape_i_open = header.find("(");
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ using KernelGraph = mindspore::session::KernelGraph;
|
|||
using AnfAlgo = mindspore::session::AnfRuntimeAlgorithm;
|
||||
|
||||
namespace mindspore {
|
||||
|
||||
static const size_t PARAMETER_OUTPUT_INDEX = 0;
|
||||
|
||||
std::vector<int> CheckRealOutput(const std::string &node_name, const size_t &output_size) {
|
||||
|
|
@ -158,5 +157,4 @@ void ReadDataAndDump(const CNodePtr &cnode, const KernelLaunchInfo *launch_info_
|
|||
bool last_kernel = !AnfAlgo::IsInplaceNode(cnode, "skip");
|
||||
debugger->PostExecuteNode(cnode, last_kernel);
|
||||
}
|
||||
|
||||
} // namespace mindspore
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ bool IsMulOverflow(const T &x, const T &y, const T &max, const T &min) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
bool IsDivOverflow(const T &x, const T &y, const T &max, const T &min) {
|
||||
bool IsDivOverflow(const T &x, const T &y, const T &min) {
|
||||
return (x == min && static_cast<int64_t>(y) == -1);
|
||||
}
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ bool IsSignedIntOverflow(T x, T y, OpType opType) {
|
|||
}
|
||||
|
||||
if (opType == OpType::DIV || opType == OpType::MOD) {
|
||||
return IsDivOverflow<T>(x, y, max, min);
|
||||
return IsDivOverflow<T>(x, y, min);
|
||||
}
|
||||
|
||||
MS_LOG(EXCEPTION) << "Unsupported operation type.";
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ AnfNodePtr BoolScalarEliminate::operator()(const OptimizerPtr &optimizer, const
|
|||
|
||||
AnfNodeIndexSet node_idx_set = iter->second;
|
||||
for (auto &item : node_idx_set) {
|
||||
manager->Replace(item.first, vnode);
|
||||
(void)manager->Replace(item.first, vnode);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -809,27 +809,27 @@ static std::vector<ActionItem> CommonPipeline() {
|
|||
std::vector<ActionItem> actions;
|
||||
|
||||
// Parse the python ast to ANF graph
|
||||
actions.emplace_back(std::make_pair("parse", ParseAction));
|
||||
(void)actions.emplace_back(std::make_pair("parse", ParseAction));
|
||||
|
||||
// Resolve the python func
|
||||
actions.emplace_back(std::make_pair("symbol_resolve", SymbolResolveAction));
|
||||
(void)actions.emplace_back(std::make_pair("symbol_resolve", SymbolResolveAction));
|
||||
|
||||
auto multi_graphs = parallel::CostModelContext::GetInstance()->is_multi_subgraphs();
|
||||
if (!multi_graphs) {
|
||||
actions.emplace_back(std::make_pair("combine_like_graphs", CombineLikeGraphs));
|
||||
(void)actions.emplace_back(std::make_pair("combine_like_graphs", CombineLikeGraphs));
|
||||
}
|
||||
|
||||
actions.emplace_back(std::make_pair("inference_opt_prepare", InferenceOptPrepareAction));
|
||||
(void)actions.emplace_back(std::make_pair("inference_opt_prepare", InferenceOptPrepareAction));
|
||||
// Evaluate type and shape, and specialize
|
||||
actions.emplace_back(std::make_pair("abstract_specialize", AbstractSpecializeAction));
|
||||
(void)actions.emplace_back(std::make_pair("abstract_specialize", AbstractSpecializeAction));
|
||||
// Auto-monad for side-effects handling.
|
||||
actions.emplace_back(std::make_pair("auto_monad", AutoMonadAction));
|
||||
(void)actions.emplace_back(std::make_pair("auto_monad", AutoMonadAction));
|
||||
// Do data structure simplifications and inline
|
||||
actions.emplace_back(std::make_pair("inline", OptInlineAction));
|
||||
(void)actions.emplace_back(std::make_pair("inline", OptInlineAction));
|
||||
// Add pre-ad, post-inline python pass stub
|
||||
actions.emplace_back(std::make_pair("py_pre_ad", PreAdActionPyStub));
|
||||
(void)actions.emplace_back(std::make_pair("py_pre_ad", PreAdActionPyStub));
|
||||
// Do PipelineSplit
|
||||
actions.emplace_back(std::make_pair("pipeline_split", PipelineSplitAction));
|
||||
(void)actions.emplace_back(std::make_pair("pipeline_split", PipelineSplitAction));
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
|
@ -837,13 +837,13 @@ static std::vector<ActionItem> CommonPipeline() {
|
|||
std::vector<ActionItem> GePipeline() {
|
||||
auto actions = CommonPipeline();
|
||||
// optimize
|
||||
actions.emplace_back(std::make_pair("optimize", GeOptimizeAction));
|
||||
(void)actions.emplace_back(std::make_pair("optimize", GeOptimizeAction));
|
||||
// Add opt-stage python pass stub
|
||||
actions.emplace_back(std::make_pair("py_opt", OptActionGePyStub));
|
||||
actions.emplace_back(std::make_pair("remove_value_node_duplications", RemoveValueNodeDuplicationsAction));
|
||||
actions.emplace_back(std::make_pair("auto_monad_reorder", OrderEnforceAction));
|
||||
actions.emplace_back(std::make_pair("remove_monad_from_random_op", RemoveRandomOpMonadAction));
|
||||
actions.emplace_back(std::make_pair("validate", ValidateAction));
|
||||
(void)actions.emplace_back(std::make_pair("py_opt", OptActionGePyStub));
|
||||
(void)actions.emplace_back(std::make_pair("remove_value_node_duplications", RemoveValueNodeDuplicationsAction));
|
||||
(void)actions.emplace_back(std::make_pair("auto_monad_reorder", OrderEnforceAction));
|
||||
(void)actions.emplace_back(std::make_pair("remove_monad_from_random_op", RemoveRandomOpMonadAction));
|
||||
(void)actions.emplace_back(std::make_pair("validate", ValidateAction));
|
||||
return actions;
|
||||
}
|
||||
|
||||
|
|
@ -851,31 +851,31 @@ std::vector<ActionItem> VmPipeline() {
|
|||
auto actions = CommonPipeline();
|
||||
|
||||
// optimize
|
||||
actions.emplace_back(std::make_pair("optimize", VmOptimizeAction));
|
||||
(void)actions.emplace_back(std::make_pair("optimize", VmOptimizeAction));
|
||||
|
||||
// Add opt-stage python pass stub
|
||||
actions.emplace_back(std::make_pair("py_opt", OptActionVmPyStub));
|
||||
(void)actions.emplace_back(std::make_pair("py_opt", OptActionVmPyStub));
|
||||
|
||||
actions.emplace_back(std::make_pair("auto_monad_reorder", OrderEnforceAction));
|
||||
(void)actions.emplace_back(std::make_pair("auto_monad_reorder", OrderEnforceAction));
|
||||
|
||||
actions.emplace_back(std::make_pair("remove_monad_from_random_op", RemoveRandomOpMonadAction));
|
||||
(void)actions.emplace_back(std::make_pair("remove_monad_from_random_op", RemoveRandomOpMonadAction));
|
||||
|
||||
actions.emplace_back(std::make_pair("validate", ValidateAction));
|
||||
(void)actions.emplace_back(std::make_pair("validate", ValidateAction));
|
||||
#if ((defined ENABLE_CPU) && (!defined _WIN32))
|
||||
if (ps::PSContext::instance()->is_worker()) {
|
||||
std::string server_mode = ps::PSContext::instance()->server_mode();
|
||||
if (server_mode == ps::kServerModeFL || server_mode == ps::kServerModeHybrid) {
|
||||
actions.emplace_back(std::make_pair("worker", StartFLWorkerAction));
|
||||
(void)actions.emplace_back(std::make_pair("worker", StartFLWorkerAction));
|
||||
} else {
|
||||
actions.emplace_back(std::make_pair("worker", StartPSWorkerAction));
|
||||
(void)actions.emplace_back(std::make_pair("worker", StartPSWorkerAction));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// compile the ANF graph
|
||||
actions.emplace_back(std::make_pair("task_emit", TaskEmitAction));
|
||||
(void)actions.emplace_back(std::make_pair("task_emit", TaskEmitAction));
|
||||
|
||||
// to execute the graph
|
||||
actions.emplace_back(std::make_pair("execute", ExecuteAction));
|
||||
(void)actions.emplace_back(std::make_pair("execute", ExecuteAction));
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
|
@ -883,34 +883,34 @@ std::vector<ActionItem> VmPipeline() {
|
|||
std::vector<ActionItem> BackendPipeline() {
|
||||
std::vector<ActionItem> actions;
|
||||
// compile the ANF graph
|
||||
actions.emplace_back(std::make_pair("task_emit", TaskEmitAction));
|
||||
(void)actions.emplace_back(std::make_pair("task_emit", TaskEmitAction));
|
||||
// to execute the graph
|
||||
actions.emplace_back(std::make_pair("execute", ExecuteAction));
|
||||
(void)actions.emplace_back(std::make_pair("execute", ExecuteAction));
|
||||
return actions;
|
||||
}
|
||||
|
||||
#if ((defined ENABLE_CPU) && (!defined _WIN32))
|
||||
std::vector<ActionItem> ServerPipeline() {
|
||||
auto actions = CommonPipeline();
|
||||
actions.emplace_back(std::make_pair("optimize", VmOptimizeAction));
|
||||
actions.emplace_back(std::make_pair("validate", ValidateAction));
|
||||
actions.emplace_back(std::make_pair("server", StartServerAction));
|
||||
(void)actions.emplace_back(std::make_pair("optimize", VmOptimizeAction));
|
||||
(void)actions.emplace_back(std::make_pair("validate", ValidateAction));
|
||||
(void)actions.emplace_back(std::make_pair("server", StartServerAction));
|
||||
return actions;
|
||||
}
|
||||
|
||||
std::vector<ActionItem> PServerPipeline() {
|
||||
auto actions = CommonPipeline();
|
||||
actions.emplace_back(std::make_pair("optimize", VmOptimizeAction));
|
||||
actions.emplace_back(std::make_pair("auto_monad_reorder", OrderEnforceAction));
|
||||
actions.emplace_back(std::make_pair("remove_monad_from_random_op", RemoveRandomOpMonadAction));
|
||||
actions.emplace_back(std::make_pair("validate", ValidateAction));
|
||||
actions.emplace_back(std::make_pair("pserver", StartPSServerAction));
|
||||
(void)actions.emplace_back(std::make_pair("optimize", VmOptimizeAction));
|
||||
(void)actions.emplace_back(std::make_pair("auto_monad_reorder", OrderEnforceAction));
|
||||
(void)actions.emplace_back(std::make_pair("remove_monad_from_random_op", RemoveRandomOpMonadAction));
|
||||
(void)actions.emplace_back(std::make_pair("validate", ValidateAction));
|
||||
(void)actions.emplace_back(std::make_pair("pserver", StartPSServerAction));
|
||||
return actions;
|
||||
}
|
||||
|
||||
std::vector<ActionItem> PSchedulerPipeline() {
|
||||
std::vector<ActionItem> actions;
|
||||
actions.emplace_back(std::make_pair("scheduler", StartPSSchedulerAction));
|
||||
(void)actions.emplace_back(std::make_pair("scheduler", StartPSSchedulerAction));
|
||||
return actions;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
#include "mindspore/core/ir/cell.h"
|
||||
|
||||
namespace mindspore::parse {
|
||||
static std::unordered_set<std::string> cell_input_args_;
|
||||
static std::unordered_set<std::string> cell_input_args_ = {};
|
||||
static const std::set<std::string> ignore_judge_dynamic_cell = {
|
||||
"Cell mindspore.nn.layer.basic.Dense", "Cell mindspore.nn.probability.distribution.normal.Normal",
|
||||
"Cell src.transformer.create_attn_mask.CreateAttentionMaskFromInputMask", "Cell mindspore.nn.layer.math.MatMul"};
|
||||
|
|
@ -59,7 +59,7 @@ void DynamicParser::ParseInputArgs(const std::shared_ptr<parse::ParseAst> &ast,
|
|||
for (size_t i = 1; i < args.size(); i++) {
|
||||
std::string arg_name = py::cast<std::string>(args[i].attr("arg"));
|
||||
MS_LOG(DEBUG) << "Input arg name: " << arg_name;
|
||||
cell_input_args_.emplace(arg_name);
|
||||
(void)cell_input_args_.emplace(arg_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -569,7 +569,7 @@ class SideEffectFinder {
|
|||
size_t input_index = 0;
|
||||
// Support tuple index is negative
|
||||
if (top_index < 0) {
|
||||
if (cnode->size() + top_index < 0) {
|
||||
if (SizeToLong(cnode->size()) + top_index < 0) {
|
||||
MS_LOG(EXCEPTION) << "Invalid make_tuple: " << cnode->DebugString() << " index=" << top_index;
|
||||
}
|
||||
input_index = static_cast<size_t>(cnode->size() + top_index);
|
||||
|
|
|
|||
|
|
@ -420,19 +420,19 @@ REGISTER_PYBIND_DEFINE(Tensor, ([](const py::module *m) {
|
|||
return TensorPy::MakeTensor(input, type_ptr);
|
||||
}),
|
||||
py::arg("input"), py::arg("dtype") = nullptr)
|
||||
.def(py::init([](py::float_ input, const TypePtr &type_ptr) {
|
||||
.def(py::init([](const py::float_ input, const TypePtr &type_ptr) {
|
||||
return TensorPy::MakeTensor(py::array(input), type_ptr);
|
||||
}),
|
||||
py::arg("input"), py::arg("dtype") = nullptr)
|
||||
.def(py::init([](py::int_ input, const TypePtr &type_ptr) {
|
||||
.def(py::init([](const py::int_ input, const TypePtr &type_ptr) {
|
||||
return TensorPy::MakeTensor(py::array(input), type_ptr);
|
||||
}),
|
||||
py::arg("input"), py::arg("dtype") = nullptr)
|
||||
.def(py::init([](py::list input, const TypePtr &type_ptr) {
|
||||
.def(py::init([](const py::list &input, const TypePtr &type_ptr) {
|
||||
return TensorPy::MakeTensor(py::array(input), type_ptr);
|
||||
}),
|
||||
py::arg("input"), py::arg("dtype") = nullptr)
|
||||
.def(py::init([](py::tuple input, const TypePtr &type_ptr) {
|
||||
.def(py::init([](const py::tuple &input, const TypePtr &type_ptr) {
|
||||
return TensorPy::MakeTensor(py::array(input), type_ptr);
|
||||
}),
|
||||
py::arg("input"), py::arg("dtype") = nullptr)
|
||||
|
|
|
|||
|
|
@ -43,19 +43,19 @@ void PhiloxGenerator::JumpStep(uint64_t step) {
|
|||
counter_[3] = static_cast<uint32_t>(max_counter >> kShiftNum);
|
||||
}
|
||||
|
||||
std::array<uint32_t, gResultNum> PhiloxGenerator::Compute(const std::array<uint32_t, gResultNum> &counter_,
|
||||
const std::array<uint32_t, 2> &key_var_) {
|
||||
std::array<uint32_t, gResultNum> PhiloxGenerator::Compute(const std::array<uint32_t, gResultNum> &counter,
|
||||
const std::array<uint32_t, 2> &key_var) const {
|
||||
std::array<uint32_t, gResultNum> min_value;
|
||||
std::array<uint32_t, gResultNum> max_value;
|
||||
for (size_t i = 0; i < gResultNum; i += 2) {
|
||||
uint64_t temp = static_cast<uint64_t>(keyConstant[i]) * counter_[i];
|
||||
uint64_t temp = static_cast<uint64_t>(keyConstant[i]) * counter[i];
|
||||
min_value[i] = static_cast<uint32_t>(temp);
|
||||
max_value[i] = static_cast<uint32_t>(temp >> kShiftNum);
|
||||
}
|
||||
std::array<uint32_t, gResultNum> result;
|
||||
result[0] = (max_value[2] ^ counter_[1] ^ key_var_[0]);
|
||||
result[0] = (max_value[2] ^ counter[1] ^ key_var[0]);
|
||||
result[1] = min_value[2];
|
||||
result[2] = (max_value[0] ^ counter_[3] ^ key_var_[0]);
|
||||
result[2] = (max_value[0] ^ counter[3] ^ key_var[0]);
|
||||
result[3] = min_value[0];
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@ class PhiloxGenerator {
|
|||
|
||||
void JumpStep(uint64_t step);
|
||||
|
||||
std::array<uint32_t, gResultNum> Compute(const std::array<uint32_t, gResultNum> &counter_,
|
||||
const std::array<uint32_t, 2> &key_var_);
|
||||
std::array<uint32_t, gResultNum> Compute(const std::array<uint32_t, gResultNum> &counter,
|
||||
const std::array<uint32_t, 2> &key_var) const;
|
||||
|
||||
std::array<uint32_t, gResultNum> operator()();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue