Merge pull request !6244 from cjh9368/fix_issuetags/v1.0.0
| @@ -232,7 +232,7 @@ if (BUILD_DEVICE) | |||
| if (NOT WIN32) | |||
| add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/benchmark) | |||
| add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test) | |||
| add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/time_profile) | |||
| add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/time_profiler) | |||
| endif () | |||
| endif () | |||
| @@ -6,21 +6,21 @@ set(COMMON_SRC | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../src/common/utils.cc | |||
| ) | |||
| add_executable(timeprofile | |||
| add_executable(timeprofiler | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/main.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/time_profile.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/time_profiler.cc | |||
| ${COMMON_SRC}) | |||
| if (PLATFORM_ARM32 OR PLATFORM_ARM64) | |||
| target_link_libraries(timeprofile mindspore-lite) | |||
| target_link_libraries(timeprofiler mindspore-lite) | |||
| else() | |||
| target_link_libraries(timeprofile mindspore-lite pthread) | |||
| target_link_libraries(timeprofiler mindspore-lite pthread) | |||
| endif() | |||
| if (PLATFORM_ARM32 OR PLATFORM_ARM64) | |||
| install(TARGETS timeprofile | |||
| RUNTIME DESTINATION ${MAIN_DIR}-${COMPONENT_NAME}/time_profile COMPONENT ${COMPONENT_NAME}) | |||
| install(TARGETS timeprofiler | |||
| RUNTIME DESTINATION ${MAIN_DIR}-${COMPONENT_NAME}/time_profiler COMPONENT ${COMPONENT_NAME}) | |||
| else() | |||
| install(TARGETS timeprofile | |||
| RUNTIME DESTINATION ${MAIN_DIR}-${RUN_X86_COMPONENT_NAME}/time_profile COMPONENT ${RUN_X86_COMPONENT_NAME}) | |||
| install(TARGETS timeprofiler | |||
| RUNTIME DESTINATION ${MAIN_DIR}-${RUN_X86_COMPONENT_NAME}/time_profiler COMPONENT ${RUN_X86_COMPONENT_NAME}) | |||
| endif() | |||
| @@ -14,6 +14,6 @@ | |||
| * limitations under the License. | |||
| */ | |||
| #include "tools/time_profile/time_profile.h" | |||
| #include "tools/time_profiler/time_profiler.h" | |||
| int main(int argc, const char **argv) { return mindspore::lite::RunTimeProfile(argc, argv); } | |||
| int main(int argc, const char **argv) { return mindspore::lite::RunTimeProfiler(argc, argv); } | |||
| @@ -14,7 +14,7 @@ | |||
| * limitations under the License. | |||
| */ | |||
| #include "tools/time_profile/time_profile.h" | |||
| #include "tools/time_profiler/time_profiler.h" | |||
| #define __STDC_FORMAT_MACROS | |||
| #include <cinttypes> | |||
| #undef __STDC_FORMAT_MACROS | |||
| @@ -27,7 +27,7 @@ | |||
| namespace mindspore { | |||
| namespace lite { | |||
| int TimeProfile::GenerateRandomData(size_t size, void *data) { | |||
| int TimeProfiler::GenerateRandomData(size_t size, void *data) { | |||
| MS_ASSERT(data != nullptr); | |||
| char *castedData = static_cast<char *>(data); | |||
| for (size_t i = 0; i < size; i++) { | |||
| @@ -36,7 +36,7 @@ int TimeProfile::GenerateRandomData(size_t size, void *data) { | |||
| return RET_OK; | |||
| } | |||
| int TimeProfile::GenerateInputData() { | |||
| int TimeProfiler::GenerateInputData() { | |||
| for (auto tensor : ms_inputs_) { | |||
| MS_ASSERT(tensor != nullptr); | |||
| auto input_data = tensor->MutableData(); | |||
| @@ -57,7 +57,7 @@ int TimeProfile::GenerateInputData() { | |||
| return RET_OK; | |||
| } | |||
| int TimeProfile::ReadInputFile() { | |||
| int TimeProfiler::ReadInputFile() { | |||
| if (ms_inputs_.empty()) { | |||
| return RET_OK; | |||
| } | |||
| @@ -83,7 +83,7 @@ int TimeProfile::ReadInputFile() { | |||
| return RET_OK; | |||
| } | |||
| int TimeProfile::LoadInput() { | |||
| int TimeProfiler::LoadInput() { | |||
| ms_inputs_ = session_->GetInputs(); | |||
| if (_flags->in_data_path_.empty()) { | |||
| auto status = GenerateInputData(); | |||
| @@ -103,7 +103,7 @@ int TimeProfile::LoadInput() { | |||
| return RET_OK; | |||
| } | |||
| int TimeProfile::InitSession() { | |||
| int TimeProfiler::InitSession() { | |||
| size_t size = 0; | |||
| char *graph_buf = ReadFile(_flags->model_path_.c_str(), &size); | |||
| if (graph_buf == nullptr) { | |||
| @@ -127,7 +127,7 @@ int TimeProfile::InitSession() { | |||
| return RET_OK; | |||
| } | |||
| int TimeProfile::InitCallbackParameter() { | |||
| int TimeProfiler::InitCallbackParameter() { | |||
| // before callback | |||
| before_call_back_ = [&](const std::vector<mindspore::tensor::MSTensor *> &before_inputs, | |||
| const std::vector<mindspore::tensor::MSTensor *> &before_outputs, | |||
| @@ -175,7 +175,7 @@ int TimeProfile::InitCallbackParameter() { | |||
| return RET_OK; | |||
| } | |||
| int TimeProfile::Init() { | |||
| int TimeProfiler::Init() { | |||
| if (this->_flags == nullptr) { | |||
| return 1; | |||
| } | |||
| @@ -238,7 +238,7 @@ int TimeProfile::Init() { | |||
| return RET_OK; | |||
| } | |||
| int TimeProfile::PrintResult(const std::vector<std::string> &title, | |||
| int TimeProfiler::PrintResult(const std::vector<std::string> &title, | |||
| const std::map<std::string, std::pair<int, float>> &result) { | |||
| std::vector<size_t> columnLenMax(5); | |||
| std::vector<std::vector<std::string>> rows; | |||
| @@ -302,7 +302,7 @@ int TimeProfile::PrintResult(const std::vector<std::string> &title, | |||
| return RET_OK; | |||
| } | |||
| int TimeProfile::RunTimeProfile() { | |||
| int TimeProfiler::RunTimeProfiler() { | |||
| uint64_t time_avg = 0; | |||
| // Load graph | |||
| @@ -383,8 +383,8 @@ int TimeProfile::RunTimeProfile() { | |||
| return ret; | |||
| } | |||
| int RunTimeProfile(int argc, const char **argv) { | |||
| TimeProfileFlags flags; | |||
| int RunTimeProfiler(int argc, const char **argv) { | |||
| TimeProfilerFlags flags; | |||
| Option<std::string> err = flags.ParseFlags(argc, argv); | |||
| if (err.IsSome()) { | |||
| @@ -398,15 +398,15 @@ int RunTimeProfile(int argc, const char **argv) { | |||
| return 0; | |||
| } | |||
| TimeProfile time_profile(&flags); | |||
| auto ret = time_profile.Init(); | |||
| TimeProfiler time_profiler(&flags); | |||
| auto ret = time_profiler.Init(); | |||
| if (ret != RET_OK) { | |||
| MS_LOG(ERROR) << "Init TimeProfile failed."; | |||
| std::cerr << "Init TimeProfile failed." << std::endl; | |||
| return RET_ERROR; | |||
| } | |||
| ret = time_profile.RunTimeProfile(); | |||
| ret = time_profiler.RunTimeProfiler(); | |||
| if (ret != RET_OK) { | |||
| MS_LOG(ERROR) << "Run TimeProfile failed."; | |||
| std::cerr << "Run TimeProfile failed." << std::endl; | |||
| @@ -31,19 +31,19 @@ | |||
| namespace mindspore { | |||
| namespace lite { | |||
| class MS_API TimeProfileFlags : public virtual FlagParser { | |||
| class MS_API TimeProfilerFlags : public virtual FlagParser { | |||
| public: | |||
| TimeProfileFlags() { | |||
| AddFlag(&TimeProfileFlags::model_path_, "modelPath", "Input model path", ""); | |||
| AddFlag(&TimeProfileFlags::in_data_path_, "inDataPath", "Input data path, if not set, use random input", ""); | |||
| AddFlag(&TimeProfileFlags::cpu_bind_mode_, "cpuBindMode", | |||
| TimeProfilerFlags() { | |||
| AddFlag(&TimeProfilerFlags::model_path_, "modelPath", "Input model path", ""); | |||
| AddFlag(&TimeProfilerFlags::in_data_path_, "inDataPath", "Input data path, if not set, use random input", ""); | |||
| AddFlag(&TimeProfilerFlags::cpu_bind_mode_, "cpuBindMode", | |||
| "Input -1 for MID_CPU, 1 for HIGHER_CPU, 0 for NO_BIND, defalut value: 1", 1); | |||
| AddFlag(&TimeProfileFlags::loop_count_, "loopCount", "Run loop count", 10); | |||
| AddFlag(&TimeProfileFlags::num_threads_, "numThreads", "Run threads number", 2); | |||
| AddFlag(&TimeProfileFlags::fp16_priority, "fp16Priority", "Run fp16 ops prior", false); | |||
| AddFlag(&TimeProfilerFlags::loop_count_, "loopCount", "Run loop count", 10); | |||
| AddFlag(&TimeProfilerFlags::num_threads_, "numThreads", "Run threads number", 2); | |||
| AddFlag(&TimeProfilerFlags::fp16_priority, "fp16Priority", "Run fp16 ops prior", false); | |||
| } | |||
| ~TimeProfileFlags() override = default; | |||
| ~TimeProfilerFlags() override = default; | |||
| public: | |||
| std::string model_path_; | |||
| @@ -54,13 +54,13 @@ class MS_API TimeProfileFlags : public virtual FlagParser { | |||
| bool fp16_priority; | |||
| }; | |||
| class MS_API TimeProfile { | |||
| class MS_API TimeProfiler { | |||
| public: | |||
| explicit TimeProfile(TimeProfileFlags *flags) : _flags(flags) {} | |||
| ~TimeProfile() = default; | |||
| explicit TimeProfiler(TimeProfilerFlags *flags) : _flags(flags) {} | |||
| ~TimeProfiler() = default; | |||
| int Init(); | |||
| int RunTimeProfile(); | |||
| int RunTimeProfiler(); | |||
| private: | |||
| int GenerateRandomData(size_t size, void *data); | |||
| @@ -72,7 +72,7 @@ class MS_API TimeProfile { | |||
| int PrintResult(const std::vector<std::string> &title, const std::map<std::string, std::pair<int, float>> &result); | |||
| private: | |||
| TimeProfileFlags *_flags; | |||
| TimeProfilerFlags *_flags; | |||
| std::vector<mindspore::tensor::MSTensor *> ms_inputs_; | |||
| session::LiteSession *session_; | |||
| @@ -87,7 +87,7 @@ class MS_API TimeProfile { | |||
| session::KernelCallBack after_call_back_; | |||
| }; | |||
| int MS_API RunTimeProfile(int argc, const char **argv); | |||
| int MS_API RunTimeProfiler(int argc, const char **argv); | |||
| } // namespace lite | |||
| } // namespace mindspore | |||
| #endif // MINNIE_TIMEPROFILE_TIMEPROFILE_H_ | |||