提交 fc8d13cd 编写于 作者: M Megvii Engine Team

fix(build): fix linkage on ubuntu1604

GitOrigin-RevId: ee2a8360b02b26f94f9ca32dbecc342d62c76669
上级 c51a687c
......@@ -213,7 +213,7 @@ using IdentifiedCommand = std::pair<uint64_t, Command>;
template <>
struct ToStringTrait<interpreter::intl::Command>{
std::string operator()(const interpreter::intl::Command& cmd) const {
return std::visit([](auto& cmd){
return std::visit([](const auto& cmd){
std::string result = cmd.get_name();
result += "{";
cmd.get_props([&](const char* key, auto&& value) {
......
......@@ -481,8 +481,8 @@ void ChannelImpl::process_one_task(IdentifiedCommand& icmd) {
finished = true;
};
//TODO: remove std::visit for support osx 10.12
auto cmd_visitor = [&](auto& cmd) {
using T = std::remove_reference_t<decltype(cmd)>;
auto cmd_visitor = [&](const auto& cmd) {
using T = std::decay_t<decltype(cmd)>;
if constexpr (std::is_same_v<T, Put>) {
auto value = cmd.no_cache ? std::make_shared<Tensor>(cmd.value) : Tensor::make(cmd.value);
produce_tensor(cmd.dest, std::move(value));
......@@ -598,10 +598,10 @@ void ChannelImpl::process_one_task(IdentifiedCommand& icmd) {
do_finish_command();
m_worker_state.profiler->record_host<WorkerEndScope>(cmd.scope_name);
} else {
static_assert(std::is_same_v<T, T>);
static_assert(!std::is_same_v<T, T>);
}
};
std::visit([&](auto& cmd){
std::visit([&](const auto& cmd){
using T = std::decay_t<decltype(cmd)>;
if (!m_worker_state.options.catch_worker_execption) {
cmd_visitor(cmd);
......
......@@ -97,7 +97,7 @@ struct InterpreterProfilerDumpChromeTimelineContext {
};
// convert Command to json object. Has to be an callable object
static auto constexpr cmd_to_args = [](auto&& cmd) {
static auto constexpr cmd_to_args = [](const auto& cmd) {
auto args = json::Object::make();
cmd.get_props([&](const char* key, auto&& value){
(*args)[key] = json::String::make(to_string(value));
......@@ -108,14 +108,14 @@ struct InterpreterProfilerDumpChromeTimelineContext {
void process() {
// enumerate and process each record
for (auto&& record: profile_data.records) {
std::visit([this](auto& record){
for (auto& record: profile_data.records) {
std::visit([this](const auto& record){
using TEvent = std::decay_t<decltype(record.data)>;
Session<TEvent>(*this, record).process();
}, record);
}
for (size_t tid = 0; tid < thread_list.size(); ++tid) {
auto tname = std::visit([&](auto& host_or_device) -> std::string{
auto tname = std::visit([&](auto host_or_device) -> std::string{
using T = std::decay_t<decltype(host_or_device)>;
if constexpr (std::is_same_v<T, std::thread::id>) {
// take name from host_map
......@@ -142,11 +142,11 @@ struct InterpreterProfilerDumpChromeTimelineContext {
template <typename TEvent>
struct Session {
InterpreterProfilerDumpChromeTimelineContext& ctx;
ProfilerBase::EventRecord<TEvent>& record;
TEvent& data;
const ProfilerBase::EventRecord<TEvent>& record;
const TEvent& data;
Session(InterpreterProfilerDumpChromeTimelineContext& ctx,
ProfilerBase::EventRecord<TEvent>& record)
const ProfilerBase::EventRecord<TEvent>& record)
: ctx{ctx}, record{record}, data{record.data} {}
uint64_t get_host_tid() {
......
......@@ -57,7 +57,7 @@ public:
Host tid;
double time;
void wait() {}
void wait() const {}
};
struct DeviceInstant {
......@@ -65,7 +65,7 @@ public:
std::shared_ptr<CompNode::Event> event;
double after;
void wait() {
void wait() const {
event->host_wait();
}
};
......@@ -77,16 +77,16 @@ public:
Instant instant;
TEvent data;
HostInstant& host() {
const HostInstant& host() const {
return std::get<HostInstant>(instant);
}
DeviceInstant device() {
const DeviceInstant& device() const {
return std::get<DeviceInstant>(instant);
}
void wait() {
std::visit([&](auto& instant){ instant.wait(); }, instant);
void wait() const {
std::visit([&](const auto& instant){ instant.wait(); }, instant);
}
};
protected:
......@@ -173,7 +173,7 @@ public:
mgb_assert(m_status == Profiling, "profiler not active");
m_status = Stopped;
for (auto&& record: m_record_list) {
std::visit([&](auto& record){
std::visit([&](const auto& record){
record.wait();
}, record);
}
......@@ -312,7 +312,7 @@ public:
return m_content.back();
}
std::shared_ptr<json::Array> to_json() {
std::shared_ptr<json::Array> to_json() const {
auto result = json::Array::make();
for (auto&& event: m_content) {
result->add(event.to_json());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册