Unverified Commit 97c9cf9d authored by Robert Kimball's avatar Robert Kimball Committed by GitHub

Normalize line endings (#1649)

* set global line ending options for repo

* Normalize line endings

* add newline at eof
parent 54403cdc
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.cpp text
*.hpp text
This diff is collapsed.
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
#include <array>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <sstream>
#include <string>
static std::mt19937_64 random_generator;
namespace ngraph
{
class uuid_type;
}
class ngraph::uuid_type
{
public:
uuid_type()
{
m_data[0] = random_generator();
m_data[1] = random_generator();
uint8_t* p = reinterpret_cast<uint8_t*>(m_data);
p[6] = (p[6] & 0x0F) | 0x40;
p[8] = (p[8] & 0x3F) | 0x80;
}
std::string to_string() const
{
std::stringstream ss;
const uint8_t* p = reinterpret_cast<const uint8_t*>(m_data);
for (int i = 0; i < 4; i++)
{
ss << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(*p++);
}
ss << "-";
for (int i = 0; i < 2; i++)
{
ss << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(*p++);
}
ss << "-";
for (int i = 0; i < 2; i++)
{
ss << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(*p++);
}
ss << "-";
for (int i = 0; i < 2; i++)
{
ss << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(*p++);
}
ss << "-";
for (int i = 0; i < 6; i++)
{
ss << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(*p++);
}
return ss.str();
}
static uuid_type zero()
{
uuid_type rc;
rc.m_data[0] = 0;
rc.m_data[1] = 0;
return rc;
}
bool operator==(const uuid_type& other) const { return memcmp(m_data, other.m_data, 16) == 0; }
bool operator!=(const uuid_type& other) const { return !(*this == other); }
friend std::ostream& operator<<(std::ostream& out, const uuid_type& id)
{
out << id.to_string();
return out;
}
private:
uint64_t m_data[2];
};
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
#include <array>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <sstream>
#include <string>
static std::mt19937_64 random_generator;
namespace ngraph
{
class uuid_type;
}
class ngraph::uuid_type
{
public:
uuid_type()
{
m_data[0] = random_generator();
m_data[1] = random_generator();
uint8_t* p = reinterpret_cast<uint8_t*>(m_data);
p[6] = (p[6] & 0x0F) | 0x40;
p[8] = (p[8] & 0x3F) | 0x80;
}
std::string to_string() const
{
std::stringstream ss;
const uint8_t* p = reinterpret_cast<const uint8_t*>(m_data);
for (int i = 0; i < 4; i++)
{
ss << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(*p++);
}
ss << "-";
for (int i = 0; i < 2; i++)
{
ss << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(*p++);
}
ss << "-";
for (int i = 0; i < 2; i++)
{
ss << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(*p++);
}
ss << "-";
for (int i = 0; i < 2; i++)
{
ss << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(*p++);
}
ss << "-";
for (int i = 0; i < 6; i++)
{
ss << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(*p++);
}
return ss.str();
}
static uuid_type zero()
{
uuid_type rc;
rc.m_data[0] = 0;
rc.m_data[1] = 0;
return rc;
}
bool operator==(const uuid_type& other) const { return memcmp(m_data, other.m_data, 16) == 0; }
bool operator!=(const uuid_type& other) const { return !(*this == other); }
friend std::ostream& operator<<(std::ostream& out, const uuid_type& id)
{
out << id.to_string();
return out;
}
private:
uint64_t m_data[2];
};
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include <memory>
#include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h"
#include "ngraph/log.hpp"
#include "ngraph/ngraph.hpp"
#include "ngraph/pass/dump_sorted.hpp"
#include "ngraph/pass/liveness.hpp"
#include "ngraph/pass/liveness.hpp"
#include "ngraph/pass/manager.hpp"
#include "ngraph/pass/visualize_tree.hpp"
#include "util/test_tools.hpp"
using namespace std;
using namespace ngraph;
namespace ng = ngraph;
TEST(liveness, constant)
{
Shape shape{1};
auto c = op::Constant::create(element::i32, shape, {5});
auto f = make_shared<Function>(make_shared<op::Negative>(c), op::ParameterVector{});
pass::Manager pass_manager;
pass_manager.register_pass<pass::Liveness>();
pass_manager.run_passes(f);
auto tmp = f->get_ordered_ops();
vector<shared_ptr<Node>> sorted{tmp.begin(), tmp.end()};
ASSERT_EQ(3, sorted.size());
EXPECT_EQ(0, sorted[0]->liveness_new_list.size());
EXPECT_EQ(0, sorted[0]->liveness_free_list.size());
// op::Negative is live on output to op::Result
// op::Negative is new
EXPECT_EQ(1, sorted[1]->liveness_new_list.size());
EXPECT_EQ(0, sorted[1]->liveness_free_list.size());
// op::Negative is live on input to op::Result
EXPECT_EQ(0, sorted[2]->liveness_new_list.size());
// op::Negative is freed
EXPECT_EQ(1, sorted[2]->liveness_free_list.size());
}
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include <memory>
#include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h"
#include "ngraph/log.hpp"
#include "ngraph/ngraph.hpp"
#include "ngraph/pass/dump_sorted.hpp"
#include "ngraph/pass/liveness.hpp"
#include "ngraph/pass/liveness.hpp"
#include "ngraph/pass/manager.hpp"
#include "ngraph/pass/visualize_tree.hpp"
#include "util/test_tools.hpp"
using namespace std;
using namespace ngraph;
namespace ng = ngraph;
TEST(liveness, constant)
{
Shape shape{1};
auto c = op::Constant::create(element::i32, shape, {5});
auto f = make_shared<Function>(make_shared<op::Negative>(c), op::ParameterVector{});
pass::Manager pass_manager;
pass_manager.register_pass<pass::Liveness>();
pass_manager.run_passes(f);
auto tmp = f->get_ordered_ops();
vector<shared_ptr<Node>> sorted{tmp.begin(), tmp.end()};
ASSERT_EQ(3, sorted.size());
EXPECT_EQ(0, sorted[0]->liveness_new_list.size());
EXPECT_EQ(0, sorted[0]->liveness_free_list.size());
// op::Negative is live on output to op::Result
// op::Negative is new
EXPECT_EQ(1, sorted[1]->liveness_new_list.size());
EXPECT_EQ(0, sorted[1]->liveness_free_list.size());
// op::Negative is live on input to op::Result
EXPECT_EQ(0, sorted[2]->liveness_new_list.size());
// op::Negative is freed
EXPECT_EQ(1, sorted[2]->liveness_free_list.size());
}
This diff is collapsed.
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h"
#include "ngraph/uuid.hpp"
using namespace std;
using namespace ngraph;
TEST(uuid, zero)
{
uuid_type zero = uuid_type::zero();
stringstream ss;
ss << zero;
std::string expected = "00000000-0000-0000-0000-000000000000";
EXPECT_STREQ(expected.c_str(), ss.str().c_str());
}
TEST(uuid, eq)
{
uuid_type z1 = uuid_type::zero();
uuid_type z2 = uuid_type::zero();
EXPECT_EQ(z1, z2);
}
TEST(uuid, ne)
{
uuid_type u1;
uuid_type u2;
EXPECT_NE(u1, u2);
}
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h"
#include "ngraph/uuid.hpp"
using namespace std;
using namespace ngraph;
TEST(uuid, zero)
{
uuid_type zero = uuid_type::zero();
stringstream ss;
ss << zero;
std::string expected = "00000000-0000-0000-0000-000000000000";
EXPECT_STREQ(expected.c_str(), ss.str().c_str());
}
TEST(uuid, eq)
{
uuid_type z1 = uuid_type::zero();
uuid_type z2 = uuid_type::zero();
EXPECT_EQ(z1, z2);
}
TEST(uuid, ne)
{
uuid_type u1;
uuid_type u2;
EXPECT_NE(u1, u2);
}
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