Commit bf022034 authored by Bob Kimball's avatar Bob Kimball

updated per review comments

parent f828a116
...@@ -53,7 +53,7 @@ namespace ngraph ...@@ -53,7 +53,7 @@ namespace ngraph
size_t m_bitwidth; size_t m_bitwidth;
bool m_is_float; bool m_is_float;
bool m_is_signed; bool m_is_signed;
std::string m_cname; const std::string m_cname;
}; };
std::ostream& operator<<(std::ostream& out, const ngraph::element::Type& obj); std::ostream& operator<<(std::ostream& out, const ngraph::element::Type& obj);
......
...@@ -57,6 +57,6 @@ void pass::AssignTensors::check_dependencies( ...@@ -57,6 +57,6 @@ void pass::AssignTensors::check_dependencies(
if (!found_propagate_types) if (!found_propagate_types)
{ {
throw runtime_error("Depencency 'PropagateTypes' not found for pass 'AssignTensors'"); throw runtime_error("Dependency 'PropagateTypes' not found for pass 'AssignTensors'");
} }
} }
...@@ -136,7 +136,7 @@ void pass::Liveness::check_dependencies( ...@@ -136,7 +136,7 @@ void pass::Liveness::check_dependencies(
if (!found_propagate_types) if (!found_propagate_types)
{ {
throw runtime_error("Depencency 'PropagateTypes' not found for pass 'AssignTensors'"); throw runtime_error("Dependency 'PropagateTypes' not found for pass 'AssignTensors'");
} }
} }
......
...@@ -46,7 +46,7 @@ void pass::MemoryLayout::check_dependencies( ...@@ -46,7 +46,7 @@ void pass::MemoryLayout::check_dependencies(
if (!found_propagate_types) if (!found_propagate_types)
{ {
throw runtime_error("Depencency 'PropagateTypes' not found for pass 'AssignTensors'"); throw runtime_error("Dependency 'PropagateTypes' not found for pass 'AssignTensors'");
} }
} }
...@@ -68,16 +68,13 @@ pass::MemoryManager::MemoryManager(size_t alignment) ...@@ -68,16 +68,13 @@ pass::MemoryManager::MemoryManager(size_t alignment)
size_t pass::MemoryManager::allocate(size_t size) size_t pass::MemoryManager::allocate(size_t size)
{ {
INFO;
size_t rc; size_t rc;
switch(m_scheme) switch(m_scheme)
{ {
case allocation_scheme::FIRST_FIT: case allocation_scheme::FIRST_FIT:
INFO;
rc = first_fit(size); rc = first_fit(size);
break; break;
case allocation_scheme::BEST_FIT: case allocation_scheme::BEST_FIT:
INFO;
rc = best_fit(size); rc = best_fit(size);
break; break;
} }
...@@ -88,7 +85,6 @@ size_t pass::MemoryManager::best_fit(size_t size) ...@@ -88,7 +85,6 @@ size_t pass::MemoryManager::best_fit(size_t size)
{ {
size = align(size, m_alignment); size = align(size, m_alignment);
size_t offset = 0; size_t offset = 0;
bool found = false;
size_t min_delta = numeric_limits<size_t>::max(); size_t min_delta = numeric_limits<size_t>::max();
auto best_fit = m_node_list.end(); auto best_fit = m_node_list.end();
size_t best_offset = offset; size_t best_offset = offset;
...@@ -97,7 +93,6 @@ size_t pass::MemoryManager::best_fit(size_t size) ...@@ -97,7 +93,6 @@ size_t pass::MemoryManager::best_fit(size_t size)
if (it->m_state == block_state::FREE && it->m_size >= size) if (it->m_state == block_state::FREE && it->m_size >= size)
{ {
size_t delta = it->m_size - size; size_t delta = it->m_size - size;
INFO << "delta " << delta << ", min_delta " << min_delta;
if (delta < min_delta) if (delta < min_delta)
{ {
min_delta = delta; min_delta = delta;
...@@ -107,22 +102,21 @@ size_t pass::MemoryManager::best_fit(size_t size) ...@@ -107,22 +102,21 @@ size_t pass::MemoryManager::best_fit(size_t size)
} }
offset += it->m_size; offset += it->m_size;
} }
if (best_fit == m_node_list.end()) if (best_fit == m_node_list.end())
{ {
throw bad_alloc(); throw bad_alloc();
} }
else if (!found)
if (min_delta == 0)
{ {
if (min_delta == 0) // exact fit
{ best_fit->m_state = block_state::ALLOCATED;
// exact fit }
best_fit->m_state = block_state::ALLOCATED; else
} {
else m_node_list.insert(best_fit, node{size, block_state::ALLOCATED});
{ best_fit->m_size -= size;
m_node_list.insert(best_fit, node{size, block_state::ALLOCATED});
best_fit->m_size -= size;
}
} }
m_max_allocated = std::max(m_max_allocated, best_offset + size); m_max_allocated = std::max(m_max_allocated, best_offset + size);
...@@ -224,12 +218,10 @@ size_t pass::MemoryManager::align(size_t size, size_t alignment) ...@@ -224,12 +218,10 @@ size_t pass::MemoryManager::align(size_t size, size_t alignment)
else else
{ {
auto remainder = size % alignment; auto remainder = size % alignment;
INFO << "size " << size << ", remainder " << remainder << ", alignment " << alignment;
if (remainder > 0) if (remainder > 0)
{ {
size += (alignment - remainder); size += (alignment - remainder);
} }
INFO << "final size " << size;
} }
return size; return size;
} }
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