Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temp build #694

Open
wants to merge 21 commits into
base: ipu_stable_sdk2.2.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ODLA/platforms/odla_popart/odla_compute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <ODLA/odla.h>
#include <dlfcn.h>
#include <stdlib.h>

#include <cstdlib>
#include <fstream>
Expand Down Expand Up @@ -62,6 +63,7 @@ odla_status odla_SetComputationItem(odla_computation comp, odla_item_type type,
comp->opts.cache_dir = (reinterpret_cast<char*>(value));
break;
case 1001: // load cache directly, need set path of cache file
setenv("POPART_LOG_LEVEL", "INFO", 1);
PopartConfig::instance()->set_load_or_save_cache(true);
PopartConfig::instance()->set_cache_path(
(std::string) reinterpret_cast<char*>(value));
Expand Down Expand Up @@ -167,6 +169,7 @@ odla_status odla_DestroyContext(odla_context ctx) {
}

odla_status odla_DestroyComputation(odla_computation comp) {
popart::logging::info("call odla_destroyComputation");
if (comp != nullptr) {
if (!comp->is_compile_only()) {
comp->mark_done();
Expand Down
16 changes: 9 additions & 7 deletions ODLA/platforms/odla_popart/odla_popart.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ void compute_loop(odla_computation comp) {
popart::logging::err("Poplar unrecoverable_runtime_error exception caught");
QManager::instance()->set_status(ODLA_UNRECOVERABLE_ERR);
} catch (poplar::unknown_runtime_error& e) {
popart::logging::info("Poplar unknown runtime exception caught");
popart::logging::err("Poplar unknown runtime exception caught");
QManager::instance()->set_status(ODLA_UNRECOVERABLE_ERR);
} catch (...) {
popart::logging::info("Poplar unknown exception caught");
popart::logging::err("Poplar unknown exception caught");
QManager::instance()->set_status(ODLA_UNRECOVERABLE_ERR);
}

popart::logging::warn("The pipeline loop finished");
popart::logging::info("The pipeline loop finished");
comp->thread_done();
}

Expand Down Expand Up @@ -134,10 +134,12 @@ odla_status _odla_computation::compile_and_export() {
config_string = PopartConfig::instance()->get_default_config_string();
}
// add sdk_version in the file content
std::string version_string(popart::core::versionString());
std::string version_string(popart::core::packageHash());
popart::logging::info("the popart version is: {}", version_string);
version_string = "\n\"sdk_version\":\"" + version_string + "\",";
config_string.insert(1, version_string);
if (config_string.find("sdk_version") == std::string::npos) {
std::string item_string = "\n\"sdk_version\":\"" + version_string + "\",";
config_string.insert(1, item_string);
}
popart::logging::info("the config_string with sdk_version is: {}",
config_string);
// added the sdk_version information to the file content
Expand Down Expand Up @@ -236,7 +238,7 @@ odla_status _odla_computation::init(bool is_compile) {
if (!is_compile) {
if (PopartConfig::instance()->load_or_save_cache()) {
popart::logging::info("Load cachefile from existing stream");
std::string version_string(popart::core::versionString());
std::string version_string(popart::core::packageHash());
if (!PopartConfig::instance()->sdk_version_match(version_string)) {
popart::logging::err("The sdk version of cache does not match {}",
version_string);
Expand Down
41 changes: 28 additions & 13 deletions ODLA/platforms/odla_popart/popart_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include "json.hpp"

PopartConfig* PopartConfig::instance_ = new PopartConfig();
std::vector<std::string> PopartConfig::mode = {"unknown", "pipeline",
"parallel", "sequence"};

const char* bool_to_str(const bool& value) { return value ? "true" : "false"; }

const std::string& get_config_path_from_cache_file(
const std::string& cache_path) {
Expand All @@ -43,6 +47,7 @@ const std::string& get_config_path_from_cache_file(

void PopartConfig::use_default() {
amp_ = 0.6;
sdk_version_ = popart::core::packageHash();
version_ = "1.0.0";
batches_per_step_ = 1;
ipu_num_ = 1;
Expand All @@ -54,19 +59,27 @@ void PopartConfig::use_default() {
queue_type_ = "LockFreeQueue";
queue_capacity_ = 1024 * 1024;
debug_ = false;
default_config_string_ =
char config_base[] =
"{\n\
\"version\":\"1.0.0\",\n\
\"amp\":0.6,\n\
\"batches_per_step\":1,\n\
\"execution_mode\":\"sequence\",\n\
\"ipu_num\":1,\n\
\"load_onnx\":false, \n\
\"load_onnx_path\":\"test-load-time.onnx\",\n\
\"queue_type\":\"LockFreeQueue\",\n\
\"queue_capacity\":1048576,\n\
\"debug\": false\n\
\"sdk_version\":\"%s\",\n\
\"version\":\"%s\",\n\
\"amp\":%f,\n\
\"batches_per_step\":%d,\n\
\"execution_mode\":\"%s\",\n\
\"ipu_num\":%d,\n\
\"load_onnx\":%s, \n\
\"load_onnx_path\":\"%s\",\n\
\"queue_type\":\"%s\",\n\
\"queue_capacity\":%d,\n\
\"debug\":%s\n\
}\n";
char raw_default_config[1024] = {0};
snprintf(raw_default_config, 1024, config_base, sdk_version_.c_str(),
version_.c_str(), amp_, batches_per_step_,
PopartConfig::mode[(int)execution_mode_].c_str(), ipu_num_,
bool_to_str(load_onnx_), load_onnx_path_.c_str(),
queue_type_.c_str(), queue_capacity_, bool_to_str(debug_));
default_config_string_ = raw_default_config;
}

odla_status PopartConfig::load_config(const char* env_file_path) {
Expand Down Expand Up @@ -104,6 +117,8 @@ odla_status PopartConfig::load_config(const char* env_file_path) {
void PopartConfig::parse_from_json(const json& jf) {
if (jf.contains("sdk_version")) {
sdk_version_ = jf["sdk_version"].get<std::string>();
} else {
sdk_version_ = popart::core::packageHash();
}
if (jf.contains("amp")) {
amp_ = jf["amp"].get<float>();
Expand Down Expand Up @@ -196,12 +211,12 @@ odla_status PopartConfig::load_from_file(const std::string& file_path) {
void PopartConfig::print() {
std::string line(80, '=');
popart::logging::info(line);
popart::logging::info("sdk_version: {}", sdk_version_);
popart::logging::info("version: {}", version_);
popart::logging::info("amp: {}", amp_);
popart::logging::info("batch_per_step: {}", batches_per_step_);
std::string mode[] = {"UNKNOWN", "PIPELINE", "PARALLEL", "SEQUENCE"};
popart::logging::info("execution_mode: {}",
mode[(long unsigned int)execution_mode_]);
PopartConfig::mode[(long unsigned int)execution_mode_]);
popart::logging::info("ipu_num: {}", ipu_num_);
std::string bool_value[] = {"false", "true"};
popart::logging::info("load_onnx: {}",
Expand Down
3 changes: 2 additions & 1 deletion ODLA/platforms/odla_popart/popart_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <iostream>
#include <map>
#include <mutex>
#include <popart/version.hpp>
#include <regex>
#include <string>
#include <vector>
Expand Down Expand Up @@ -61,6 +62,7 @@ class PopartConfig {
std::string sdk_version_; // version of the sdk
int batches_per_step_; // Batch per step for PIPELINE & PARALLEL execution
// mode
static std::vector<std::string> mode; // string value of execution mode
ExecutionMode
execution_mode_; // The execution mode {PIPELINE, PARALLEL, SEQUENCE}
bool load_onnx_; // Whether load onnx model to run instead of the model
Expand Down Expand Up @@ -118,7 +120,6 @@ class PopartConfig {
cache_fs->clear();
}
pipeline_setting_.clear();
load_or_save_cache_ = false;
sdk_version_ = "NA";
}
}
Expand Down