Browse Source

use the correct filename for solver output log

tags/v1.2.0-rc1
laiyongqiang 4 years ago
parent
commit
15240c3614
2 changed files with 24 additions and 5 deletions
  1. +20
    -5
      mindspore/ccsrc/backend/optimizer/somas/somas_solver_pre.cc
  2. +4
    -0
      mindspore/ccsrc/backend/optimizer/somas/somas_solver_pre.h

+ 20
- 5
mindspore/ccsrc/backend/optimizer/somas/somas_solver_pre.cc View File

@@ -94,8 +94,15 @@ Status SomasSolverPre::Solving(const session::KernelGraph *graph,
void SomasSolverPre::Log(const session::KernelGraph *graph, void SomasSolverPre::Log(const session::KernelGraph *graph,
const unordered_map<size_t, SomasSolverTensorDescPtr> &tensors, const unordered_map<size_t, SomasSolverTensorDescPtr> &tensors,
const std::vector<DynamicBitSet> *pConstraints, const vector<vector<size_t>> &continuous_v) { const std::vector<DynamicBitSet> *pConstraints, const vector<vector<size_t>> &continuous_v) {
MS_LOG(INFO) << "SomasSolver::Log Writing somas-input.txt..";
SolverInputLog(graph, tensors, pConstraints, continuous_v);
SolverOutputLog(graph, tensors);
}


void SomasSolverPre::SolverInputLog(const session::KernelGraph *graph,
const unordered_map<size_t, SomasSolverTensorDescPtr> &tensors,
const std::vector<DynamicBitSet> *pConstraints,
const vector<vector<size_t>> &continuous_v) {
MS_LOG(INFO) << "SomasSolver::Log Writing somas-input.txt..";
auto context_ptr = MsContext::GetInstance(); auto context_ptr = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(context_ptr); MS_EXCEPTION_IF_NULL(context_ptr);
auto save_graphs_path = context_ptr->get_param<std::string>(MS_CTX_SAVE_GRAPHS_PATH); auto save_graphs_path = context_ptr->get_param<std::string>(MS_CTX_SAVE_GRAPHS_PATH);
@@ -140,16 +147,24 @@ void SomasSolverPre::Log(const session::KernelGraph *graph,
} }
ofs.close(); ofs.close();


MS_LOG(INFO) << "SomasSolver::Log Writing somas-output.txt..";
MS_LOG(INFO) << "SomasSolver input Log done";
}

void SomasSolverPre::SolverOutputLog(const session::KernelGraph *graph,
const unordered_map<size_t, SomasSolverTensorDescPtr> &tensors) const {
MS_LOG(INFO) << "SomasSolver::Log Writing somas output...";
auto context_ptr = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(context_ptr);
auto save_graphs_path = context_ptr->get_param<std::string>(MS_CTX_SAVE_GRAPHS_PATH);
std::string out_filename = std::string out_filename =
save_graphs_path + "/" + "somas_solver_output_" + std::to_string(graph->graph_id()) + ".ir"; save_graphs_path + "/" + "somas_solver_output_" + std::to_string(graph->graph_id()) + ".ir";
if (out_filename.size() > PATH_MAX) { if (out_filename.size() > PATH_MAX) {
MS_LOG(ERROR) << "File path " << out_filename << " is too long."; MS_LOG(ERROR) << "File path " << out_filename << " is too long.";
return; return;
} }
auto out_real_path = Common::GetRealPath(filename);
auto out_real_path = Common::GetRealPath(out_filename);
if (!out_real_path.has_value()) { if (!out_real_path.has_value()) {
MS_LOG(ERROR) << "Get real path failed. path=" << filename;
MS_LOG(ERROR) << "Get real path failed. path=" << out_filename;
return; return;
} }


@@ -181,7 +196,7 @@ void SomasSolverPre::Log(const session::KernelGraph *graph,
} }
ofs_out.close(); ofs_out.close();


MS_LOG(INFO) << "SomasSolver::Log done";
MS_LOG(INFO) << "SomasSolver output Log done";
} }
} // namespace somas } // namespace somas
} // namespace mindspore } // namespace mindspore

+ 4
- 0
mindspore/ccsrc/backend/optimizer/somas/somas_solver_pre.h View File

@@ -187,6 +187,10 @@ class SomasSolverPre {


private: private:
size_t max_offset_; size_t max_offset_;
void SolverInputLog(const session::KernelGraph *graph, const unordered_map<size_t, SomasSolverTensorDescPtr> &tensors,
const std::vector<DynamicBitSet> *pConstraints_v, const vector<vector<size_t>> &continuous_v);
void SolverOutputLog(const session::KernelGraph *graph,
const unordered_map<size_t, SomasSolverTensorDescPtr> &tensors) const;
}; };
using SomasSolverPrePtr = std::shared_ptr<SomasSolverPre>; using SomasSolverPrePtr = std::shared_ptr<SomasSolverPre>;
} // namespace somas } // namespace somas


Loading…
Cancel
Save