Unverified Commit fbafa3fc authored by Scott Cyphers's avatar Scott Cyphers Committed by GitHub

Cleanup null distributed device (#4402)

* Cleanup null distributed device

* Fix build error

* style
Co-authored-by: 's avatarScott Cyphers <diyessi@users.noreply.github.com>
parent 906716e5
......@@ -80,6 +80,8 @@ set (SRC
descriptor/tensor.hpp
dimension.cpp
dimension.hpp
distributed/null.cpp
distributed/null.hpp
distributed.cpp
distributed.hpp
enum_names.hpp
......
......@@ -54,8 +54,8 @@ DistributedInterface* ngraph::get_distributed_interface()
{
if (nullptr == s_distributed_interface)
{
set_distributed_interface(std::unique_ptr<DistributedInterface>(
new ngraph::distributed::NullDistributedInterface()));
set_distributed_interface(
std::unique_ptr<DistributedInterface>(new ngraph::distributed::Null()));
}
return s_distributed_interface.get();
}
//*****************************************************************************
// Copyright 2017-2020 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 <cstdio>
#include <string>
#include "ngraph/distributed/null.hpp"
#include "ngraph/except.hpp"
const std::string& ngraph::distributed::Null::get_name() const
{
return m_name;
}
int ngraph::distributed::Null::get_size()
{
return 0;
}
int ngraph::distributed::Null::get_rank()
{
return 0;
}
void ngraph::distributed::Null::log_print(const std::string& timestamp,
const std::vector<char>& buf)
{
std::cout << timestamp << ": " << std::string(buf.data()) << "\n";
}
void ngraph::distributed::Null::all_reduce(void*, void*, element::Type_t, reduction::Type, size_t)
{
throw ngraph_error("Distributed Library not supported/mentioned");
}
void ngraph::distributed::Null::broadcast(void*, element::Type_t, size_t, int)
{
throw ngraph_error("Distributed Library not supported/mentioned");
}
void ngraph::distributed::Null::recv(void*, element::Type_t, size_t, int)
{
throw ngraph_error("Distributed Library not supported/mentioned");
}
void ngraph::distributed::Null::send(const void*, element::Type_t, size_t, int)
{
throw ngraph_error("Distributed Library not supported/mentioned");
}
......@@ -20,53 +20,34 @@
#include <string>
#include "ngraph/distributed.hpp"
#include "ngraph/except.hpp"
namespace ngraph
{
namespace distributed
{
class NullDistributedInterface : public DistributedInterface
class Null : public DistributedInterface
{
const std::string& get_name() const override { return m_name; }
int get_size() override { return 0; }
int get_rank() override { return 0; }
void log_print(const std::string& timestamp, const std::vector<char>& buf) override
{
std::printf("%s: %s\n", timestamp.c_str(), buf.data());
}
void all_reduce(void* /* in */,
void* /* out */,
element::Type_t /* element_type */,
reduction::Type /* reduce_type */,
size_t /* count */) override
{
throw ngraph_error("Distributed Library not supported/mentioned");
}
void broadcast(void* /* in */,
element::Type_t /* element_type */,
size_t /* count */,
int /* root_id */) override
{
throw ngraph_error("Distributed Library not supported/mentioned");
}
void recv(void* /* in */,
element::Type_t /* element_type */,
size_t /* count */,
int /* src_id*/) override
{
throw ngraph_error("Distributed Library not supported/mentioned");
}
void send(const void* /* in */,
element::Type_t /* element_type */,
size_t /* count */,
int /* dest_id */) override
{
throw ngraph_error("Distributed Library not supported/mentioned");
}
const std::string& get_name() const override;
int get_size() override;
int get_rank() override;
void log_print(const std::string& timestamp, const std::vector<char>& buf) override;
void all_reduce(void* in,
void* out,
element::Type_t element_type,
reduction::Type reduce_type,
size_t count) override;
void broadcast(void* in,
element::Type_t element_type,
size_t count,
int root_id) override;
void recv(void* in, element::Type_t element_type, size_t count, int src_id) override;
void send(const void* in,
element::Type_t element_type,
size_t count,
int dest_id) override;
protected:
std::string m_name{"NULL"};
......
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