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 ...@@ -44,3 +44,10 @@ SpacesInSquareBrackets: false
SortIncludes: false SortIncludes: false
ReflowComments: true 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, ...@@ -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; 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_bitwidth{bitwidth}
, m_is_float{is_float} , m_is_float{is_float}
, m_is_signed{is_signed} , m_is_signed{is_signed}
......
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
#pragma once #pragma once
#include <string>
#include <map> #include <map>
#include <string>
namespace ngraph namespace ngraph
{ {
......
...@@ -14,12 +14,12 @@ ...@@ -14,12 +14,12 @@
*/ */
#include <chrono> #include <chrono>
#include <condition_variable>
#include <ctime>
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include <ctime>
#include <thread>
#include <mutex> #include <mutex>
#include <condition_variable> #include <thread>
#include "log.hpp" #include "log.hpp"
......
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
#pragma once #pragma once
#include <deque>
#include <sstream> #include <sstream>
#include <stdexcept> #include <stdexcept>
#include <deque>
namespace nervana namespace nervana
{ {
...@@ -37,6 +37,7 @@ namespace nervana ...@@ -37,6 +37,7 @@ namespace nervana
} }
constexpr const char* get_ptr(size_t offset) const { return &_string[offset]; } 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: private:
const char* _string; const char* _string;
size_t _size; size_t _size;
...@@ -44,8 +45,9 @@ namespace nervana ...@@ -44,8 +45,9 @@ namespace nervana
constexpr const char* find_last(conststring s, size_t offset, char ch) 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) return offset == 0
: find_last(s, offset - 1, ch)); ? 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) constexpr const char* find_last(conststring s, char ch)
...@@ -67,6 +69,7 @@ namespace nervana ...@@ -67,6 +69,7 @@ namespace nervana
~log_helper(); ~log_helper();
std::ostream& stream() { return _stream; } std::ostream& stream() { return _stream; }
private: private:
std::stringstream _stream; std::stringstream _stream;
}; };
......
...@@ -14,40 +14,39 @@ ...@@ -14,40 +14,39 @@
#pragma once #pragma once
#include <string>
#include <map> #include <map>
#include <string>
namespace ngraph namespace ngraph
{ {
//================================================================================================
//================================================================================================ // NameableValue
// NameableValue // An Axis labels a dimension of a tensor. The op-graph uses
// An Axis labels a dimension of a tensor. The op-graph uses // the identity of Axis objects to pair and specify dimensions in
// the identity of Axis objects to pair and specify dimensions in // symbolic expressions. This system has several advantages over
// symbolic expressions. This system has several advantages over // using the length and position of the axis as in other frameworks:
// using the length and position of the axis as in other frameworks: //
// // 1) Convenience. The dimensions of tensors, which may be nested
// 1) Convenience. The dimensions of tensors, which may be nested // deep in a computation graph, can be specified without having to
// deep in a computation graph, can be specified without having to // calculate their lengths.
// calculate their lengths. //
// // 2) Safety. Axis labels are analogous to types in general-purpose
// 2) Safety. Axis labels are analogous to types in general-purpose // programming languages, allowing objects to interact only when
// programming languages, allowing objects to interact only when // they are permitted to do so in advance. In symbolic computation,
// they are permitted to do so in advance. In symbolic computation, // this prevents interference between axes that happen to have the
// this prevents interference between axes that happen to have the // same lengths but are logically distinct, e.g. if the number of
// same lengths but are logically distinct, e.g. if the number of // training examples and the number of input features are both 50.
// training examples and the number of input features are both 50. //
// // TODO: Please add to the list...
// TODO: Please add to the list... //
// // Arguments:
// Arguments: // length: The length of the axis.
// length: The length of the axis. // batch: Whether the axis is a batch axis.
// batch: Whether the axis is a batch axis. // recurrent: Whether the axis is a recurrent axis.
// recurrent: Whether the axis is a recurrent axis. //================================================================================================
//================================================================================================ class NameableValue
class NameableValue {
{ public:
public:
//!----------------------------------------------------------------------------------- //!-----------------------------------------------------------------------------------
//! NameableValue //! NameableValue
//! An object that can be named. //! An object that can be named.
...@@ -103,7 +102,6 @@ public: ...@@ -103,7 +102,6 @@ public:
std::string m_graph_label; std::string m_graph_label;
std::string m_short_name; std::string m_short_name;
std::string m_doc_string; std::string m_doc_string;
}; };
} // end namespace ngraph } // end namespace ngraph
#include <iostream>
#include <algorithm> #include <algorithm>
#include <iostream>
#include "strides.hpp" #include "strides.hpp"
#include "util.hpp" #include "util.hpp"
......
#pragma once #pragma once
#include <cstdio> #include <cstdio>
#include <vector>
#include <initializer_list> #include <initializer_list>
#include <vector>
#include "element_type.hpp" #include "element_type.hpp"
#include "tree.hpp" #include "tree.hpp"
......
#pragma once #pragma once
#include <algorithm>
#include <functional> #include <functional>
#include <vector>
#include <initializer_list> #include <initializer_list>
#include <iostream> #include <iostream>
#include <algorithm> #include <vector>
#include "util.hpp" #include "util.hpp"
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include <map>
#include <iomanip> #include <iomanip>
#include <map>
#include "util.hpp" #include "util.hpp"
......
...@@ -14,23 +14,22 @@ ...@@ -14,23 +14,22 @@
#pragma once #pragma once
#include <string>
#include <sstream>
#include <vector>
#include <chrono>
#include <algorithm> #include <algorithm>
#include <map> #include <chrono>
#include <iostream> #include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>
namespace ngraph namespace ngraph
{ {
class stopwatch;
extern std::map<std::string, stopwatch*> stopwatch_statistics;
class stopwatch; template <typename T>
extern std::map<std::string, stopwatch*> stopwatch_statistics; std::string join(const T& v, const std::string& sep)
{
template <typename T>
std::string join(const T& v, const std::string& sep)
{
std::ostringstream ss; std::ostringstream ss;
for (const auto& x : v) for (const auto& x : v)
{ {
...@@ -41,11 +40,11 @@ std::string join(const T& v, const std::string& sep) ...@@ -41,11 +40,11 @@ std::string join(const T& v, const std::string& sep)
ss << x; ss << x;
} }
return ss.str(); return ss.str();
} }
template <typename U, typename T> template <typename U, typename T>
bool contains(const U& container, const T& obj) bool contains(const U& container, const T& obj)
{ {
bool rc = false; bool rc = false;
for (auto o : container) for (auto o : container)
{ {
...@@ -56,11 +55,11 @@ bool contains(const U& container, const T& obj) ...@@ -56,11 +55,11 @@ bool contains(const U& container, const T& obj)
} }
} }
return rc; return rc;
} }
template <typename U, typename T> template <typename U, typename T>
bool contains_key(const U& container, const T& obj) bool contains_key(const U& container, const T& obj)
{ {
bool rc = false; bool rc = false;
for (auto o : container) for (auto o : container)
{ {
...@@ -71,28 +70,28 @@ bool contains_key(const U& container, const T& obj) ...@@ -71,28 +70,28 @@ bool contains_key(const U& container, const T& obj)
} }
} }
return rc; return rc;
} }
template <typename U, typename T> template <typename U, typename T>
void remove_from(U& container, const T& obj) void remove_from(U& container, const T& obj)
{ {
auto it = container.find(obj); auto it = container.find(obj);
if (it != container.end()) if (it != container.end())
{ {
container.erase(it); container.erase(it);
} }
} }
size_t hash_combine(const std::vector<size_t>& list); size_t hash_combine(const std::vector<size_t>& list);
void dump(std::ostream& out, const void*, size_t); void dump(std::ostream& out, const void*, size_t);
std::string to_lower(const std::string& s); std::string to_lower(const std::string& s);
std::string trim(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::vector<std::string> split(const std::string& s, char delimiter, bool trim = false);
class stopwatch class stopwatch
{ {
public: public:
stopwatch() {} stopwatch() {}
stopwatch(const std::string& name) stopwatch(const std::string& name)
: m_name{name} : m_name{name}
...@@ -150,20 +149,21 @@ public: ...@@ -150,20 +149,21 @@ public:
size_t get_total_microseconds() const { return get_total_nanoseconds() / 1e3; } size_t get_total_microseconds() const { return get_total_nanoseconds() / 1e3; }
size_t get_total_nanoseconds() const { return m_total_time.count(); } size_t get_total_nanoseconds() const { return m_total_time.count(); }
private: private:
std::chrono::high_resolution_clock m_clock; std::chrono::high_resolution_clock m_clock;
std::chrono::time_point<std::chrono::high_resolution_clock> m_start_time; std::chrono::time_point<std::chrono::high_resolution_clock> m_start_time;
bool m_active = false; bool m_active = false;
std::chrono::nanoseconds m_total_time = std::chrono::high_resolution_clock::duration::zero(); std::chrono::nanoseconds m_total_time =
std::chrono::high_resolution_clock::duration::zero();
std::chrono::nanoseconds m_last_time; std::chrono::nanoseconds m_last_time;
size_t m_total_count = 0; size_t m_total_count = 0;
std::string m_name; std::string m_name;
}; };
template <class InputIt, class BinaryOp> template <class InputIt, class BinaryOp>
typename std::iterator_traits<InputIt>::value_type typename std::iterator_traits<InputIt>::value_type
reduce(InputIt first, InputIt last, BinaryOp op) reduce(InputIt first, InputIt last, BinaryOp op)
{ {
typename std::iterator_traits<InputIt>::value_type result; typename std::iterator_traits<InputIt>::value_type result;
if (first == last) if (first == last)
...@@ -180,18 +180,18 @@ typename std::iterator_traits<InputIt>::value_type ...@@ -180,18 +180,18 @@ typename std::iterator_traits<InputIt>::value_type
} }
} }
return result; return result;
} }
template <typename T> template <typename T>
T plus(const T& a, const T& b) T plus(const T& a, const T& b)
{ {
return a + b; return a + b;
} }
template <typename T> template <typename T>
T mul(const T& a, const T& b) T mul(const T& a, const T& b)
{ {
return a * b; return a * b;
} }
} // end namespace ngraph } // end namespace ngraph
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
#pragma once #pragma once
#include <array> #include <array>
#include <random> #include <cstring>
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include <cstring> #include <random>
static std::mt19937_64 random_generator; static std::mt19937_64 random_generator;
......
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream> #include <sstream>
#include <string>
#include <unordered_map> #include <unordered_map>
#include <vector>
#include "gtest/gtest.h" #include "gtest/gtest.h"
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream> #include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h" #include "gtest/gtest.h"
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream> #include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h" #include "gtest/gtest.h"
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include <iostream>
#include <chrono> #include <chrono>
#include <iostream>
#include "gtest/gtest.h" #include "gtest/gtest.h"
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream> #include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h" #include "gtest/gtest.h"
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream> #include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h" #include "gtest/gtest.h"
......
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream> #include <sstream>
#include <string>
#include <unordered_map> #include <unordered_map>
#include <vector>
#include "gtest/gtest.h" #include "gtest/gtest.h"
......
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream>
#include <memory> #include <memory>
#include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h" #include "gtest/gtest.h"
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream> #include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h" #include "gtest/gtest.h"
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream> #include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h" #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