Unverified Commit 37d211f2 authored by Scott Cyphers's avatar Scott Cyphers Committed by GitHub

Migrate from master. (#2866)

parent 2e03ccdb
...@@ -112,47 +112,50 @@ void runtime::cpu::CPU_CallFrame::inner_call( ...@@ -112,47 +112,50 @@ void runtime::cpu::CPU_CallFrame::inner_call(
m_ctx_vec[id]->op_durations, m_ctx_vec[id]->op_durations,
m_external_function->get_function_name() + ".timeline.json"); m_external_function->get_function_name() + ".timeline.json");
} }
std::unique_lock<std::mutex> lck(m_mutex);
m_id_pool[id] = true;
m_num_ctx_available++;
m_cv.notify_all();
} }
void runtime::cpu::CPU_CallFrame::call( void runtime::cpu::CPU_CallFrame::call(
const std::vector<std::shared_ptr<runtime::Tensor>>& output_tvs, const std::vector<std::shared_ptr<runtime::Tensor>>& output_tvs,
const std::vector<std::shared_ptr<runtime::Tensor>>& input_tvs) const std::vector<std::shared_ptr<runtime::Tensor>>& input_tvs)
{ {
std::unique_lock<std::mutex> lck(m_mutex);
while (m_num_ctx_available == 0)
{
m_cv.wait(lck);
}
auto id = 0; auto id = 0;
for (auto i = 0; i < m_num_ctx; i++) auto disable_caching = false;
{ {
if (m_id_pool[i]) std::unique_lock<std::mutex> lck(m_mutex);
while (m_num_ctx_available == 0)
{ {
id = i; m_cv.wait(lck);
break;
} }
for (auto i = 0; i < m_num_ctx; i++)
{
if (m_id_pool[i])
{
id = i;
break;
}
}
NGRAPH_CHECK(id != m_num_ctx);
m_id_pool[id] = false;
if (id != m_prev_ctx)
{
// Disable caching since staleness hints are no longer
// applicable to this context
disable_caching = true;
}
m_prev_ctx = id;
m_num_ctx_available--;
} }
NGRAPH_CHECK(id != m_num_ctx);
m_id_pool[id] = false;
auto disable_caching = false;
if (id != m_prev_ctx)
{
// Disable caching since staleness hints are no longer
// applicable to this context
disable_caching = true;
}
m_prev_ctx = id;
m_num_ctx_available--;
m_mutex.unlock();
m_ctx_vec[id]->pc = 0; m_ctx_vec[id]->pc = 0;
propagate_layouts(output_tvs, m_external_function->get_result_layout_descriptors()); propagate_layouts(output_tvs, m_external_function->get_result_layout_descriptors());
inner_call(output_tvs, input_tvs, id, disable_caching); inner_call(output_tvs, input_tvs, id, disable_caching);
m_mutex.lock();
m_id_pool[id] = true;
m_num_ctx_available++;
m_mutex.unlock();
m_cv.notify_one();
} }
void runtime::cpu::CPU_CallFrame::propagate_layouts( void runtime::cpu::CPU_CallFrame::propagate_layouts(
......
...@@ -951,8 +951,6 @@ TEST(cpu_test, rotated_pooling) ...@@ -951,8 +951,6 @@ TEST(cpu_test, rotated_pooling)
make_f(false, false), make_f(false, false), "INTERPRETER", "CPU"); // 5D MaxPool make_f(false, false), make_f(false, false), "INTERPRETER", "CPU"); // 5D MaxPool
} }
// TODO enable test for Windows
#ifndef _WIN32
// for float this will be 18 bits matching // for float this will be 18 bits matching
// for bfloat this will be 6 bits matching // for bfloat this will be 6 bits matching
constexpr int three_quarters_of_available_bits = (MAX_FLOAT_BITS * 3) / 4; constexpr int three_quarters_of_available_bits = (MAX_FLOAT_BITS * 3) / 4;
...@@ -1049,7 +1047,6 @@ TEST(cpu_test, thread_safe_calls_convolution_2d_2items) ...@@ -1049,7 +1047,6 @@ TEST(cpu_test, thread_safe_calls_convolution_2d_2items)
unset_environment("NGRAPH_CPU_CONCURRENCY"); unset_environment("NGRAPH_CPU_CONCURRENCY");
} }
#endif
TEST(cpu_test, constant_reshape) TEST(cpu_test, constant_reshape)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment