Commit 22e2307b authored by Robert Kimball's avatar Robert Kimball

update clang-format to sort includes and rerun style

parent 7da5f65e
......@@ -44,3 +44,10 @@ SpacesInSquareBrackets: false
SortIncludes: false
ReflowComments: true
IncludeCategories:
- Regex: '^".*'
Priority: 3
- Regex: '^<.*'
Priority: 2
SortIncludes: true
......@@ -27,7 +27,10 @@ const ngraph::ElementType element_type_uint64_t = ngraph::ElementType(64, false,
std::map<std::string, ngraph::ElementType> ngraph::ElementType::m_element_list;
ngraph::ElementType::ElementType(size_t bitwidth, bool is_float, bool is_signed, const std::string& cname)
ngraph::ElementType::ElementType(size_t bitwidth,
bool is_float,
bool is_signed,
const std::string& cname)
: m_bitwidth{bitwidth}
, m_is_float{is_float}
, m_is_signed{is_signed}
......
......@@ -18,8 +18,8 @@
#pragma once
#include <string>
#include <map>
#include <string>
namespace ngraph
{
......
......@@ -14,12 +14,12 @@
*/
#include <chrono>
#include <condition_variable>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <ctime>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <thread>
#include "log.hpp"
......
......@@ -15,9 +15,9 @@
#pragma once
#include <deque>
#include <sstream>
#include <stdexcept>
#include <deque>
namespace nervana
{
......@@ -36,7 +36,8 @@ namespace nervana
return i < _size ? _string[i] : throw std::out_of_range("");
}
constexpr const char* get_ptr(size_t offset) const { return &_string[offset]; }
constexpr size_t size() const { return _size; }
constexpr size_t size() const { return _size; }
private:
const char* _string;
size_t _size;
......@@ -44,8 +45,9 @@ namespace nervana
constexpr const char* find_last(conststring s, size_t offset, char ch)
{
return offset == 0 ? s.get_ptr(0) : (s[offset] == ch ? s.get_ptr(offset + 1)
: find_last(s, offset - 1, ch));
return offset == 0
? s.get_ptr(0)
: (s[offset] == ch ? s.get_ptr(offset + 1) : find_last(s, offset - 1, ch));
}
constexpr const char* find_last(conststring s, char ch)
......@@ -67,6 +69,7 @@ namespace nervana
~log_helper();
std::ostream& stream() { return _stream; }
private:
std::stringstream _stream;
};
......@@ -81,9 +84,9 @@ namespace nervana
static void stop();
private:
static void log_item(const std::string& s);
static void process_event(const std::string& s);
static void thread_entry(void* param);
static void log_item(const std::string& s);
static void process_event(const std::string& s);
static void thread_entry(void* param);
static std::string log_path;
static std::deque<std::string> queue;
};
......
......@@ -14,96 +14,94 @@
#pragma once
#include <string>
#include <map>
#include <string>
namespace ngraph
{
//================================================================================================
// NameableValue
// An Axis labels a dimension of a tensor. The op-graph uses
// the identity of Axis objects to pair and specify dimensions in
// symbolic expressions. This system has several advantages over
// using the length and position of the axis as in other frameworks:
//
// 1) Convenience. The dimensions of tensors, which may be nested
// deep in a computation graph, can be specified without having to
// calculate their lengths.
//
// 2) Safety. Axis labels are analogous to types in general-purpose
// programming languages, allowing objects to interact only when
// they are permitted to do so in advance. In symbolic computation,
// this prevents interference between axes that happen to have the
// same lengths but are logically distinct, e.g. if the number of
// training examples and the number of input features are both 50.
//
// TODO: Please add to the list...
//
// Arguments:
// length: The length of the axis.
// batch: Whether the axis is a batch axis.
// recurrent: Whether the axis is a recurrent axis.
//================================================================================================
class NameableValue
{
public:
//!-----------------------------------------------------------------------------------
//! NameableValue
//! An object that can be named.
//!
//! Arguments:
//! graph_label_type: A label that should be used when drawing the graph. Defaults to
//! the class name.
//! name (str): The name of the object.
//! **kwargs: Parameters for related classes.
//!
//! Attributes:
//! graph_label_type: A label that should be used when drawing the graph.
//! id: Unique id for this object.
//!-----------------------------------------------------------------------------------
NameableValue(const std::string& name,
const std::string& graph_label_type = "",
const std::string& doc_string = "");
//================================================================================================
// NameableValue
// An Axis labels a dimension of a tensor. The op-graph uses
// the identity of Axis objects to pair and specify dimensions in
// symbolic expressions. This system has several advantages over
// using the length and position of the axis as in other frameworks:
//
// 1) Convenience. The dimensions of tensors, which may be nested
// deep in a computation graph, can be specified without having to
// calculate their lengths.
//
// 2) Safety. Axis labels are analogous to types in general-purpose
// programming languages, allowing objects to interact only when
// they are permitted to do so in advance. In symbolic computation,
// this prevents interference between axes that happen to have the
// same lengths but are logically distinct, e.g. if the number of
// training examples and the number of input features are both 50.
//
// TODO: Please add to the list...
//
// Arguments:
// length: The length of the axis.
// batch: Whether the axis is a batch axis.
// recurrent: Whether the axis is a recurrent axis.
//================================================================================================
class NameableValue
{
public:
//!-----------------------------------------------------------------------------------
//! NameableValue
//! An object that can be named.
//!
//! Arguments:
//! graph_label_type: A label that should be used when drawing the graph. Defaults to
//! the class name.
//! name (str): The name of the object.
//! **kwargs: Parameters for related classes.
//!
//! Attributes:
//! graph_label_type: A label that should be used when drawing the graph.
//! id: Unique id for this object.
//!-----------------------------------------------------------------------------------
NameableValue(const std::string& name,
const std::string& graph_label_type = "",
const std::string& doc_string = "");
//!-----------------------------------------------------------------------------------
//! graph_label
//! The label used for drawings of the graph.
//!-----------------------------------------------------------------------------------
const std::string& graph_label();
//!-----------------------------------------------------------------------------------
//! graph_label
//! The label used for drawings of the graph.
//!-----------------------------------------------------------------------------------
const std::string& graph_label();
//!-----------------------------------------------------------------------------------
//! name
//! Sets the object name to a unique name based on name.
//!
//! Arguments:
//! name: Prefix for the name
//!-----------------------------------------------------------------------------------
const std::string& name();
//!-----------------------------------------------------------------------------------
//! name
//! Sets the object name to a unique name based on name.
//!
//! Arguments:
//! name: Prefix for the name
//!-----------------------------------------------------------------------------------
const std::string& name();
//!-----------------------------------------------------------------------------------
//! name
//!-----------------------------------------------------------------------------------
void name(const std::string& name);
//!-----------------------------------------------------------------------------------
//! name
//!-----------------------------------------------------------------------------------
void name(const std::string& name);
//!-----------------------------------------------------------------------------------
//! short_name
//!-----------------------------------------------------------------------------------
const std::string& short_name();
//!-----------------------------------------------------------------------------------
//! short_name
//!-----------------------------------------------------------------------------------
const std::string& short_name();
//!-----------------------------------------------------------------------------------
//! named
//!-----------------------------------------------------------------------------------
NameableValue& named(const std::string& name);
//!-----------------------------------------------------------------------------------
//! named
//!-----------------------------------------------------------------------------------
NameableValue& named(const std::string& name);
static size_t __counter;
static std::map<std::string, NameableValue> __all_names;
static size_t __counter;
static std::map<std::string, NameableValue> __all_names;
std::string m_name;
std::string m_graph_label;
std::string m_short_name;
std::string m_doc_string;
};
std::string m_name;
std::string m_graph_label;
std::string m_short_name;
std::string m_doc_string;
};
} // end namespace ngraph
#include <iostream>
#include <algorithm>
#include <iostream>
#include "strides.hpp"
#include "util.hpp"
......
#pragma once
#include <cstdio>
#include <vector>
#include <initializer_list>
#include <vector>
#include "element_type.hpp"
#include "tree.hpp"
......
#pragma once
#include <algorithm>
#include <functional>
#include <vector>
#include <initializer_list>
#include <iostream>
#include <algorithm>
#include <vector>
#include "util.hpp"
......
......@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <map>
#include <iomanip>
#include <map>
#include "util.hpp"
......
......@@ -14,184 +14,184 @@
#pragma once
#include <string>
#include <sstream>
#include <vector>
#include <chrono>
#include <algorithm>
#include <map>
#include <chrono>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>
namespace ngraph
{
class stopwatch;
extern std::map<std::string, stopwatch*> stopwatch_statistics;
class stopwatch;
extern std::map<std::string, stopwatch*> stopwatch_statistics;
template <typename T>
std::string join(const T& v, const std::string& sep)
{
std::ostringstream ss;
for (const auto& x : v)
template <typename T>
std::string join(const T& v, const std::string& sep)
{
if (&x != &*(v.begin()))
std::ostringstream ss;
for (const auto& x : v)
{
ss << sep;
if (&x != &*(v.begin()))
{
ss << sep;
}
ss << x;
}
ss << x;
return ss.str();
}
return ss.str();
}
template <typename U, typename T>
bool contains(const U& container, const T& obj)
{
bool rc = false;
for (auto o : container)
template <typename U, typename T>
bool contains(const U& container, const T& obj)
{
if (o == obj)
bool rc = false;
for (auto o : container)
{
rc = true;
break;
if (o == obj)
{
rc = true;
break;
}
}
return rc;
}
return rc;
}
template <typename U, typename T>
bool contains_key(const U& container, const T& obj)
{
bool rc = false;
for (auto o : container)
template <typename U, typename T>
bool contains_key(const U& container, const T& obj)
{
if (o.first == obj)
bool rc = false;
for (auto o : container)
{
rc = true;
break;
if (o.first == obj)
{
rc = true;
break;
}
}
return rc;
}
return rc;
}
template <typename U, typename T>
void remove_from(U& container, const T& obj)
{
auto it = container.find(obj);
if (it != container.end())
template <typename U, typename T>
void remove_from(U& container, const T& obj)
{
container.erase(it);
auto it = container.find(obj);
if (it != container.end())
{
container.erase(it);
}
}
}
size_t hash_combine(const std::vector<size_t>& list);
void dump(std::ostream& out, const void*, size_t);
size_t hash_combine(const std::vector<size_t>& list);
void dump(std::ostream& out, const void*, size_t);
std::string to_lower(const std::string& s);
std::string trim(const std::string& s);
std::vector<std::string> split(const std::string& s, char delimiter, bool trim = false);
std::string to_lower(const std::string& s);
std::string trim(const std::string& s);
std::vector<std::string> split(const std::string& s, char delimiter, bool trim = false);
class stopwatch
{
public:
stopwatch() {}
stopwatch(const std::string& name)
: m_name{name}
class stopwatch
{
stopwatch_statistics.insert({m_name, this});
}
public:
stopwatch() {}
stopwatch(const std::string& name)
: m_name{name}
{
stopwatch_statistics.insert({m_name, this});
}
~stopwatch()
{
if (m_name.size() > 0)
~stopwatch()
{
stopwatch_statistics.find(m_name);
if (m_name.size() > 0)
{
stopwatch_statistics.find(m_name);
}
}
}
void start()
{
if (m_active == false)
void start()
{
m_total_count++;
m_active = true;
m_start_time = m_clock.now();
if (m_active == false)
{
m_total_count++;
m_active = true;
m_start_time = m_clock.now();
}
}
}
void stop()
{
if (m_active == true)
void stop()
{
auto end_time = m_clock.now();
m_last_time = end_time - m_start_time;
m_total_time += m_last_time;
m_active = false;
if (m_active == true)
{
auto end_time = m_clock.now();
m_last_time = end_time - m_start_time;
m_total_time += m_last_time;
m_active = false;
}
}
size_t get_call_count() const { return m_total_count; }
size_t get_seconds() const { return get_nanoseconds() / 1e9; }
size_t get_milliseconds() const { return get_nanoseconds() / 1e6; }
size_t get_microseconds() const { return get_nanoseconds() / 1e3; }
size_t get_nanoseconds() const
{
if (m_active)
{
return (m_clock.now() - m_start_time).count();
}
else
{
return m_last_time.count();
}
}
}
size_t get_call_count() const { return m_total_count; }
size_t get_seconds() const { return get_nanoseconds() / 1e9; }
size_t get_milliseconds() const { return get_nanoseconds() / 1e6; }
size_t get_microseconds() const { return get_nanoseconds() / 1e3; }
size_t get_nanoseconds() const
size_t get_total_seconds() const { return get_total_nanoseconds() / 1e9; }
size_t get_total_milliseconds() const { return get_total_nanoseconds() / 1e6; }
size_t get_total_microseconds() const { return get_total_nanoseconds() / 1e3; }
size_t get_total_nanoseconds() const { return m_total_time.count(); }
private:
std::chrono::high_resolution_clock m_clock;
std::chrono::time_point<std::chrono::high_resolution_clock> m_start_time;
bool m_active = false;
std::chrono::nanoseconds m_total_time =
std::chrono::high_resolution_clock::duration::zero();
std::chrono::nanoseconds m_last_time;
size_t m_total_count = 0;
std::string m_name;
};
template <class InputIt, class BinaryOp>
typename std::iterator_traits<InputIt>::value_type
reduce(InputIt first, InputIt last, BinaryOp op)
{
if (m_active)
typename std::iterator_traits<InputIt>::value_type result;
if (first == last)
{
return (m_clock.now() - m_start_time).count();
result = {};
}
else
{
return m_last_time.count();
result = *first++;
while (first != last)
{
result = op(result, *first);
first++;
}
}
return result;
}
size_t get_total_seconds() const { return get_total_nanoseconds() / 1e9; }
size_t get_total_milliseconds() const { return get_total_nanoseconds() / 1e6; }
size_t get_total_microseconds() const { return get_total_nanoseconds() / 1e3; }
size_t get_total_nanoseconds() const { return m_total_time.count(); }
private:
std::chrono::high_resolution_clock m_clock;
std::chrono::time_point<std::chrono::high_resolution_clock> m_start_time;
bool m_active = false;
std::chrono::nanoseconds m_total_time = std::chrono::high_resolution_clock::duration::zero();
std::chrono::nanoseconds m_last_time;
size_t m_total_count = 0;
std::string m_name;
};
template <class InputIt, class BinaryOp>
typename std::iterator_traits<InputIt>::value_type
reduce(InputIt first, InputIt last, BinaryOp op)
{
typename std::iterator_traits<InputIt>::value_type result;
if (first == last)
template <typename T>
T plus(const T& a, const T& b)
{
result = {};
return a + b;
}
else
template <typename T>
T mul(const T& a, const T& b)
{
result = *first++;
while (first != last)
{
result = op(result, *first);
first++;
}
return a * b;
}
return result;
}
template <typename T>
T plus(const T& a, const T& b)
{
return a + b;
}
template <typename T>
T mul(const T& a, const T& b)
{
return a * b;
}
} // end namespace ngraph
......@@ -15,10 +15,10 @@
#pragma once
#include <array>
#include <random>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <cstring>
#include <random>
static std::mt19937_64 random_generator;
......
......@@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>
#include "gtest/gtest.h"
......
......@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h"
......
......@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h"
......
......@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <iostream>
#include <chrono>
#include <iostream>
#include "gtest/gtest.h"
......
......@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h"
......
......@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h"
......
......@@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>
#include "gtest/gtest.h"
......
......@@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream>
#include <memory>
#include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h"
......
......@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h"
......
......@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h"
......
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