Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace stdx::make_unique with std::make_unique #548

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions source/neuropod/backends/neuropod_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ NeuropodBackend::NeuropodBackend(const std::string &neuropod_path, RuntimeOption
: model_config_(load_model_config(neuropod_path)),
neuropod_path_(neuropod_path),
options_(std::move(options)),
sealer_(stdx::make_unique<Sealer>(get_device_mapping(*model_config_, options_)))
sealer_(std::make_unique<Sealer>(get_device_mapping(*model_config_, options_)))
{
loader_ = get_loader(neuropod_path);
}
Expand Down Expand Up @@ -301,7 +301,7 @@ std::unique_ptr<NeuropodValueMap> NeuropodBackend::infer_internal(const Neuropod

// Run inference and get all the outputs
auto data = infer_internal(inputs);
auto out = stdx::make_unique<NeuropodValueMap>();
auto out = std::make_unique<NeuropodValueMap>();

// Filter to the requested outputs
for (const auto &tensor_name : requested_outputs)
Expand Down
6 changes: 3 additions & 3 deletions source/neuropod/backends/python_bridge/python_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ std::unique_ptr<py::gil_scoped_release> maybe_initialize()

// TODO: shutdown the interpreter once we know that there are no more python objects left
// atexit(py::finalize_interpreter);
return stdx::make_unique<py::gil_scoped_release>();
return std::make_unique<py::gil_scoped_release>();
}

// Handle interpreter startup and shutdown
Expand Down Expand Up @@ -205,7 +205,7 @@ void PythonBridge::load_model_internal()
const auto local_path = loader_->ensure_local();

// Load the neuropod and save a reference to it
neuropod_ = stdx::make_unique<py::object>(load_neuropod(local_path));
neuropod_ = std::make_unique<py::object>(load_neuropod(local_path));
}

PythonBridge::~PythonBridge()
Expand Down Expand Up @@ -249,7 +249,7 @@ std::unique_ptr<NeuropodValueMap> PythonBridge::infer_internal(const NeuropodVal
auto outputs = from_numpy_dict(*get_tensor_allocator(), model_outputs);

// We need a unique pointer
return stdx::make_unique<NeuropodValueMap>(std::move(outputs));
return std::make_unique<NeuropodValueMap>(std::move(outputs));
}

REGISTER_NEUROPOD_BACKEND(PythonBridge, "python", PY_VERSION)
Expand Down
2 changes: 1 addition & 1 deletion source/neuropod/backends/tensorflow/tf_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ std::unique_ptr<NeuropodValueMap> TensorflowNeuropodBackend::infer_internal(
check_tf_status(session_->RunCallable(handle, tf_inputs, &outputs, nullptr));

// Read the outputs and wrap them in `NeuropodTensor`s
auto to_return = stdx::make_unique<NeuropodValueMap>();
auto to_return = std::make_unique<NeuropodValueMap>();
size_t position = 0;
for (const auto &item : tensor_fetches)
{
Expand Down
4 changes: 2 additions & 2 deletions source/neuropod/backends/torchscript/torch_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void insert_value_in_output(NeuropodValueMap & output,
(!has_type && list[0].isString()))
{
// Make a TorchNeuropodTensor
auto neuropod_tensor = stdx::make_unique<TorchNeuropodTensor<std::string>>(tensor);
auto neuropod_tensor = std::make_unique<TorchNeuropodTensor<std::string>>(tensor);

// Add it to our output
auto &to_set = output[name];
Expand Down Expand Up @@ -416,7 +416,7 @@ std::unique_ptr<NeuropodValueMap> TorchNeuropodBackend::infer_internal(const Neu
c10::IValue result = model_->forward(torch_inputs);

// Get outputs
auto to_return = stdx::make_unique<NeuropodValueMap>();
auto to_return = std::make_unique<NeuropodValueMap>();

if (result.isGenericDict())
{
Expand Down
2 changes: 1 addition & 1 deletion source/neuropod/bindings/neuropod_native.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ template <typename... Params>
std::unique_ptr<Neuropod> make_neuropod(py::kwargs kwargs, Params &&... params)
{
auto options = get_options_from_kwargs(kwargs);
return stdx::make_unique<Neuropod>(std::forward<Params>(params)..., options);
return std::make_unique<Neuropod>(std::forward<Params>(params)..., options);
}

} // namespace
Expand Down
2 changes: 1 addition & 1 deletion source/neuropod/core/generic_tensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace neuropod

std::unique_ptr<NeuropodTensorAllocator> get_generic_tensor_allocator()
{
return stdx::make_unique<DefaultTensorAllocator<GenericNeuropodTensor>>();
return std::make_unique<DefaultTensorAllocator<GenericNeuropodTensor>>();
}

} // namespace neuropod
2 changes: 1 addition & 1 deletion source/neuropod/internal/backend_registration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ std::unique_ptr<std::unordered_map<std::string, BackendInfo>> registered_backend
void init_registrar_if_needed()
{
std::call_once(registrar_initialized, []() {
registered_backends_by_type = stdx::make_unique<std::unordered_map<std::string, BackendInfo>>();
registered_backends_by_type = std::make_unique<std::unordered_map<std::string, BackendInfo>>();

// Make sure our logging is initialized
init_logging();
Expand Down
3 changes: 1 addition & 2 deletions source/neuropod/internal/backend_registration.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ limitations under the License.
#pragma once

#include "neuropod/internal/config_utils.hh"
#include "neuropod/internal/memory_utils.hh"

#include <memory>
#include <string>
Expand All @@ -38,7 +37,7 @@ typedef std::unique_ptr<NeuropodBackend> (*BackendFactoryFunction)(const std::st
template <typename T>
std::unique_ptr<NeuropodBackend> createNeuropodBackend(const std::string &neuropod_path, const RuntimeOptions &options)
{
return stdx::make_unique<T>(neuropod_path, options);
return std::make_unique<T>(neuropod_path, options);
}

// Register a backend for a set of specific types
Expand Down
2 changes: 1 addition & 1 deletion source/neuropod/internal/config_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ std::unique_ptr<ModelConfig> load_model_config(std::istream &input_stream)
}

// Not directly using make_unique because of brace initialization
return stdx::make_unique<ModelConfig>(
return std::make_unique<ModelConfig>(
ModelConfig{name, platform, platform_version_semver, inputs, outputs, custom_ops, input_tensor_device});
}

Expand Down
1 change: 0 additions & 1 deletion source/neuropod/internal/config_utils.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ limitations under the License.

#pragma once

#include "neuropod/internal/memory_utils.hh"
#include "neuropod/internal/tensor_types.hh"

#include <memory>
Expand Down
65 changes: 0 additions & 65 deletions source/neuropod/internal/memory_utils.hh

This file was deleted.

9 changes: 4 additions & 5 deletions source/neuropod/internal/neuropod_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ limitations under the License.
#include "neuropod/internal/neuropod_loader.hh"

#include "neuropod/internal/error_utils.hh"
#include "neuropod/internal/memory_utils.hh"

#include <ghc/filesystem.hpp>

Expand Down Expand Up @@ -48,7 +47,7 @@ class LocalLoader : public NeuropodLoader

std::unique_ptr<std::istream> get_istream_for_file(const std::string &path) override
{
auto ret = stdx::make_unique<std::ifstream>(get_file_path(path));
auto ret = std::make_unique<std::ifstream>(get_file_path(path));
if (!(*ret))
{
return nullptr;
Expand Down Expand Up @@ -99,7 +98,7 @@ class ZipLoader : public NeuropodLoader

std::unique_ptr<std::istream> get_istream_for_file(const std::string &path) override
{
auto out = stdx::make_unique<std::stringstream>();
auto out = std::make_unique<std::stringstream>();
if (!unzipper_.extractEntryToStream(path, *out))
{
return nullptr;
Expand Down Expand Up @@ -174,10 +173,10 @@ std::unique_ptr<NeuropodLoader> get_loader(const std::string &neuropod_path)

if (fs::is_directory(neuropod_path))
{
return stdx::make_unique<LocalLoader>(neuropod_path);
return std::make_unique<LocalLoader>(neuropod_path);
}

return stdx::make_unique<ZipLoader>(neuropod_path);
return std::make_unique<ZipLoader>(neuropod_path);
}

} // namespace neuropod
7 changes: 3 additions & 4 deletions source/neuropod/internal/neuropod_tensor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ limitations under the License.
#pragma once

#include "neuropod/internal/error_utils_header_only.hh"
#include "neuropod/internal/memory_utils.hh"
#include "neuropod/internal/tensor_accessor.hh"
#include "neuropod/internal/type_macros.hh"
#include "neuropod/options.hh"
Expand Down Expand Up @@ -642,9 +641,9 @@ protected:
};

// Utility to make a tensor of a specific type
#define MAKE_TENSOR(CPP_TYPE, NEUROPOD_TYPE) \
case NEUROPOD_TYPE: { \
return stdx::make_unique<TensorClass<CPP_TYPE>>(std::forward<Params>(params)...); \
#define MAKE_TENSOR(CPP_TYPE, NEUROPOD_TYPE) \
case NEUROPOD_TYPE: { \
return std::make_unique<TensorClass<CPP_TYPE>>(std::forward<Params>(params)...); \
}

template <template <class> class TensorClass, typename... Params>
Expand Down
1 change: 0 additions & 1 deletion source/neuropod/multiprocess/mq/ipc_message_queue.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.

#include "neuropod/internal/blocking_spsc_queue.hh"
#include "neuropod/internal/error_utils.hh"
#include "neuropod/internal/memory_utils.hh"
#include "neuropod/multiprocess/mq/heartbeat.hh"
#include "neuropod/multiprocess/mq/wire_format.hh"

Expand Down
14 changes: 7 additions & 7 deletions source/neuropod/multiprocess/mq/ipc_message_queue_impl.hh
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ constexpr auto MAX_QUEUE_SIZE = 20;
template <typename UserPayloadType>
inline std::unique_ptr<ipc::message_queue> make_queue(const std::string &control_queue_name_, const std::string &suffix)
{
return stdx::make_unique<ipc::message_queue>(ipc::open_or_create,
("neuropod_" + control_queue_name_ + suffix).c_str(),
MAX_QUEUE_SIZE,
sizeof(WireFormat<UserPayloadType>));
return std::make_unique<ipc::message_queue>(ipc::open_or_create,
("neuropod_" + control_queue_name_ + suffix).c_str(),
MAX_QUEUE_SIZE,
sizeof(WireFormat<UserPayloadType>));
}

template <typename UserPayloadType>
Expand Down Expand Up @@ -67,7 +67,7 @@ void IPCMessageQueue<UserPayloadType>::read_worker_loop()
boost::posix_time::milliseconds(detail::MESSAGE_TIMEOUT_MS);

// Get a message
auto received = stdx::make_unique<WireFormat>();
auto received = std::make_unique<WireFormat>();
size_t received_size;
unsigned int priority;
bool successful_read =
Expand Down Expand Up @@ -196,8 +196,8 @@ IPCMessageQueue<UserPayloadType>::IPCMessageQueue(const std::string &control_que
control_queue_name_(control_queue_name),
send_queue_(detail::make_send_queue<UserPayloadType>(control_queue_name_, type)),
recv_queue_(detail::make_recv_queue<UserPayloadType>(control_queue_name_, type)),
heartbeat_controller_(stdx::make_unique<detail::HeartbeatController>(*this)),
transferrable_controller_(stdx::make_unique<detail::TransferrableController>()),
heartbeat_controller_(std::make_unique<detail::HeartbeatController>(*this)),
transferrable_controller_(std::make_unique<detail::TransferrableController>()),
lost_heartbeat_(false),
read_worker_(&IPCMessageQueue<UserPayloadType>::read_worker_loop, this)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ TEST(test_ipc_message_queue, simple)
{
// A tensor allocator that allocates tensors in shared memory
std::unique_ptr<neuropod::NeuropodTensorAllocator> allocator =
neuropod::stdx::make_unique<neuropod::DefaultTensorAllocator<neuropod::SHMNeuropodTensor>>();
neuropod::std::make_unique<neuropod::DefaultTensorAllocator<neuropod::SHMNeuropodTensor>>();

// Store tensors we allocate so they don't go out of scope
neuropod::NeuropodValueMap sender_map;
Expand Down
2 changes: 1 addition & 1 deletion source/neuropod/multiprocess/mq/test/test_ope_heartbeat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class TestChannel

TEST(test_ope_heartbeat, basic)
{
auto test_channel = neuropod::stdx::make_unique<TestChannel>();
auto test_channel = neuropod::std::make_unique<TestChannel>();

// Create a controller
neuropod::detail::HeartbeatController controller(*test_channel);
Expand Down
6 changes: 3 additions & 3 deletions source/neuropod/multiprocess/multiprocess.cc
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class MultiprocessNeuropodBackend : public NeuropodBackendWithDefaultAllocator<S
}

// Load the returned tensors
auto to_return = stdx::make_unique<NeuropodValueMap>();
auto to_return = std::make_unique<NeuropodValueMap>();
received.get(*to_return);

if (free_memory_every_cycle_)
Expand Down Expand Up @@ -309,7 +309,7 @@ std::unique_ptr<NeuropodBackend> load_neuropod_ope(const std::string &
if (control_queue_name.empty())
{
// Start a new worker
return stdx::make_unique<MultiprocessNeuropodBackend>(
return std::make_unique<MultiprocessNeuropodBackend>(
neuropod_path, options, free_memory_every_cycle, default_backend_overrides);
}

Expand All @@ -321,7 +321,7 @@ std::unique_ptr<NeuropodBackend> load_neuropod_ope(const std::string &
}

// Use an existing worker
return stdx::make_unique<MultiprocessNeuropodBackend>(neuropod_path, control_queue_name, free_memory_every_cycle);
return std::make_unique<MultiprocessNeuropodBackend>(neuropod_path, control_queue_name, free_memory_every_cycle);
}

} // namespace neuropod
2 changes: 1 addition & 1 deletion source/neuropod/multiprocess/multiprocess_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void multiprocess_worker_loop(const std::string &control_queue_name)
opts.use_ope = false;

// Load a neuropod
neuropod = stdx::make_unique<Neuropod>(config.neuropod_path, config.default_backend_overrides, opts);
neuropod = std::make_unique<Neuropod>(config.neuropod_path, config.default_backend_overrides, opts);
allocator = neuropod->get_tensor_allocator();
inputs.clear();
control_channel.send_message(LOAD_SUCCESS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ limitations under the License.
#pragma once

#include "neuropod/internal/error_utils.hh"
#include "neuropod/internal/memory_utils.hh"

#include <boost/pfr/precise.hpp>

Expand Down Expand Up @@ -151,7 +150,7 @@ inline void ipc_deserialize(std::istream &in, std::string &item)
else
{
// We need to allocate a larger buffer
auto buffer = stdx::make_unique<char[]>(length);
auto buffer = std::make_unique<char[]>(length);
detail::checked_read(in, buffer.get(), length);

// Set the content of `item`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ TEST(test_ipc_serialization, neuropod_value_map)
{
// A tensor allocator that allocates tensors in shared memory
std::unique_ptr<neuropod::NeuropodTensorAllocator> allocator =
neuropod::stdx::make_unique<neuropod::DefaultTensorAllocator<neuropod::SHMNeuropodTensor>>();
neuropod::std::make_unique<neuropod::DefaultTensorAllocator<neuropod::SHMNeuropodTensor>>();

const std::shared_ptr<neuropod::NeuropodValue> float_tensor_1D =
allocator->allocate_tensor({3}, neuropod::FLOAT_TENSOR);
Expand Down
Loading