Change onnxruntime::make_unique to std::make_unique (#7502)

1. Change onnxruntime::make_unique to std::make_unique
2. Add "-std=c++14" to ROCM EP's build flags.
This commit is contained in:
Changming Sun 2021-04-29 17:04:53 -07:00 committed by GitHub
parent d337fa90e7
commit 1012535dab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
219 changed files with 1070 additions and 1086 deletions

View file

@ -994,6 +994,7 @@ if (onnxruntime_USE_ROCM)
endif()
set(HIP_CXX_FLAGS -fPIC)
list(APPEND HIP_CXX_FLAGS -std=c++14)
if(CMAKE_BUILD_TYPE MATCHES Debug)
list(APPEND HIP_CXX_FLAGS -g)

View file

@ -26,7 +26,7 @@ Other
* Don't use else after return. see: [https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return](https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return)
* Don't overuse std::shared\_ptr. Use std::shared\_ptr only if it's not clear when and where the object will be deallocated. See also: [https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rf-shared_ptr](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rf-shared_ptr)
* Avoid using the 'long' type, which could be either 32 bits or 64 bits.
* If there is a legitimate need to allocate objects on the heap, prefer using onnxruntime::make_unique(). References for the reasoning:
* If there is a legitimate need to allocate objects on the heap, prefer using std::make_unique(). References for the reasoning:
* https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rh-make_unique
* https://herbsutter.com/2013/05/29/gotw-89-solution-smart-pointers/
* https://abseil.io/tips/126

View file

@ -34,7 +34,6 @@
#include "core/common/code_location.h"
#include "core/common/exceptions.h"
#include "core/common/make_string.h"
#include "core/common/make_unique.h"
#include "core/common/status.h"
#ifdef USE_MIMALLOC_ARENA_ALLOCATOR

View file

@ -6,7 +6,7 @@
#ifndef SHARED_PROVIDER
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include "core/common/status.h"
#include "core/common/logging/logging.h"
#include "core/framework/tensor.h"
@ -20,6 +20,8 @@ struct ComputeCapability;
class KernelRegistry;
class KernelRegistryManager;
} // namespace onnxruntime
#else
#include <memory>
#endif
#include "core/framework/provider_options.h"
@ -51,7 +53,7 @@ class IExecutionProvider {
IExecutionProvider(const std::string& type, bool use_metadef_id_creator = false)
: type_{type} {
if (use_metadef_id_creator) {
metadef_id_generator_ = onnxruntime::make_unique<ModelMetadefIdGenerator>();
metadef_id_generator_ = std::make_unique<ModelMetadefIdGenerator>();
}
}

View file

@ -760,7 +760,7 @@ class Graph {
if (iter != node_args_.end()) {
return *(iter->second);
}
auto result = node_args_.insert(std::make_pair(name, onnxruntime::make_unique<NodeArg>(name, p_arg_type)));
auto result = node_args_.insert(std::make_pair(name, std::make_unique<NodeArg>(name, p_arg_type)));
return *(result.first->second);
}

View file

@ -24,7 +24,7 @@
#pragma warning(disable : 4127)
#pragma warning(disable : 4805)
#endif
#include <memory>
#include "unsupported/Eigen/CXX11/ThreadPool"
#if defined(__GNUC__)
@ -33,7 +33,6 @@
#pragma warning(pop)
#endif
#include "core/common/denormal.h"
#include "core/common/make_unique.h"
#include "core/common/spin_pause.h"
#include "core/platform/ort_mutex.h"
#include "core/platform/Barrier.h"
@ -740,7 +739,7 @@ class ThreadPoolTempl : public onnxruntime::concurrency::ExtendedThreadPoolInter
// preferable for pushing work. We use a regular array given that a std::vector
// cannot contain std::atomic.
num_hint_words_ = static_cast<int>((num_threads_ + bits_per_hint_word_ - 1) / bits_per_hint_word_);
good_worker_hints_ = onnxruntime::make_unique<std::atomic<uint64_t>[]>(num_hint_words_);
good_worker_hints_ = std::make_unique<std::atomic<uint64_t>[]>(num_hint_words_);
worker_data_.resize(num_threads_);
for (int i = 0; i < num_threads_; i++) {

View file

@ -72,7 +72,7 @@ struct Inverse::ComputeImpl {
using namespace inverse_internal;
using CudaT = typename ToCudaType<T>::MappedType;
const size_t input_count = static_cast<size_t>(input.Shape().Size());
auto info_cpu = onnxruntime::make_unique<int[]>(num_batches);
auto info_cpu = std::make_unique<int[]>(num_batches);
const auto dim = static_cast<int>(rows);
const auto n_batches = static_cast<int>(num_batches);

View file

@ -33,7 +33,7 @@ class BiasDropout final : public CudaKernel {
BiasDropout(const OpKernelInfo& info) : CudaKernel(info) {
int64_t seed = 0;
if (info.GetAttr<int64_t>("seed", &seed).IsOK()) {
generator_ = onnxruntime::make_unique<PhiloxGenerator>(static_cast<uint64_t>(seed));
generator_ = std::make_unique<PhiloxGenerator>(static_cast<uint64_t>(seed));
}
}

View file

@ -119,7 +119,7 @@ const onnxruntime::Node* GetInputNode(const Node& node, const NodeArg* def) {
std::unique_ptr<ComputeCapability> ToCapacity(const onnxruntime::GraphViewer& graph,
int fused_count,
std::unique_ptr<IndexedSubGraph>& subgraph) {
auto meta_def = onnxruntime::make_unique<::onnxruntime::IndexedSubGraph::MetaDef>();
auto meta_def = std::make_unique<::onnxruntime::IndexedSubGraph::MetaDef>();
meta_def->name = "Fuse" + std::to_string(fused_count);
meta_def->domain = "Fuse";
@ -232,7 +232,7 @@ std::unique_ptr<ComputeCapability> ToCapacity(const onnxruntime::GraphViewer& gr
meta_def->status = ONNX_NAMESPACE::EXPERIMENTAL;
std::unique_ptr<IndexedSubGraph> finished_subgraph(subgraph.release());
finished_subgraph->SetMetaDef(std::move(meta_def));
return onnxruntime::make_unique<ComputeCapability>(std::move(finished_subgraph));
return std::make_unique<ComputeCapability>(std::move(finished_subgraph));
}
int64_t ShapeRank(const NodeArg* def) {

View file

@ -3,7 +3,6 @@
#include "core/codegen/common/utils.h"
#include "core/common/cpuid_info.h"
#include "core/common/make_unique.h"
#include "core/common/safeint.h"
#include <stdlib.h>
@ -33,7 +32,7 @@ std::unique_ptr<char[]> GetEnv(const char* var) {
// a unique_ptr, and it will be destroyed automatically after the caller
// completes.
size_t len_val = strlen(val) + 1;
auto p = onnxruntime::make_unique<char[]>(len_val);
auto p = std::make_unique<char[]>(len_val);
// use explicit loop to get ride of VC's warning on unsafe copy
for (size_t i = 0; i < len_val; ++i) {
p[i] = val[i];

View file

@ -70,7 +70,7 @@ Status TVMIRBuilder::Evaluate(
// BEGIN: Generic IR creator classes
#define ADD_OP_ITEM(name) \
op_ir_registry->Register(onnxruntime::make_unique<GENERIC_OP_IR_CREATOR_CLASS(name)>());
op_ir_registry->Register(std::make_unique<GENERIC_OP_IR_CREATOR_CLASS(name)>());
#define BINARY_OP(name) ADD_OP_ITEM(name)
#define BINARY_CMP_OP(name) ADD_OP_ITEM(name)
@ -107,7 +107,7 @@ void RegisterAllGenericOpIRCreators(OpIRRegistry* op_ir_registry) {
void RegisterGenericOrtOpTypeDispatcher(const std::shared_ptr<TVMIRBuilder>& builder,
const OpIRRegistry* registry) {
auto dispatcher = onnxruntime::make_unique<OP_IR_DISPATCHER_CLASS(OpType)>("GenericOrtOpTypeOpIRCreators");
auto dispatcher = std::make_unique<OP_IR_DISPATCHER_CLASS(OpType)>("GenericOrtOpTypeOpIRCreators");
LIST_ALL_GENERIC_OPS()
builder->InsertDispatcher(std::move(dispatcher));
}

View file

@ -145,7 +145,7 @@ std::unique_ptr<Logger> LoggingManager::CreateLogger(const std::string& logger_i
const Severity severity,
bool filter_user_data,
int vlog_level) {
auto logger = onnxruntime::make_unique<Logger>(*this, logger_id, severity, filter_user_data, vlog_level);
auto logger = std::make_unique<Logger>(*this, logger_id, severity, filter_user_data, vlog_level);
return logger;
}

View file

@ -5,7 +5,6 @@
#include <fstream>
#include "core/common/logging/sinks/ostream_sink.h"
#include "core/common/make_unique.h"
namespace onnxruntime {
namespace logging {
@ -34,7 +33,7 @@ class FileSink : public OStreamSink {
/// <param name="filter_user_data">If set to <c>true</c> [removes user data].</param>
/// <remarks>Filtering of user data can alternatively be done at the <see cref="LoggingManager" /> level.</remarks>
FileSink(const std::string& filename, bool append, bool filter_user_data)
: FileSink{onnxruntime::make_unique<std::ofstream>(filename, std::ios::out | (append ? std::ios::app : std::ios::trunc)),
: FileSink{std::make_unique<std::ofstream>(filename, std::ios::out | (append ? std::ios::app : std::ios::trunc)),
filter_user_data} {
}

View file

@ -20,14 +20,14 @@ Status::Status(StatusCategory category, int code, const std::string& msg) {
// state_ will be allocated here causing the status to be treated as a failure
ORT_ENFORCE(code != static_cast<int>(common::OK));
state_ = onnxruntime::make_unique<State>(category, code, msg);
state_ = std::make_unique<State>(category, code, msg);
}
Status::Status(StatusCategory category, int code, const char* msg) {
// state_ will be allocated here causing the status to be treated as a failure
ORT_ENFORCE(code != static_cast<int>(common::OK));
state_ = onnxruntime::make_unique<State>(category, code, msg);
state_ = std::make_unique<State>(category, code, msg);
}
Status::Status(StatusCategory category, int code)

View file

@ -379,7 +379,7 @@ ThreadPool::ThreadPool(Env* env,
if (degree_of_parallelism >= 2) {
int threads_to_create = degree_of_parallelism - 1;
extended_eigen_threadpool_ =
onnxruntime::make_unique<ThreadPoolTempl<Env> >(name,
std::make_unique<ThreadPoolTempl<Env> >(name,
threads_to_create,
low_latency_hint,
*env,

View file

@ -1051,7 +1051,7 @@ Status SequentialPlanner::CreatePlan(
const ISequentialPlannerContext& context,
std::unique_ptr<SequentialExecutionPlan>& plan) {
// allocate/reset here so we know it's clean
plan = onnxruntime::make_unique<SequentialExecutionPlan>();
plan = std::make_unique<SequentialExecutionPlan>();
PlannerImpl planner(parent_node, graph_viewer, outer_scope_node_args, providers,
kernel_create_info_map, ort_value_name_idx_map, context, *plan);

View file

@ -47,10 +47,10 @@ AllocatorPtr CreateAllocator(const AllocatorCreationInfo& info) {
#ifdef USE_MIMALLOC
return std::shared_ptr<IArenaAllocator>(
onnxruntime::make_unique<MiMallocArena>(std::move(device_allocator), max_mem));
std::make_unique<MiMallocArena>(std::move(device_allocator), max_mem));
#else
return std::shared_ptr<IArenaAllocator>(
onnxruntime::make_unique<BFCArena>(std::move(device_allocator),
std::make_unique<BFCArena>(std::move(device_allocator),
max_mem,
arena_extend_str,
initial_chunk_size_bytes,

View file

@ -90,7 +90,7 @@ void IExecutionFrame::UpdateFetches(const std::vector<int>& fetch_mlvalue_idxs,
if (!dest.IsAllocated()) {
AllocatorPtr allocator = GetAllocator(src.Location());
auto p_tensor = onnxruntime::make_unique<Tensor>(src.DataType(), src.Shape(), allocator);
auto p_tensor = std::make_unique<Tensor>(src.DataType(), src.Shape(), allocator);
auto ml_tensor = DataTypeImpl::GetType<Tensor>();
dest.Init(p_tensor.release(), ml_tensor, ml_tensor->GetDeleteFunc());
}
@ -249,7 +249,7 @@ void IExecutionFrame::Init(const std::vector<int>& feed_mlvalue_idxs, const std:
// If the initializer is providing the output, the shape is known.
AllocatorPtr allocator = GetAllocator(src.Location());
auto p_tensor = onnxruntime::make_unique<Tensor>(src.DataType(), src.Shape(), allocator);
auto p_tensor = std::make_unique<Tensor>(src.DataType(), src.Shape(), allocator);
auto ml_tensor = DataTypeImpl::GetType<Tensor>();
dest.Init(p_tensor.release(), ml_tensor, ml_tensor->GetDeleteFunc());
}
@ -340,7 +340,7 @@ ExecutionFrame::ExecutionFrame(const std::vector<int>& feed_mlvalue_idxs, const
mem_patterns_ = session_state.GetMemoryPatternGroup(input_shapes, feed_mlvalue_idxs, inferred_shapes_);
// if no existing patterns, generate one in this executionframe
if (!mem_patterns_) {
planner_ = onnxruntime::make_unique<OrtValuePatternPlanner>(*session_state.GetExecutionPlan());
planner_ = std::make_unique<OrtValuePatternPlanner>(*session_state.GetExecutionPlan());
} else {
// pre-allocate the big chunk requested in memory pattern.
// all the internal kernel's input/output tensors will be allocated on these buffer.
@ -486,7 +486,7 @@ Status ExecutionFrame::AllocateMLValueTensorSelfOwnBufferHelper(OrtValue& ort_va
//no memory pattern, or the pattern is not correct.
if (!alloc) alloc = GetAllocator(location);
std::unique_ptr<Tensor> p_tensor = onnxruntime::make_unique<Tensor>(element_type, shape, alloc);
std::unique_ptr<Tensor> p_tensor = std::make_unique<Tensor>(element_type, shape, alloc);
{
auto ml_tensor = DataTypeImpl::GetType<Tensor>();
@ -564,7 +564,7 @@ Status ExecutionFrame::AllocateTensorWithPreAllocateBufferHelper(OrtValue& ort_v
const OrtMemoryInfo& location,
const TensorShape& shape) {
auto ml_tensor = DataTypeImpl::GetType<Tensor>();
auto p_tensor = onnxruntime::make_unique<Tensor>(element_type, shape, pBuffer, location);
auto p_tensor = std::make_unique<Tensor>(element_type, shape, pBuffer, location);
ort_value.Init(p_tensor.release(), ml_tensor, ml_tensor->GetDeleteFunc());
return Status::OK();
@ -578,7 +578,7 @@ static Status AllocateTraditionalMLValue(OrtValue& ort_value, const NonTensorTyp
static Status AllocateTensorSequence(OrtValue& ort_value) {
auto ml_tensor_sequence = DataTypeImpl::GetType<TensorSeq>();
auto p_tensor_sequence = onnxruntime::make_unique<TensorSeq>();
auto p_tensor_sequence = std::make_unique<TensorSeq>();
ort_value.Init(p_tensor_sequence.release(), ml_tensor_sequence, ml_tensor_sequence->GetDeleteFunc());
return Status::OK();
@ -588,7 +588,7 @@ static Status AllocateSparseTensor(MLValue& mlvalue, const DataTypeImpl& ml_type
const TensorShape& shape, size_t nnz, bool create_fence,
const SessionState& session_state) {
auto element_type = ml_type.AsSparseTensorType()->GetElementType();
auto sparse = onnxruntime::make_unique<SparseTensor>(element_type, shape, nnz, allocator);
auto sparse = std::make_unique<SparseTensor>(element_type, shape, nnz, allocator);
auto deleter = DataTypeImpl::GetType<SparseTensor>()->GetDeleteFunc();
mlvalue.Init(sparse.release(), DataTypeImpl::GetType<SparseTensor>(), deleter);

View file

@ -34,9 +34,9 @@ IExecutionProvider::GetCapability(const onnxruntime::GraphViewer& graph,
for (auto& node : graph.Nodes()) {
for (auto registry : kernel_registries) {
if (KernelRegistry::HasImplementationOf(*registry, node, Type())) {
std::unique_ptr<IndexedSubGraph> sub_graph = onnxruntime::make_unique<IndexedSubGraph>();
std::unique_ptr<IndexedSubGraph> sub_graph = std::make_unique<IndexedSubGraph>();
sub_graph->nodes.push_back(node.Index());
result.push_back(onnxruntime::make_unique<ComputeCapability>(std::move(sub_graph)));
result.push_back(std::make_unique<ComputeCapability>(std::move(sub_graph)));
break;
}
}

View file

@ -46,7 +46,7 @@ Status FeedsFetchesManager::Create(const std::vector<std::string>& feed_names,
std::unique_ptr<FeedsFetchesManager>& feed_fetch_manager) {
FeedsFetchesInfo info{feed_names, output_names, ort_value_name_idx_map};
feed_fetch_manager = onnxruntime::make_unique<FeedsFetchesManager>(std::move(info));
feed_fetch_manager = std::make_unique<FeedsFetchesManager>(std::move(info));
return Status::OK();
}

View file

@ -9,7 +9,7 @@ class FuncManager {
public:
FuncManager()
: fused_funcs_(std::make_shared<std::unordered_map<std::string, FuncInfo> >()),
lib_loader_(onnxruntime::make_unique<ExLibLoader>()) {
lib_loader_(std::make_unique<ExLibLoader>()) {
}
Status AddFuncInfo(const std::string& name, const std::string& dll_path);

View file

@ -273,7 +273,7 @@ static Status PartitionOnnxFormatModelImpl(Graph& graph, bool export_dll, FuncMa
for (size_t j = 0, end = nodes_to_compile.size(); j < end; j++) {
auto* node = nodes_to_compile[j];
const auto& cur_capability = *capabilities_to_compile[j];
viewers.push_back(onnxruntime::make_unique<GraphViewer>(graph, *cur_capability.sub_graph));
viewers.push_back(std::make_unique<GraphViewer>(graph, *cur_capability.sub_graph));
nodes_and_viewers.push_back(IExecutionProvider::FusedNodeAndGraph{*node, *viewers.back()});
}
@ -444,7 +444,7 @@ static Status PartitionOrtFormatModelImpl(Graph& graph, FuncManager& func_mgr,
//
// TODO: Could avoid the topological sort in the GraphViewer ctor by constructing from an existing
// GraphViewer instance instead of the Graph (copying the topological order instead of recalculating).
viewers.push_back(onnxruntime::make_unique<GraphViewer>(graph, indexed_sub_graph));
viewers.push_back(std::make_unique<GraphViewer>(graph, indexed_sub_graph));
nodes_and_viewers.push_back(IExecutionProvider::FusedNodeAndGraph{fused_node, *viewers.back()});
}

View file

@ -69,7 +69,7 @@ class TypeBindingResolver {
: node_(node),
type_binding_map_() {
if (use_lookup_map) {
type_binding_map_ = onnxruntime::make_unique<TypeBindingMap>();
type_binding_map_ = std::make_unique<TypeBindingMap>();
TraverseFormalParametersWithTypeProto(
node_,
[](const ONNX_NAMESPACE::OpSchema::FormalParameter&) -> bool { return true; },

View file

@ -10,7 +10,7 @@ using namespace ::onnxruntime::common;
namespace onnxruntime {
std::unique_ptr<OpKernelInfo> CopyOpKernelInfo(const OpKernelInfo& info) {
return onnxruntime::make_unique<OpKernelInfo>(info);
return std::make_unique<OpKernelInfo>(info);
}
const onnxruntime::Node& OpKernel::Node() const {

View file

@ -9,7 +9,7 @@ namespace onnxruntime {
OrtValuePatternPlanner::OrtValuePatternPlanner(const ExecutionPlanBase& execution_plan, bool trace_using_counters)
: execution_planner_(execution_plan) {
for (auto& location : execution_plan.GetAllLocations()) {
planner_map_.emplace(location, onnxruntime::make_unique<MemPatternPlanner>(trace_using_counters));
planner_map_.emplace(location, std::make_unique<MemPatternPlanner>(trace_using_counters));
}
}

View file

@ -80,7 +80,7 @@ void OrtValueTensorSlicer<T>::Iterator::MaterializeMLValue() const {
//
// TODO: Ideally we could avoid the overhead of creating a new Tensor (mainly cost of copying type and shape info)
// and would simply update Tensor::p_data_ given all other info remains constant for each slice.
auto sub_tensor = onnxruntime::make_unique<Tensor>(tensor_data_type_, per_iteration_shape_,
auto sub_tensor = std::make_unique<Tensor>(tensor_data_type_, per_iteration_shape_,
const_cast<void*>(tensor_slice_data_raw), *tensor_location_);
auto ml_tensor = DataTypeImpl::GetType<Tensor>();
current_ = OrtValue{sub_tensor.release(), ml_tensor, ml_tensor->GetDeleteFunc()};

View file

@ -470,7 +470,7 @@ Status PartialExecutor::Execute(const SessionState& session_state, const std::ve
}
if (all_tensors) {
auto mem_patterns = onnxruntime::make_unique<MemoryPatternGroup>();
auto mem_patterns = std::make_unique<MemoryPatternGroup>();
ORT_RETURN_IF_ERROR(frame.GeneratePatterns(mem_patterns.get()));
ORT_RETURN_IF_ERROR(session_state.UpdateMemoryPatternGroupCache(input_shapes, std::move(mem_patterns)));
}

View file

@ -38,7 +38,7 @@ Status ParallelExecutor::Execute(const SessionState& session_state, const std::v
tp = session_state.Profiler().Now();
}
root_frame_ = onnxruntime::make_unique<ExecutionFrame>(feed_mlvalue_idxs, feeds, fetch_mlvalue_idxs, fetches,
root_frame_ = std::make_unique<ExecutionFrame>(feed_mlvalue_idxs, feeds, fetch_mlvalue_idxs, fetches,
fetch_allocators, session_state);
//std::cout << "start nodes:" << std::endl;
for (auto node_index : session_state.GetGraphViewer().GetRootNodes()) {
@ -94,7 +94,7 @@ Status ParallelExecutor::Execute(const SessionState& session_state, const std::v
}
if (all_tensors) {
auto mem_patterns = onnxruntime::make_unique<MemoryPatternGroup>();
auto mem_patterns = std::make_unique<MemoryPatternGroup>();
ORT_RETURN_IF_ERROR(root_frame_->GeneratePatterns(mem_patterns.get()));
ORT_RETURN_IF_ERROR(session_state.UpdateMemoryPatternGroupCache(input_shapes, std::move(mem_patterns)));
}

View file

@ -27,7 +27,7 @@ struct PartialGraphExecutionState {
const std::unordered_map<size_t, IExecutor::CustomAllocator>& fetch_allocators,
const SessionState& session_state) {
if (execution_frame_ == nullptr) {
execution_frame_ = onnxruntime::make_unique<ExecutionFrame>(feed_mlvalue_idxs, feeds, fetch_mlvalue_idxs, fetches,
execution_frame_ = std::make_unique<ExecutionFrame>(feed_mlvalue_idxs, feeds, fetch_mlvalue_idxs, fetches,
fetch_allocators, session_state);
} else {
execution_frame_->UpdateFeeds(feed_mlvalue_idxs, feeds);

View file

@ -127,20 +127,20 @@ struct ProviderHostImpl : ProviderHost {
}
std::unique_ptr<IAllocator> CreateCPUAllocator(const OrtMemoryInfo& memory_info) override {
return onnxruntime::make_unique<CPUAllocator>(memory_info);
return std::make_unique<CPUAllocator>(memory_info);
};
#ifdef USE_TENSORRT
std::unique_ptr<IAllocator> CreateCUDAAllocator(int16_t device_id, const char* name) override {
return onnxruntime::make_unique<CUDAAllocator>(device_id, name);
return std::make_unique<CUDAAllocator>(device_id, name);
}
std::unique_ptr<IAllocator> CreateCUDAPinnedAllocator(int16_t device_id, const char* name) override {
return onnxruntime::make_unique<CUDAPinnedAllocator>(device_id, name);
return std::make_unique<CUDAPinnedAllocator>(device_id, name);
}
std::unique_ptr<IDataTransfer> CreateGPUDataTransfer(void* stream) override {
return onnxruntime::make_unique<GPUDataTransfer>(static_cast<cudaStream_t>(stream));
return std::make_unique<GPUDataTransfer>(static_cast<cudaStream_t>(stream));
}
void cuda__Impl_Cast(void* stream, const int64_t* input_data, int32_t* output_data, size_t count) override {
@ -231,7 +231,7 @@ struct ProviderHostImpl : ProviderHost {
// logging::Capture
std::unique_ptr<logging::Capture> logging__Capture__construct(const logging::Logger& logger, logging::Severity severity, const char* category, logging::DataType dataType, const CodeLocation& location) override {
return onnxruntime::make_unique<logging::Capture>(logger, severity, category, dataType, location);
return std::make_unique<logging::Capture>(logger, severity, category, dataType, location);
}
void logging__Capture__operator_delete(logging::Capture* p) noexcept override { delete p; }
std::ostream& logging__Capture__Stream(logging::Capture* p) noexcept override { return p->Stream(); }
@ -253,7 +253,7 @@ struct ProviderHostImpl : ProviderHost {
ONNX_NAMESPACE::TypeProto_Tensor* TypeProto__mutable_tensor_type(ONNX_NAMESPACE::TypeProto* p) override { return p->mutable_tensor_type(); }
// AttributeProto
std::unique_ptr<ONNX_NAMESPACE::AttributeProto> AttributeProto__construct() override { return onnxruntime::make_unique<ONNX_NAMESPACE::AttributeProto>(); }
std::unique_ptr<ONNX_NAMESPACE::AttributeProto> AttributeProto__construct() override { return std::make_unique<ONNX_NAMESPACE::AttributeProto>(); }
void AttributeProto__operator_delete(ONNX_NAMESPACE::AttributeProto* p) override { delete p; }
void AttributeProto__operator_assign(ONNX_NAMESPACE::AttributeProto* p, const ONNX_NAMESPACE::AttributeProto& v) override { *p = v; }
@ -290,7 +290,7 @@ struct ProviderHostImpl : ProviderHost {
void GraphProto__operator_assign(ONNX_NAMESPACE::GraphProto* p, const ONNX_NAMESPACE::GraphProto& v) override { *p = v; }
// ModelProto
std::unique_ptr<ONNX_NAMESPACE::ModelProto> ModelProto__construct() override { return onnxruntime::make_unique<ONNX_NAMESPACE::ModelProto>(); }
std::unique_ptr<ONNX_NAMESPACE::ModelProto> ModelProto__construct() override { return std::make_unique<ONNX_NAMESPACE::ModelProto>(); }
void ModelProto__operator_delete(ONNX_NAMESPACE::ModelProto* p) override { delete p; }
bool ModelProto__SerializeToString(const ONNX_NAMESPACE::ModelProto* p, std::string& string) override { return p->SerializeToString(&string); }
@ -321,11 +321,11 @@ struct ProviderHostImpl : ProviderHost {
// TensorShapeProto_Dimensions
std::unique_ptr<TensorShapeProto_Dimension_Iterator> TensorShapeProto_Dimensions__begin(const ONNX_NAMESPACE::TensorShapeProto_Dimensions* p) override {
return onnxruntime::make_unique<TensorShapeProto_Dimension_Iterator_Impl>(p->begin());
return std::make_unique<TensorShapeProto_Dimension_Iterator_Impl>(p->begin());
}
std::unique_ptr<TensorShapeProto_Dimension_Iterator> TensorShapeProto_Dimensions__end(const ONNX_NAMESPACE::TensorShapeProto_Dimensions* p) override {
return onnxruntime::make_unique<TensorShapeProto_Dimension_Iterator_Impl>(p->end());
return std::make_unique<TensorShapeProto_Dimension_Iterator_Impl>(p->end());
}
// TensorShapeProto
@ -347,7 +347,7 @@ struct ProviderHostImpl : ProviderHost {
const ONNX_NAMESPACE::ValueInfoProto& ValueInfoProtos__operator_array(const ONNX_NAMESPACE::ValueInfoProtos* p, int index) override { return (*p)[index]; }
// ComputeCapability
std::unique_ptr<ComputeCapability> ComputeCapability__construct(std::unique_ptr<IndexedSubGraph> t_sub_graph) override { return onnxruntime::make_unique<ComputeCapability>(std::move(t_sub_graph)); }
std::unique_ptr<ComputeCapability> ComputeCapability__construct(std::unique_ptr<IndexedSubGraph> t_sub_graph) override { return std::make_unique<ComputeCapability>(std::move(t_sub_graph)); }
void ComputeCapability__operator_delete(ComputeCapability* p) override { delete p; }
std::unique_ptr<IndexedSubGraph>& ComputeCapability__SubGraph(ComputeCapability* p) override { return p->sub_graph; }
@ -359,7 +359,7 @@ struct ProviderHostImpl : ProviderHost {
Status IDataTransfer__CopyTensors(const IDataTransfer* p, const std::vector<IDataTransfer::SrcDstPair>& src_dst_pairs) override { return p->IDataTransfer::CopyTensors(src_dst_pairs); }
// IndexedSubGraph_MetaDef
std::unique_ptr<IndexedSubGraph_MetaDef> IndexedSubGraph_MetaDef__construct() override { return onnxruntime::make_unique<IndexedSubGraph::MetaDef>(); }
std::unique_ptr<IndexedSubGraph_MetaDef> IndexedSubGraph_MetaDef__construct() override { return std::make_unique<IndexedSubGraph::MetaDef>(); }
void IndexedSubGraph_MetaDef__operator_delete(IndexedSubGraph_MetaDef* p) override { delete p; }
std::string& IndexedSubGraph_MetaDef__name(IndexedSubGraph_MetaDef* p) override { return p->name; }
@ -372,7 +372,7 @@ struct ProviderHostImpl : ProviderHost {
std::string& IndexedSubGraph_MetaDef__doc_string(IndexedSubGraph_MetaDef* p) override { return p->doc_string; }
// IndexedSubGraph
std::unique_ptr<IndexedSubGraph> IndexedSubGraph__construct() override { return onnxruntime::make_unique<IndexedSubGraph>(); }
std::unique_ptr<IndexedSubGraph> IndexedSubGraph__construct() override { return std::make_unique<IndexedSubGraph>(); }
void IndexedSubGraph__operator_delete(IndexedSubGraph* p) override { delete p; }
std::vector<onnxruntime::NodeIndex>& IndexedSubGraph__Nodes(IndexedSubGraph* p) override { return p->nodes; }
@ -385,7 +385,7 @@ struct ProviderHostImpl : ProviderHost {
int KernelDef__ExecQueueId(const KernelDef* p) override { return p->ExecQueueId(); }
// KernelDefBuilder
std::unique_ptr<KernelDefBuilder> KernelDefBuilder__construct() override { return onnxruntime::make_unique<KernelDefBuilder>(); }
std::unique_ptr<KernelDefBuilder> KernelDefBuilder__construct() override { return std::make_unique<KernelDefBuilder>(); }
void KernelDefBuilder__operator_delete(KernelDefBuilder* p) override { delete p; }
void KernelDefBuilder__SetName(KernelDefBuilder* p, const char* op_name) override { p->SetName(op_name); }
@ -428,14 +428,14 @@ struct ProviderHostImpl : ProviderHost {
size_t Node__GetInputEdgesCount(const Node* p) noexcept override { return p->GetInputEdgesCount(); }
size_t Node__GetOutputEdgesCount(const Node* p) noexcept override { return p->GetOutputEdgesCount(); }
std::unique_ptr<Node__NodeIterator> Node__InputNodesBegin(const Node* p) noexcept override { return onnxruntime::make_unique<Node__NodeIterator_Impl>(p->InputNodesBegin()); }
std::unique_ptr<Node__NodeIterator> Node__InputNodesEnd(const Node* p) noexcept override { return onnxruntime::make_unique<Node__NodeIterator_Impl>(p->InputNodesEnd()); }
std::unique_ptr<Node__NodeIterator> Node__InputNodesBegin(const Node* p) noexcept override { return std::make_unique<Node__NodeIterator_Impl>(p->InputNodesBegin()); }
std::unique_ptr<Node__NodeIterator> Node__InputNodesEnd(const Node* p) noexcept override { return std::make_unique<Node__NodeIterator_Impl>(p->InputNodesEnd()); }
std::unique_ptr<Node__NodeIterator> Node__OutputNodesBegin(const Node* p) noexcept override { return onnxruntime::make_unique<Node__NodeIterator_Impl>(p->OutputNodesBegin()); }
std::unique_ptr<Node__NodeIterator> Node__OutputNodesEnd(const Node* p) noexcept override { return onnxruntime::make_unique<Node__NodeIterator_Impl>(p->OutputNodesEnd()); }
std::unique_ptr<Node__NodeIterator> Node__OutputNodesBegin(const Node* p) noexcept override { return std::make_unique<Node__NodeIterator_Impl>(p->OutputNodesBegin()); }
std::unique_ptr<Node__NodeIterator> Node__OutputNodesEnd(const Node* p) noexcept override { return std::make_unique<Node__NodeIterator_Impl>(p->OutputNodesEnd()); }
std::unique_ptr<Node__EdgeIterator> Node__OutputEdgesBegin(const Node* p) noexcept override { return onnxruntime::make_unique<Node__EdgeIterator_Impl>(p->OutputEdgesBegin()); }
std::unique_ptr<Node__EdgeIterator> Node__OutputEdgesEnd(const Node* p) noexcept override { return onnxruntime::make_unique<Node__EdgeIterator_Impl>(p->OutputEdgesEnd()); }
std::unique_ptr<Node__EdgeIterator> Node__OutputEdgesBegin(const Node* p) noexcept override { return std::make_unique<Node__EdgeIterator_Impl>(p->OutputEdgesBegin()); }
std::unique_ptr<Node__EdgeIterator> Node__OutputEdgesEnd(const Node* p) noexcept override { return std::make_unique<Node__EdgeIterator_Impl>(p->OutputEdgesEnd()); }
void Node__ForEachDef(const Node* p, std::function<void(const NodeArg&, bool is_input)> func, bool include_missing_optional_defs) override { p->ForEachDef(func, std::move(include_missing_optional_defs)); }
@ -448,7 +448,7 @@ struct ProviderHostImpl : ProviderHost {
const ONNX_NAMESPACE::TypeProto* NodeArg__TypeAsProto(const NodeArg* p) noexcept override { return p->TypeAsProto(); }
// NodeAttributes
std::unique_ptr<NodeAttributes> NodeAttributes__construct() override { return onnxruntime::make_unique<NodeAttributes>(); }
std::unique_ptr<NodeAttributes> NodeAttributes__construct() override { return std::make_unique<NodeAttributes>(); }
void NodeAttributes__operator_delete(NodeAttributes* p) noexcept override { delete p; }
size_t NodeAttributes__size(const NodeAttributes* p) override { return p->size(); }
void NodeAttributes__clear(NodeAttributes* p) noexcept override { return p->clear(); }
@ -458,24 +458,24 @@ struct ProviderHostImpl : ProviderHost {
void NodeAttributes__operator_assign(NodeAttributes* p, const NodeAttributes& v) override { *p = v; }
std::unique_ptr<NodeAttributes_Iterator> NodeAttributes__begin(const NodeAttributes* p) override {
return onnxruntime::make_unique<NodeAttributes_Iterator_Impl>(p->begin());
return std::make_unique<NodeAttributes_Iterator_Impl>(p->begin());
}
std::unique_ptr<NodeAttributes_Iterator> NodeAttributes__end(const NodeAttributes* p) override {
return onnxruntime::make_unique<NodeAttributes_Iterator_Impl>(p->end());
return std::make_unique<NodeAttributes_Iterator_Impl>(p->end());
}
std::unique_ptr<NodeAttributes_Iterator> NodeAttributes__find(const NodeAttributes* p, const std::string& key) override {
return onnxruntime::make_unique<NodeAttributes_Iterator_Impl>(p->find(key));
return std::make_unique<NodeAttributes_Iterator_Impl>(p->find(key));
}
void NodeAttributes__insert(NodeAttributes* p, const NodeAttributes& v) override { return p->insert(v.begin(), v.end()); }
// Model
void Model__operator_delete(Model* p) override { delete p; }
Graph& Model__MainGraph(Model* p) override { return p->MainGraph(); }
std::unique_ptr<ONNX_NAMESPACE::ModelProto> Model__ToProto(Model* p) override { return onnxruntime::make_unique<ONNX_NAMESPACE::ModelProto>(p->ToProto()); }
std::unique_ptr<ONNX_NAMESPACE::ModelProto> Model__ToProto(Model* p) override { return std::make_unique<ONNX_NAMESPACE::ModelProto>(p->ToProto()); }
// Graph
std::unique_ptr<GraphViewer> Graph__CreateGraphViewer(const Graph* p) override { return onnxruntime::make_unique<GraphViewer>(*p); }
std::unique_ptr<ONNX_NAMESPACE::GraphProto> Graph__ToGraphProto(const Graph* p) override { return onnxruntime::make_unique<ONNX_NAMESPACE::GraphProto>(p->ToGraphProto()); }
std::unique_ptr<GraphViewer> Graph__CreateGraphViewer(const Graph* p) override { return std::make_unique<GraphViewer>(*p); }
std::unique_ptr<ONNX_NAMESPACE::GraphProto> Graph__ToGraphProto(const Graph* p) override { return std::make_unique<ONNX_NAMESPACE::GraphProto>(p->ToGraphProto()); }
NodeArg& Graph__GetOrCreateNodeArg(Graph* p, const std::string& name, const ONNX_NAMESPACE::TypeProto* p_arg_type) override { return p->GetOrCreateNodeArg(name, p_arg_type); }
@ -494,7 +494,7 @@ struct ProviderHostImpl : ProviderHost {
// GraphViewer
void GraphViewer__operator_delete(GraphViewer* p) override { delete p; }
std::unique_ptr<Model> GraphViewer__CreateModel(const GraphViewer* graph_viewer, const logging::Logger& logger) override {
return onnxruntime::make_unique<Model>(graph_viewer->Name(), true, ModelMetaData(), PathString(),
return std::make_unique<Model>(graph_viewer->Name(), true, ModelMetaData(), PathString(),
IOnnxRuntimeOpSchemaRegistryList(), graph_viewer->DomainToVersionMap(),
std::vector<ONNX_NAMESPACE::FunctionProto>(), logger);
}

View file

@ -466,7 +466,7 @@ Status SequentialExecutor::Execute(const SessionState& session_state, const std:
}
if (all_tensors) {
auto mem_patterns = onnxruntime::make_unique<MemoryPatternGroup>();
auto mem_patterns = std::make_unique<MemoryPatternGroup>();
ORT_RETURN_IF_ERROR(frame.GeneratePatterns(mem_patterns.get()));
ORT_RETURN_IF_ERROR(session_state.UpdateMemoryPatternGroupCache(input_shapes, std::move(mem_patterns)));
}

View file

@ -71,7 +71,7 @@ AllocatorPtr SessionState::GetAllocator(OrtDevice device) const noexcept {
}
void SessionState::CreateGraphInfo() {
graph_viewer_ = onnxruntime::make_unique<onnxruntime::GraphViewer>(graph_);
graph_viewer_ = std::make_unique<onnxruntime::GraphViewer>(graph_);
// use graph_viewer_ to initialize ort_value_name_idx_map_
LOGS(logger_, VERBOSE) << "SaveMLValueNameIndexMapping";
int idx = 0;
@ -188,7 +188,7 @@ Status SessionState::CreateKernels(const KernelRegistryManager& kernel_registry_
session_kernels_[node.Index()] = op_kernel.release();
}
}
node_index_info_ = onnxruntime::make_unique<NodeIndexInfo>(*graph_viewer_, ort_value_name_idx_map_);
node_index_info_ = std::make_unique<NodeIndexInfo>(*graph_viewer_, ort_value_name_idx_map_);
return Status::OK();
}
@ -535,7 +535,7 @@ const MemoryPatternGroup* SessionState::GetMemoryPatternGroup(const std::vector<
auto it = mem_patterns_.find(key);
if (it == mem_patterns_.end()) {
#ifdef ENABLE_TRAINING
auto mem_patterns = onnxruntime::make_unique<MemoryPatternGroup>();
auto mem_patterns = std::make_unique<MemoryPatternGroup>();
if (GeneratePatternGroupCache(input_shapes, feed_mlvalue_idxs, mem_patterns.get(), inferred_shapes).IsOK()) {
key = CalculateMemoryPatternsKey(input_shapes);
auto ptr = mem_patterns.get();
@ -808,7 +808,7 @@ Status SessionState::CreateSubgraphSessionState() {
ORT_ENFORCE(subgraph, "Main Graph instance should have populated all subgraphs when being resolved.");
auto subgraph_session_state =
onnxruntime::make_unique<SessionState>(*subgraph, execution_providers_, enable_mem_pattern_,
std::make_unique<SessionState>(*subgraph, execution_providers_, enable_mem_pattern_,
thread_pool_, inter_op_thread_pool_, data_transfer_mgr_,
logger_, profiler_);

View file

@ -71,7 +71,7 @@ static common::Status DeserializeTensorProto(const Env& env, const std::basic_st
const DataTypeImpl* const type = DataTypeImpl::TensorTypeFromONNXEnum(tensor_proto.data_type())->GetElementType();
std::unique_ptr<Tensor> p_tensor;
if (m != nullptr) {
p_tensor = onnxruntime::make_unique<Tensor>(type, tensor_shape, m->GetBuffer(), m->GetAllocInfo());
p_tensor = std::make_unique<Tensor>(type, tensor_shape, m->GetBuffer(), m->GetAllocInfo());
if (m->GetLen() < p_tensor->SizeInBytes()) {
return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "Internal error. The preallocated buffer is too small. Requires ",
p_tensor->SizeInBytes(), ", Got ", m->GetLen());
@ -80,12 +80,12 @@ static common::Status DeserializeTensorProto(const Env& env, const std::basic_st
if (use_device_allocator_for_initializers) {
void* tensor_buffer = nullptr;
ORT_RETURN_IF_ERROR(AllocateBufferUsingDeviceAllocatorFromShapeAndType(tensor_shape, type, alloc, tensor_buffer));
p_tensor = onnxruntime::make_unique<Tensor>(type, tensor_shape, tensor_buffer, alloc);
p_tensor = std::make_unique<Tensor>(type, tensor_shape, tensor_buffer, alloc);
} else {
// If the provided allocator is an arena-based allocator, the call to Alloc() will tap into memory from the arena
// (may expand it if there isn't a chunk that can be allotted to the memory request).
// If the provided allocator is non-arena based, the device specific Alloc() call will be used to allocate the necessary memory.
p_tensor = onnxruntime::make_unique<Tensor>(type, tensor_shape, alloc);
p_tensor = std::make_unique<Tensor>(type, tensor_shape, alloc);
}
}
@ -102,12 +102,12 @@ static common::Status DeserializeTensorProto(const Env& env, const std::basic_st
if (use_device_allocator_for_initializers) {
void* tensor_buffer = nullptr;
ORT_RETURN_IF_ERROR(AllocateBufferUsingDeviceAllocatorFromShapeAndType(tensor_shape, type, default_cpu_alloc, tensor_buffer));
p_deserialize_tensor = onnxruntime::make_unique<Tensor>(type, tensor_shape, tensor_buffer, default_cpu_alloc);
p_deserialize_tensor = std::make_unique<Tensor>(type, tensor_shape, tensor_buffer, default_cpu_alloc);
} else {
// If the provided allocator is an arena-based allocator, the call to Alloc() will tap into memory from the arena
// (may expand it if there isn't a chunk that can be allotted to the memory request).
// If the provided allocator is non-arena based, the device specific Alloc() call will be used to allocate the necessary memory.
p_deserialize_tensor = onnxruntime::make_unique<Tensor>(type, tensor_shape, default_cpu_alloc);
p_deserialize_tensor = std::make_unique<Tensor>(type, tensor_shape, default_cpu_alloc);
}
ORT_RETURN_IF_ERROR(utils::TensorProtoToTensor(env, proto_path.c_str(), tensor_proto, *p_deserialize_tensor));

View file

@ -15,9 +15,9 @@ std::unique_ptr<ITensorAllocator> ITensorAllocator::Create(bool enable_mem_patte
const SessionState& session_state,
std::vector<BufferUniquePtr>& weights_buffers) {
if (enable_mem_pattern) {
return onnxruntime::make_unique<TensorAllocatorWithMemPattern>(execution_plan, session_state, weights_buffers);
return std::make_unique<TensorAllocatorWithMemPattern>(execution_plan, session_state, weights_buffers);
} else {
return onnxruntime::make_unique<SimpleTensorAllocator>(execution_plan, session_state, weights_buffers);
return std::make_unique<SimpleTensorAllocator>(execution_plan, session_state, weights_buffers);
}
}
} // namespace onnxruntime

View file

@ -95,7 +95,7 @@ class TensorAllocatorWithMemPattern : public ITensorAllocator {
if (it == buffers_.end()) {
if (block != nullptr && block->size_ == 0) {
// Because the size is 0, this miss find is expected. we won't allocate a buffer with size of zero.
buf_out = onnxruntime::make_unique<MemBuffer>(nullptr, 0, location);
buf_out = std::make_unique<MemBuffer>(nullptr, 0, location);
return Status::OK();
}
return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "Weight buffer for initializer '", name, "' is not found");
@ -105,7 +105,7 @@ class TensorAllocatorWithMemPattern : public ITensorAllocator {
return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "Get preallocated buffer for initializer '", name, "' failed");
}
buf_out = onnxruntime::make_unique<MemBuffer>(reinterpret_cast<char*>(it->second) + block->offset_, block->size_, location);
buf_out = std::make_unique<MemBuffer>(reinterpret_cast<char*>(it->second) + block->offset_, block->size_, location);
return Status::OK();
}
common::Status Trace(int id, const ONNX_NAMESPACE::TensorProto* value) override {

View file

@ -14,7 +14,7 @@ using ::ONNX_NAMESPACE::StringStringEntryProto;
namespace onnxruntime {
Status ExternalDataInfo::Create(const RepeatedPtrField<StringStringEntryProto>& input,
std::unique_ptr<ExternalDataInfo>& out) {
out = onnxruntime::make_unique<ExternalDataInfo>();
out = std::make_unique<ExternalDataInfo>();
const int input_size = input.size();
for (int i = 0; i != input_size; ++i) {
StringStringEntryProto stringmap = input[i];

View file

@ -579,7 +579,7 @@ static Status GetFileContent(
}
// if that fails, try to copy
auto buffer = onnxruntime::make_unique<char[]>(length);
auto buffer = std::make_unique<char[]>(length);
ORT_RETURN_IF_ERROR(env.ReadFileIntoBuffer(
file_path, offset, length, gsl::make_span(buffer.get(), length)));
@ -643,7 +643,7 @@ Status TensorProtoToTensor(const Env& env, const ORTCHAR_T* model_path,
raw_data = const_cast<char*>(tensor_proto.raw_data().data());
// TODO The line above has const-correctness issues. Below is a possible fix which copies the tensor_proto data
// into a writeable buffer. However, it requires extra memory which may exceed the limit for certain tests.
//auto buffer = onnxruntime::make_unique<char[]>(tensor_proto.raw_data().size());
//auto buffer = std::make_unique<char[]>(tensor_proto.raw_data().size());
//std::memcpy(buffer.get(), tensor_proto.raw_data().data(), tensor_proto.raw_data().size());
//deleter_for_file_data.d = OrtCallback{DeleteCharArray, buffer.get()};
//raw_data = buffer.release();
@ -720,7 +720,7 @@ Status TensorProtoToMLValue(const Env& env, const ORTCHAR_T* model_path,
// Note: We permit an empty tensor_shape_vec, and treat it as a scalar (a tensor of size 1).
TensorShape tensor_shape{GetTensorShapeFromTensorProto(tensor_proto)};
const DataTypeImpl* const type = DataTypeImpl::TensorTypeFromONNXEnum(tensor_proto.data_type())->GetElementType();
std::unique_ptr<Tensor> tensorp = onnxruntime::make_unique<Tensor>(type, tensor_shape, m.GetBuffer(), m.GetAllocInfo());
std::unique_ptr<Tensor> tensorp = std::make_unique<Tensor>(type, tensor_shape, m.GetBuffer(), m.GetAllocInfo());
if (tensorp->SizeInBytes() > m.GetLen()) {
return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT, "The preallocated buffer is too small. Requires ",
tensorp->SizeInBytes(), ", Got ", m.GetLen());

View file

@ -116,7 +116,7 @@ static common::Status AllocateHelper(const AllocatorPtr& allocator,
return Status(common::ONNXRUNTIME, common::FAIL, "invalid allocator");
}
std::unique_ptr<Tensor> p_tensor = onnxruntime::make_unique<Tensor>(fetched_tensor.DataType(),
std::unique_ptr<Tensor> p_tensor = std::make_unique<Tensor>(fetched_tensor.DataType(),
fetched_tensor.Shape(),
allocator);
auto ml_tensor = DataTypeImpl::GetType<Tensor>();

View file

@ -147,7 +147,7 @@ static void update_subgraphs_within_function_body(ONNX_NAMESPACE::GraphProto& su
static std::unique_ptr<ONNX_NAMESPACE::OpSchema> CreateSchema(const Graph& graph,
const IndexedSubGraph& nodes_to_fuse) {
const auto* meta_def = nodes_to_fuse.GetMetaDef();
auto op_schema = onnxruntime::make_unique<ONNX_NAMESPACE::OpSchema>();
auto op_schema = std::make_unique<ONNX_NAMESPACE::OpSchema>();
op_schema->SetName(meta_def->name);
op_schema->SetDomain(meta_def->domain);
op_schema->SetDoc(meta_def->doc_string);
@ -277,7 +277,7 @@ FunctionImpl::FunctionImpl(const onnxruntime::Graph& graph,
// as we might make some modifications to the FunctionProto along the way
const auto* node_in_parent_graph = parent_graph_->GetNode(node_index);
op_schema_ = onnxruntime::make_unique<ONNX_NAMESPACE::OpSchema>();
op_schema_ = std::make_unique<ONNX_NAMESPACE::OpSchema>();
op_schema_->SetName(onnx_func_proto_.name());
op_schema_->SetDomain(node_in_parent_graph->Domain());
op_schema_->SetDoc(onnx_func_proto_.doc_string());
@ -481,6 +481,6 @@ ViewerFunctionImpl::~ViewerFunctionImpl() = default;
std::unique_ptr<Function> MakeFunction(const onnxruntime::Graph& graph,
const IndexedSubGraph& nodes_to_fuse,
const logging::Logger& logger) {
return onnxruntime::make_unique<FunctionImpl>(graph, nodes_to_fuse, logger);
return std::make_unique<FunctionImpl>(graph, nodes_to_fuse, logger);
}
} // namespace onnxruntime

View file

@ -1874,7 +1874,7 @@ class InferenceContextImpl : public ONNX_NAMESPACE::InferenceContext {
auto* subgraph = node_.GetMutableGraphAttribute(attribute_name);
if (subgraph) {
auto inferencer = onnxruntime::make_unique<GraphInferencerImpl>(node_, *subgraph, subgraph_inferencing_func_, options_);
auto inferencer = std::make_unique<GraphInferencerImpl>(node_, *subgraph, subgraph_inferencing_func_, options_);
graph_inferencer = inferencer.get();
graph_inferencers_.push_back(std::move(inferencer));
} else {
@ -2395,7 +2395,7 @@ void Graph::InitFunctionBodyForNode(Node& node) {
return; // Incompatible. Do not use this function expansion.
}
auto func_ptr = onnxruntime::make_unique<onnxruntime::FunctionImpl>(*this, node.Index(), onnx_function_proto,
auto func_ptr = std::make_unique<onnxruntime::FunctionImpl>(*this, node.Index(), onnx_function_proto,
logger_);
function_container_.emplace_back(std::move(func_ptr));
@ -3461,7 +3461,7 @@ Node& Graph::BeginFuseSubGraph(const IndexedSubGraph& sub_graph, const std::stri
// if this is a full build create the lightweight Function implementation that provides the schema so that
// kernel lookup works as per usual. in an extended minimal build we do the lookup via a hash so don't
// need to create the schema.
auto func = onnxruntime::make_unique<ViewerFunctionImpl>(*this, sub_graph, logger_);
auto func = std::make_unique<ViewerFunctionImpl>(*this, sub_graph, logger_);
function_container_.push_back(std::move(func));
node.SetFunctionBody(*function_container_.back());
#endif

View file

@ -367,7 +367,7 @@ Status CommonSubexpressionElimination::ApplyImpl(Graph& graph, bool& modified, i
if (it == equivalence_classes.end()) {
// Because nodes are processed in topological order, this will always be
// a non-op value (graph input or constant initializer).
auto value = onnxruntime::make_unique<EquivalenceClass>(input_def);
auto value = std::make_unique<EquivalenceClass>(input_def);
const auto* raw_ptr = value.get();
unique_equivalence_classes.push_back(std::move(value));
value_to_representative.emplace(raw_ptr, Representative{input_def, 0, kInvalidOutputIndex});
@ -385,7 +385,7 @@ Status CommonSubexpressionElimination::ApplyImpl(Graph& graph, bool& modified, i
for (OutputIndex output_index = 0, end = static_cast<int>(node->OutputDefs().size());
output_index < end; ++output_index) {
const NodeArg* output_def = node->OutputDefs()[output_index];
auto equivalence_class = onnxruntime::make_unique<EquivalenceClass>(*node, input_values, output_index, discriminator);
auto equivalence_class = std::make_unique<EquivalenceClass>(*node, input_values, output_index, discriminator);
auto* raw_ptr = equivalence_class.get();
auto it = value_to_representative.find(raw_ptr);

View file

@ -79,7 +79,7 @@ Status ConvBNFusion::Apply(Graph& graph, Node& node, RewriteRuleEffect& rule_eff
conv_B_tensor_proto->data_type() != bn_B_tensor_proto->data_type()) {
return Status::OK();
}
conv_B = onnxruntime::make_unique<Initializer>(*conv_B_tensor_proto, graph.ModelPath());
conv_B = std::make_unique<Initializer>(*conv_B_tensor_proto, graph.ModelPath());
}
// Calculate new value of initializers of conv node

View file

@ -68,7 +68,7 @@ Status ConvMulFusion::Apply(Graph& graph, Node& node, RewriteRuleEffect& rule_ef
return Status::OK();
}
conv_B = onnxruntime::make_unique<Initializer>(*conv_B_tensor_proto, graph.ModelPath());
conv_B = std::make_unique<Initializer>(*conv_B_tensor_proto, graph.ModelPath());
}
// Calculate new value of initializers of conv node

View file

@ -36,7 +36,7 @@ bool ExpandElimination::SatisfyCondition(const Graph& graph, const Node& node, c
return false;
}
auto initializer = onnxruntime::make_unique<Initializer>(*tensor_proto, graph.ModelPath());
auto initializer = std::make_unique<Initializer>(*tensor_proto, graph.ModelPath());
if (initializer->data_type() != ONNX_NAMESPACE::TensorProto_DataType_INT64) {
return false;
}

View file

@ -63,21 +63,21 @@ std::vector<std::unique_ptr<RewriteRule>> GenerateRewriteRules(
std::vector<std::unique_ptr<RewriteRule>> rules;
switch (level) {
case TransformerLevel::Level1:
rules.push_back(onnxruntime::make_unique<EliminateIdentity>());
rules.push_back(onnxruntime::make_unique<EliminateSlice>());
rules.push_back(onnxruntime::make_unique<UnsqueezeElimination>());
rules.push_back(onnxruntime::make_unique<EliminateDropout>());
rules.push_back(onnxruntime::make_unique<ExpandElimination>());
rules.push_back(onnxruntime::make_unique<CastElimination>());
rules.push_back(onnxruntime::make_unique<DivMulFusion>());
rules.push_back(onnxruntime::make_unique<FuseReluClip>());
rules.push_back(onnxruntime::make_unique<GemmTransposeFusion>());
rules.push_back(onnxruntime::make_unique<NotWhereFusion>());
rules.push_back(onnxruntime::make_unique<ShapeToInitializer>());
rules.push_back(onnxruntime::make_unique<ConvAddFusion>());
rules.push_back(onnxruntime::make_unique<ConvMulFusion>());
rules.push_back(onnxruntime::make_unique<ConvBNFusion>());
rules.push_back(onnxruntime::make_unique<ReluQuantFusion>());
rules.push_back(std::make_unique<EliminateIdentity>());
rules.push_back(std::make_unique<EliminateSlice>());
rules.push_back(std::make_unique<UnsqueezeElimination>());
rules.push_back(std::make_unique<EliminateDropout>());
rules.push_back(std::make_unique<ExpandElimination>());
rules.push_back(std::make_unique<CastElimination>());
rules.push_back(std::make_unique<DivMulFusion>());
rules.push_back(std::make_unique<FuseReluClip>());
rules.push_back(std::make_unique<GemmTransposeFusion>());
rules.push_back(std::make_unique<NotWhereFusion>());
rules.push_back(std::make_unique<ShapeToInitializer>());
rules.push_back(std::make_unique<ConvAddFusion>());
rules.push_back(std::make_unique<ConvMulFusion>());
rules.push_back(std::make_unique<ConvBNFusion>());
rules.push_back(std::make_unique<ReluQuantFusion>());
break;
case TransformerLevel::Level2:
@ -117,7 +117,7 @@ std::unique_ptr<RuleBasedGraphTransformer> GenerateRuleBasedGraphTransformer(
}
std::unique_ptr<RuleBasedGraphTransformer> rule_transformer =
onnxruntime::make_unique<RuleBasedGraphTransformer>(GenerateRuleBasedTransformerName(level),
std::make_unique<RuleBasedGraphTransformer>(GenerateRuleBasedTransformerName(level),
compatible_execution_providers);
for (auto& entry : rewrite_rules_to_register) {
rule_transformer->Register(std::move(entry));
@ -141,11 +141,11 @@ std::vector<std::unique_ptr<GraphTransformer>> GenerateTransformers(
switch (level) {
case TransformerLevel::Level1: {
// no filtering on execution provider for L1 optimizations as they only use official ONNX operators
transformers.emplace_back(onnxruntime::make_unique<CommonSubexpressionElimination>());
transformers.emplace_back(onnxruntime::make_unique<ConstantFolding>(execution_provider, !disable_quant_qdq));
transformers.emplace_back(onnxruntime::make_unique<MatMulAddFusion>());
transformers.emplace_back(onnxruntime::make_unique<ReshapeFusion>());
transformers.emplace_back(onnxruntime::make_unique<FreeDimensionOverrideTransformer>(
transformers.emplace_back(std::make_unique<CommonSubexpressionElimination>());
transformers.emplace_back(std::make_unique<ConstantFolding>(execution_provider, !disable_quant_qdq));
transformers.emplace_back(std::make_unique<MatMulAddFusion>());
transformers.emplace_back(std::make_unique<ReshapeFusion>());
transformers.emplace_back(std::make_unique<FreeDimensionOverrideTransformer>(
session_options.free_dimension_overrides));
rule_transformer = GenerateRuleBasedGraphTransformer(level, rules_and_transformers_to_disable, {});
@ -170,38 +170,38 @@ std::vector<std::unique_ptr<GraphTransformer>> GenerateTransformers(
onnxruntime::kArmNNExecutionProvider};
if (!disable_quant_qdq) {
transformers.emplace_back(onnxruntime::make_unique<QDQS8ToU8Transformer>(cpu_ep));
transformers.emplace_back(onnxruntime::make_unique<QDQPropagationTransformer>(cpu_ep));
transformers.emplace_back(onnxruntime::make_unique<QDQTransformer>());
transformers.emplace_back(std::make_unique<QDQS8ToU8Transformer>(cpu_ep));
transformers.emplace_back(std::make_unique<QDQPropagationTransformer>(cpu_ep));
transformers.emplace_back(std::make_unique<QDQTransformer>());
}
transformers.emplace_back(onnxruntime::make_unique<GemmActivationFusion>(cpu_ep));
transformers.emplace_back(onnxruntime::make_unique<MatMulIntegerToFloatFusion>(cpu_ep));
transformers.emplace_back(onnxruntime::make_unique<DynamicQuantizeMatMulFusion>(cpu_ep));
transformers.emplace_back(std::make_unique<GemmActivationFusion>(cpu_ep));
transformers.emplace_back(std::make_unique<MatMulIntegerToFloatFusion>(cpu_ep));
transformers.emplace_back(std::make_unique<DynamicQuantizeMatMulFusion>(cpu_ep));
transformers.emplace_back(onnxruntime::make_unique<ConvActivationFusion>(cpu_cuda_rocm_acl_armnn_eps));
transformers.emplace_back(std::make_unique<ConvActivationFusion>(cpu_cuda_rocm_acl_armnn_eps));
transformers.emplace_back(onnxruntime::make_unique<GeluFusion>(cpu_cuda_rocm_eps));
transformers.emplace_back(onnxruntime::make_unique<LayerNormFusion>(cpu_cuda_rocm_eps));
transformers.emplace_back(onnxruntime::make_unique<SimplifiedLayerNormFusion>(cpu_cuda_rocm_eps));
transformers.emplace_back(onnxruntime::make_unique<AttentionFusion>(cpu_cuda_rocm_eps));
transformers.emplace_back(onnxruntime::make_unique<EmbedLayerNormFusion>(cpu_cuda_rocm_eps));
transformers.emplace_back(std::make_unique<GeluFusion>(cpu_cuda_rocm_eps));
transformers.emplace_back(std::make_unique<LayerNormFusion>(cpu_cuda_rocm_eps));
transformers.emplace_back(std::make_unique<SimplifiedLayerNormFusion>(cpu_cuda_rocm_eps));
transformers.emplace_back(std::make_unique<AttentionFusion>(cpu_cuda_rocm_eps));
transformers.emplace_back(std::make_unique<EmbedLayerNormFusion>(cpu_cuda_rocm_eps));
transformers.emplace_back(onnxruntime::make_unique<BiasDropoutFusion>(cuda_rocm_eps));
transformers.emplace_back(onnxruntime::make_unique<MatmulTransposeFusion>(cpu_cuda_rocm_eps));
transformers.emplace_back(onnxruntime::make_unique<BiasGeluFusion>(cpu_cuda_rocm_eps));
transformers.emplace_back(onnxruntime::make_unique<BiasSoftmaxFusion>(cpu_cuda_rocm_eps));
transformers.emplace_back(onnxruntime::make_unique<SkipLayerNormFusion>(cpu_cuda_rocm_eps));
transformers.emplace_back(std::make_unique<BiasDropoutFusion>(cuda_rocm_eps));
transformers.emplace_back(std::make_unique<MatmulTransposeFusion>(cpu_cuda_rocm_eps));
transformers.emplace_back(std::make_unique<BiasGeluFusion>(cpu_cuda_rocm_eps));
transformers.emplace_back(std::make_unique<BiasSoftmaxFusion>(cpu_cuda_rocm_eps));
transformers.emplace_back(std::make_unique<SkipLayerNormFusion>(cpu_cuda_rocm_eps));
transformers.emplace_back(onnxruntime::make_unique<FastGeluFusion>(cpu_cuda_rocm_eps));
transformers.emplace_back(std::make_unique<FastGeluFusion>(cpu_cuda_rocm_eps));
transformers.emplace_back(onnxruntime::make_unique<MatMulScaleFusion>(cpu_cuda_rocm_eps));
transformers.emplace_back(std::make_unique<MatMulScaleFusion>(cpu_cuda_rocm_eps));
// GeluApproximation has side effects which may change results. It needs to be manually enabled,
// or alternatively the model can be updated offline using a model conversion script
// e.g. fusion_gelu_approximation function used by onnxruntime/python/tools/transformers/onnx_model_bert.py
if (enable_gelu_approximation) {
transformers.emplace_back(onnxruntime::make_unique<GeluApproximation>(cpu_cuda_rocm_eps));
transformers.emplace_back(std::make_unique<GeluApproximation>(cpu_cuda_rocm_eps));
}
#endif
@ -211,10 +211,10 @@ std::vector<std::unique_ptr<GraphTransformer>> GenerateTransformers(
#ifndef DISABLE_CONTRIB_OPS
// Register the NCHWc layout transformer if supported by the platform.
if (MlasNchwcGetBlockSize() > 1) {
transformers.emplace_back(onnxruntime::make_unique<NchwcTransformer>());
transformers.emplace_back(std::make_unique<NchwcTransformer>());
}
transformers.emplace_back(onnxruntime::make_unique<NhwcTransformer>());
transformers.emplace_back(std::make_unique<NhwcTransformer>());
#endif
} break;

View file

@ -182,7 +182,7 @@ void NchwcTransformerImpl::CreateNchwcArgument(Node& node,
std::string output_reorder_def_name = graph_.GenerateNodeArgName("reorder");
auto* output_nchwc_arg = &graph_.GetOrCreateNodeArg(output_reorder_def_name, nullptr);
nchwc_args_[output_original_arg] =
onnxruntime::make_unique<NchwcArgument>(nchwc_node, output_nchwc_arg, original_uses, channels, shape);
std::make_unique<NchwcArgument>(nchwc_node, output_nchwc_arg, original_uses, channels, shape);
output_defs[0] = output_nchwc_arg;
}
@ -194,7 +194,7 @@ void NchwcTransformerImpl::FuseNchwcArgument(Node& node, const NchwcArgument& nc
auto& nchwc_node = nchwc_arg.output_node_;
auto* output_nchwc_arg = nchwc_node.MutableOutputDefs()[0];
nchwc_args_[output_original_arg] =
onnxruntime::make_unique<NchwcArgument>(nchwc_node, output_nchwc_arg, original_uses, nchwc_arg.channels_, nchwc_arg.shape_);
std::make_unique<NchwcArgument>(nchwc_node, output_nchwc_arg, original_uses, nchwc_arg.channels_, nchwc_arg.shape_);
}
void NchwcTransformerImpl::InsertReorderInput(Node& node) {

View file

@ -92,7 +92,7 @@ void NhwcTransformerImpl::CreateNhwcArgument(Node& node, Node& nhwc_node, int ra
std::string output_reorder_def_name = graph_.GenerateNodeArgName("reorder");
auto* output_nhwc_arg = &graph_.GetOrCreateNodeArg(output_reorder_def_name, nullptr);
nhwc_args_[output_original_arg] =
onnxruntime::make_unique<NhwcArgument>(nhwc_node, output_nhwc_arg, original_uses, rank);
std::make_unique<NhwcArgument>(nhwc_node, output_nhwc_arg, original_uses, rank);
output_defs[output_index] = output_nhwc_arg;
}

View file

@ -25,7 +25,7 @@ OptimizerExecutionFrame::Info::Info(const std::vector<const Node*>& nodes,
allocator_ptr_ = execution_provider_.GetAllocator(device_id_, mem_type_);
ORT_ENFORCE(allocator_ptr_, "Failed to get allocator for optimizer");
data_transfer_mgr_.RegisterDataTransfer(onnxruntime::make_unique<CPUDataTransfer>());
data_transfer_mgr_.RegisterDataTransfer(std::make_unique<CPUDataTransfer>());
// Create MLValues related maps
auto initialize_maps = [this, &initialized_tensor_set, &model_path](const NodeArg& arg, size_t /*index*/) -> Status {
@ -60,7 +60,7 @@ OptimizerExecutionFrame::Info::Info(const std::vector<const Node*>& nodes,
ORT_THROW_IF_ERROR(onnxruntime::Node::ForEachWithIndex(node->OutputDefs(), initialize_maps));
}
node_index_info_ = onnxruntime::make_unique<NodeIndexInfo>(nodes, ort_value_name_idx_map_);
node_index_info_ = std::make_unique<NodeIndexInfo>(nodes, ort_value_name_idx_map_);
}
std::unique_ptr<const OpKernel> OptimizerExecutionFrame::Info::CreateKernel(const Node* node) const {
@ -105,14 +105,14 @@ Status OptimizerExecutionFrame::CreateNodeOutputMLValueImpl(OrtValue& ort_value,
if (ml_type->IsSparseTensorType()) {
auto element_type = ml_type->AsSparseTensorType()->GetElementType();
auto container_type = DataTypeImpl::GetType<SparseTensor>();
auto sparse = onnxruntime::make_unique<SparseTensor>(element_type, *shape, nnz, info_.GetAllocator());
auto sparse = std::make_unique<SparseTensor>(element_type, *shape, nnz, info_.GetAllocator());
ort_value.Init(sparse.release(), container_type, container_type->GetDeleteFunc());
return Status::OK();
}
if (ml_type->IsTensorSequenceType()) {
auto element_type = ml_type->AsSequenceTensorBase()->GetElementType();
auto p_sequence = onnxruntime::make_unique<TensorSeq>(element_type);
auto p_sequence = std::make_unique<TensorSeq>(element_type);
auto ml_tensor_sequence = DataTypeImpl::GetType<TensorSeq>();
ort_value.Init(p_sequence.release(), ml_tensor_sequence, ml_tensor_sequence->GetDeleteFunc());
return Status::OK();
@ -129,7 +129,7 @@ Status OptimizerExecutionFrame::CreateNodeOutputMLValueImpl(OrtValue& ort_value,
// tensors
auto element_type = static_cast<const TensorTypeBase*>(ml_type)->GetElementType();
AllocatorPtr allocator_ptr = info_.GetAllocator();
std::unique_ptr<Tensor> p_tensor = onnxruntime::make_unique<Tensor>(element_type,
std::unique_ptr<Tensor> p_tensor = std::make_unique<Tensor>(element_type,
*shape,
allocator_ptr);

View file

@ -1,6 +1,5 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "core/common/make_unique.h"
#include "core/graph/constants.h"
#include "core/graph/onnx_protobuf.h"
#include "core/graph/graph_utils.h"

View file

@ -93,7 +93,7 @@ ACLExecutionProvider::ACLExecutionProvider(const ACLExecutionProviderInfo& info)
AllocatorCreationInfo default_memory_info{
[](int) {
return onnxruntime::make_unique<CPUAllocator>(OrtMemoryInfo(ACL, OrtAllocatorType::OrtDeviceAllocator));
return std::make_unique<CPUAllocator>(OrtMemoryInfo(ACL, OrtAllocatorType::OrtDeviceAllocator));
},
0,
info.create_arena};
@ -102,7 +102,7 @@ ACLExecutionProvider::ACLExecutionProvider(const ACLExecutionProviderInfo& info)
AllocatorCreationInfo cpu_memory_info{
[](int) {
return onnxruntime::make_unique<CPUAllocator>(
return std::make_unique<CPUAllocator>(
OrtMemoryInfo(ACL_CPU, OrtAllocatorType::OrtDeviceAllocator, OrtDevice(), 0, OrtMemTypeCPUOutput));
},
0,

View file

@ -102,7 +102,7 @@ ArmNNExecutionProvider::ArmNNExecutionProvider(const ArmNNExecutionProviderInfo&
AllocatorCreationInfo default_memory_info{
[](int) {
return onnxruntime::make_unique<CPUAllocator>(OrtMemoryInfo(ArmNN, OrtAllocatorType::OrtDeviceAllocator));
return std::make_unique<CPUAllocator>(OrtMemoryInfo(ArmNN, OrtAllocatorType::OrtDeviceAllocator));
},
0};
@ -110,7 +110,7 @@ ArmNNExecutionProvider::ArmNNExecutionProvider(const ArmNNExecutionProviderInfo&
AllocatorCreationInfo cpu_memory_info{
[](int) {
return onnxruntime::make_unique<CPUAllocator>(
return std::make_unique<CPUAllocator>(
OrtMemoryInfo(ArmNN_CPU, OrtAllocatorType::OrtDeviceAllocator, OrtDevice(), 0, OrtMemTypeCPUOutput));
}};

View file

@ -64,7 +64,7 @@ void CreateActivationOpBuilder(const std::string& op_type, OpBuilderRegistration
"Relu",
};
op_registrations.builders.push_back(onnxruntime::make_unique<ActivationOpBuilder>());
op_registrations.builders.push_back(std::make_unique<ActivationOpBuilder>());
for (const auto& op_type : op_types) {
op_registrations.op_builder_map.emplace(op_type, op_registrations.builders.back().get());
}

View file

@ -50,7 +50,7 @@ Status BaseOpBuilder::AddToModelBuilder(ModelBuilder& model_builder, const Node&
/* static */ std::unique_ptr<COREML_SPEC::NeuralNetworkLayer> BaseOpBuilder::CreateNNLayer(const Node& node) {
std::unique_ptr<COREML_SPEC::NeuralNetworkLayer> layer =
onnxruntime::make_unique<COREML_SPEC::NeuralNetworkLayer>();
std::make_unique<COREML_SPEC::NeuralNetworkLayer>();
layer->set_name(node.Name());
return layer;
}

View file

@ -132,7 +132,7 @@ bool BatchNormalizationOpBuilder::IsOpSupportedImpl(const InitializedTensorSet&
}
void CreateBatchNormalizationOpBuilder(const std::string& op_type, OpBuilderRegistrations& op_registrations) {
op_registrations.builders.push_back(onnxruntime::make_unique<BatchNormalizationOpBuilder>());
op_registrations.builders.push_back(std::make_unique<BatchNormalizationOpBuilder>());
op_registrations.op_builder_map.emplace(op_type, op_registrations.builders.back().get());
}

View file

@ -55,7 +55,7 @@ int BinaryOpBuilder::GetMinSupportedOpSet(const Node& /* node */) const {
}
void CreateBinaryOpBuilder(const std::string& op_type, OpBuilderRegistrations& op_registrations) {
op_registrations.builders.push_back(onnxruntime::make_unique<BinaryOpBuilder>());
op_registrations.builders.push_back(std::make_unique<BinaryOpBuilder>());
op_registrations.op_builder_map.emplace(op_type, op_registrations.builders.back().get());
}

View file

@ -80,7 +80,7 @@ bool ConcatOpBuilder::IsOpSupportedImpl(const InitializedTensorSet& /* initializ
}
void CreateConcatOpBuilder(const std::string& op_type, OpBuilderRegistrations& op_registrations) {
op_registrations.builders.push_back(onnxruntime::make_unique<ConcatOpBuilder>());
op_registrations.builders.push_back(std::make_unique<ConcatOpBuilder>());
op_registrations.op_builder_map.emplace(op_type, op_registrations.builders.back().get());
}

View file

@ -146,7 +146,7 @@ bool ConvOpBuilder::IsOpSupportedImpl(const InitializedTensorSet& initializers,
}
void CreateConvOpBuilder(const std::string& op_type, OpBuilderRegistrations& op_registrations) {
op_registrations.builders.push_back(onnxruntime::make_unique<ConvOpBuilder>());
op_registrations.builders.push_back(std::make_unique<ConvOpBuilder>());
op_registrations.op_builder_map.emplace(op_type, op_registrations.builders.back().get());
}

View file

@ -224,7 +224,7 @@ void CreateGemmOpBuilder(const std::string& op_type, OpBuilderRegistrations& op_
"MatMul",
};
op_registrations.builders.push_back(onnxruntime::make_unique<GemmOpBuilder>());
op_registrations.builders.push_back(std::make_unique<GemmOpBuilder>());
for (const auto& op_type : op_types) {
op_registrations.op_builder_map.emplace(op_type, op_registrations.builders.back().get());
}

View file

@ -172,7 +172,7 @@ void CreatePoolOpBuilder(const std::string& op_type, OpBuilderRegistrations& op_
"MaxPool",
};
op_registrations.builders.push_back(onnxruntime::make_unique<PoolOpBuilder>());
op_registrations.builders.push_back(std::make_unique<PoolOpBuilder>());
for (const auto& op_type : op_types) {
op_registrations.op_builder_map.emplace(op_type, op_registrations.builders.back().get());
}

View file

@ -107,7 +107,7 @@ bool ReshapeOpBuilder::IsOpSupportedImpl(const InitializedTensorSet& initializer
}
void CreateReshapeOpBuilder(const std::string& op_type, OpBuilderRegistrations& op_registrations) {
op_registrations.builders.push_back(onnxruntime::make_unique<ReshapeOpBuilder>());
op_registrations.builders.push_back(std::make_unique<ReshapeOpBuilder>());
op_registrations.op_builder_map.emplace(op_type, op_registrations.builders.back().get());
}

View file

@ -265,7 +265,7 @@ bool ResizeOpBuilder::IsOpSupportedImpl(const InitializedTensorSet& initializers
}
void CreateResizeOpBuilder(const std::string& op_type, OpBuilderRegistrations& op_registrations) {
op_registrations.builders.push_back(onnxruntime::make_unique<ResizeOpBuilder>());
op_registrations.builders.push_back(std::make_unique<ResizeOpBuilder>());
op_registrations.op_builder_map.emplace(op_type, op_registrations.builders.back().get());
}

View file

@ -47,7 +47,7 @@ Status TransposeOpBuilder::AddToModelBuilderImpl(ModelBuilder& model_builder,
}
void CreateTransposeOpBuilder(const std::string& op_type, OpBuilderRegistrations& op_registrations) {
op_registrations.builders.push_back(onnxruntime::make_unique<TransposeOpBuilder>());
op_registrations.builders.push_back(std::make_unique<TransposeOpBuilder>());
op_registrations.op_builder_map.emplace(op_type, op_registrations.builders.back().get());
}

View file

@ -23,7 +23,7 @@ ModelBuilder::ModelBuilder(const GraphViewer& graph_viewer, const logging::Logge
}
Status ModelBuilder::Initialize() {
coreml_model_ = onnxruntime::make_unique<CoreML::Specification::Model>();
coreml_model_ = std::make_unique<CoreML::Specification::Model>();
{ // initialize CoreML model
// We support CorelML Specification Version 4 (Core ML 3)
coreml_model_->set_specificationversion(4);

View file

@ -22,14 +22,14 @@ CoreMLExecutionProvider::CoreMLExecutionProvider(uint32_t coreml_flags)
coreml_flags_(coreml_flags) {
AllocatorCreationInfo device_info(
[](int) {
return onnxruntime::make_unique<CPUAllocator>(OrtMemoryInfo(COREML, OrtAllocatorType::OrtDeviceAllocator));
return std::make_unique<CPUAllocator>(OrtMemoryInfo(COREML, OrtAllocatorType::OrtDeviceAllocator));
});
InsertAllocator(CreateAllocator(device_info));
AllocatorCreationInfo cpu_memory_info(
[](int) {
return onnxruntime::make_unique<CPUAllocator>(
return std::make_unique<CPUAllocator>(
OrtMemoryInfo(COREML, OrtAllocatorType::OrtDeviceAllocator, OrtDevice(), 0, OrtMemTypeCPUOutput));
});
@ -98,7 +98,7 @@ CoreMLExecutionProvider::GetCapability(const onnxruntime::GraphViewer& graph_vie
node_set.insert(index);
}
std::unique_ptr<IndexedSubGraph> sub_graph = onnxruntime::make_unique<IndexedSubGraph>();
std::unique_ptr<IndexedSubGraph> sub_graph = std::make_unique<IndexedSubGraph>();
std::unordered_set<const NodeArg*> node_outputs;
std::unordered_set<const NodeArg*> subgraph_inputs;
@ -144,7 +144,7 @@ CoreMLExecutionProvider::GetCapability(const onnxruntime::GraphViewer& graph_vie
// Assign inputs and outputs to subgraph's meta_def
uint64_t model_hash;
int metadef_id = GenerateMetaDefId(graph_viewer, model_hash);
auto meta_def = onnxruntime::make_unique<::onnxruntime::IndexedSubGraph::MetaDef>();
auto meta_def = std::make_unique<::onnxruntime::IndexedSubGraph::MetaDef>();
meta_def->name = "COREML_" + std::to_string(model_hash) + "_" + std::to_string(metadef_id);
meta_def->domain = kMSDomain;
meta_def->since_version = 1;
@ -160,7 +160,7 @@ CoreMLExecutionProvider::GetCapability(const onnxruntime::GraphViewer& graph_vie
sub_graph->SetMetaDef(std::move(meta_def));
result.push_back(onnxruntime::make_unique<ComputeCapability>(std::move(sub_graph)));
result.push_back(std::make_unique<ComputeCapability>(std::move(sub_graph)));
}
LOGS(logger, INFO) << "CoreMLExecutionProvider::GetCapability,"

View file

@ -18,7 +18,7 @@ struct CoreMLProviderFactory : IExecutionProviderFactory {
};
std::unique_ptr<IExecutionProvider> CoreMLProviderFactory::CreateProvider() {
return onnxruntime::make_unique<CoreMLExecutionProvider>(coreml_flags_);
return std::make_unique<CoreMLExecutionProvider>(coreml_flags_);
}
std::shared_ptr<IExecutionProviderFactory> CreateExecutionProviderFactory_CoreML(uint32_t coreml_flags) {

View file

@ -311,7 +311,7 @@ Status Execution::Predict(const std::unordered_map<std::string, OnnxTensorData>&
}
Model::Model(const std::string& path, const logging::Logger& logger, uint32_t coreml_flags)
: execution_(onnxruntime::make_unique<Execution>(path, logger, coreml_flags)) {
: execution_(std::make_unique<Execution>(path, logger, coreml_flags)) {
}
Model::~Model() {}

View file

@ -178,7 +178,7 @@ common::Status If::SetupSubgraphExecutionInfo(const SessionState& session_state,
ORT_ENFORCE(info == nullptr, "SetupSubgraphExecutionInfo should only be called once for each subgraph.");
const auto& node = Node();
info = onnxruntime::make_unique<If::Info>(node, subgraph_session_state.GetGraphViewer());
info = std::make_unique<If::Info>(node, subgraph_session_state.GetGraphViewer());
// all inputs for the If subgraph are implicit
std::vector<std::string> feed_names;

View file

@ -269,7 +269,7 @@ common::Status Loop::SetupSubgraphExecutionInfo(const SessionState& session_stat
ORT_UNUSED_PARAMETER(attribute_name);
const auto& node = Node();
info_ = onnxruntime::make_unique<Loop::Info>(node, subgraph_session_state.GetGraphViewer());
info_ = std::make_unique<Loop::Info>(node, subgraph_session_state.GetGraphViewer());
// the Loop inputs are matched to subgraph feeds based on order.
// we first need the names of the Loop inputs to determine what device they are available on

View file

@ -166,7 +166,7 @@ Status Scan<8>::SetupSubgraphExecutionInfo(const SessionState& session_state,
ORT_UNUSED_PARAMETER(attribute_name);
const auto& node = Node();
info_ = onnxruntime::make_unique<Scan<8>::Info>(node, subgraph_session_state.GetGraphViewer(),
info_ = std::make_unique<Scan<8>::Info>(node, subgraph_session_state.GetGraphViewer(),
static_cast<int>(num_scan_inputs_));
auto status = scan::detail::CreateFeedsFetchesManager(node, *info_, session_state, subgraph_session_state,

View file

@ -214,7 +214,7 @@ Status Scan<9>::SetupSubgraphExecutionInfo(const SessionState& session_state,
ORT_UNUSED_PARAMETER(attribute_name);
const auto& node = Node();
info_ = onnxruntime::make_unique<Scan<9>::Info>(node, subgraph_session_state.GetGraphViewer(),
info_ = std::make_unique<Scan<9>::Info>(node, subgraph_session_state.GetGraphViewer(),
static_cast<int>(num_scan_inputs_));
auto status = scan::detail::CreateFeedsFetchesManager(node, *info_, session_state, subgraph_session_state,

View file

@ -292,7 +292,7 @@ Status IterateSequence(OpKernelContextInternal& context, const SessionState& ses
}
OrtValue AllocateTensorInMLValue(const MLDataType data_type, const TensorShape& shape, AllocatorPtr& allocator) {
auto new_tensor = onnxruntime::make_unique<Tensor>(data_type,
auto new_tensor = std::make_unique<Tensor>(data_type,
shape,
allocator);

View file

@ -18,7 +18,7 @@ class Graph;
template <typename T>
OrtValue MakeScalarMLValue(const AllocatorPtr& allocator, T value, bool is_1d) {
auto* data_type = DataTypeImpl::GetType<T>();
std::unique_ptr<Tensor> p_tensor = onnxruntime::make_unique<Tensor>(data_type,
std::unique_ptr<Tensor> p_tensor = std::make_unique<Tensor>(data_type,
is_1d ? TensorShape({1}) : TensorShape({}),
allocator);

View file

@ -1990,6 +1990,6 @@ std::shared_ptr<KernelRegistry> CPUExecutionProvider::GetKernelRegistry() const
}
std::unique_ptr<IDataTransfer> CPUExecutionProvider::GetDataTransfer() const {
return onnxruntime::make_unique<CPUDataTransfer>();
return std::make_unique<CPUDataTransfer>();
}
} // namespace onnxruntime

View file

@ -40,7 +40,7 @@ class CPUExecutionProvider : public IExecutionProvider {
create_arena = false;
#endif
AllocatorCreationInfo device_info{[](int) { return onnxruntime::make_unique<TAllocator>(); },
AllocatorCreationInfo device_info{[](int) { return std::make_unique<TAllocator>(); },
0, create_arena};
InsertAllocator(CreateAllocator(device_info));

View file

@ -6,7 +6,6 @@
#include <memory>
#include "core/common/make_unique.h"
#include "core/providers/cpu/cpu_execution_provider.h"
#include "core/session/abi_session_options_impl.h"
#include "core/session/ort_apis.h"
@ -25,7 +24,7 @@ struct CpuProviderFactory : IExecutionProviderFactory {
std::unique_ptr<IExecutionProvider> CpuProviderFactory::CreateProvider() {
CPUExecutionProviderInfo info;
info.create_arena = create_arena_;
return onnxruntime::make_unique<CPUExecutionProvider>(info);
return std::make_unique<CPUExecutionProvider>(info);
}
std::shared_ptr<IExecutionProviderFactory> CreateExecutionProviderFactory_CPU(int use_arena) {

View file

@ -15,7 +15,7 @@ class Einsum : public OpKernel {
Einsum(const OpKernelInfo& info) : OpKernel(info) {
ORT_ENFORCE(info.GetAttr<std::string>("equation", &equation_).IsOK(),
"Missing 'equation' attribute");
einsum_equation_preprocessor_ = onnxruntime::make_unique<EinsumEquationPreprocessor>(equation_);
einsum_equation_preprocessor_ = std::make_unique<EinsumEquationPreprocessor>(equation_);
}
virtual Status Compute(OpKernelContext* context) const override;

View file

@ -135,7 +135,7 @@ static std::unique_ptr<Tensor> DiagonalInnermostDims(const Tensor& input,
// Pass in allocator as that will be used as an allocator deleter by the framework
// and it will de-allocate the memory for this intermediate tensor when it goes out of scope
std::unique_ptr<Tensor> output = onnxruntime::make_unique<Tensor>(input.DataType(), output_dims, allocator);
std::unique_ptr<Tensor> output = std::make_unique<Tensor>(input.DataType(), output_dims, allocator);
switch (element_size_in_bytes) {
case 4:
@ -288,7 +288,7 @@ std::unique_ptr<Tensor> Transpose(const Tensor& input, const std::vector<int64_t
// Pass in allocator as that will be used as an allocator deleter by the framework
// and it will de-allocate the memory for this intermediate tensor when it goes out of scope
std::unique_ptr<Tensor> output = onnxruntime::make_unique<Tensor>(input.DataType(), output_dims, allocator);
std::unique_ptr<Tensor> output = std::make_unique<Tensor>(input.DataType(), output_dims, allocator);
TensorShape overriden_shape(input_shape_override);
@ -328,7 +328,7 @@ std::unique_ptr<Tensor> MatMul(const Tensor& input_1, const std::vector<int64_t>
// Pass in allocator as that will be used as an allocator deleter by the framework
// and it will de-allocate the memory for this intermediate tensor when it goes out of scope
std::unique_ptr<Tensor> output = onnxruntime::make_unique<Tensor>(input_1.DataType(), output_dims, allocator);
std::unique_ptr<Tensor> output = std::make_unique<Tensor>(input_1.DataType(), output_dims, allocator);
const T* input_1_data = input_1.template Data<T>();
const T* input_2_data = input_2.template Data<T>();
@ -352,7 +352,7 @@ std::unique_ptr<Tensor> ReduceSum(const Tensor& input, const std::vector<int64_t
const DeviceHelpers::ReduceSum<T>& device_reduce_sum_func) {
TensorShape overriden_shape(input_shape_override);
auto output = device_reduce_sum_func(input, reduce_axes, true, allocator, &overriden_shape, tp, einsum_cuda_assets);
return onnxruntime::make_unique<Tensor>(std::move(output));
return std::make_unique<Tensor>(std::move(output));
}
// Explicit template instantiations of functions

View file

@ -974,7 +974,7 @@ struct TensorAllocator {
template <typename T>
std::unique_ptr<Tensor> Allocate(const TensorShape& shape) const {
return onnxruntime::make_unique<Tensor>(DataTypeImpl::GetType<T>(),
return std::make_unique<Tensor>(DataTypeImpl::GetType<T>(),
shape,
allocator_);
}

View file

@ -17,7 +17,7 @@ class Dropout final: public OpKernel {
Dropout(const OpKernelInfo& info) : OpKernel{info} {
int64_t seed = 0;
if (info.GetAttr<int64_t>("seed", &seed).IsOK()) {
generator_ = onnxruntime::make_unique<RandomGenerator>(seed);
generator_ = std::make_unique<RandomGenerator>(seed);
}
}
@ -58,7 +58,7 @@ Status Dropout<T1, T2>::Compute(OpKernelContext* context) const {
std::unique_ptr<bool[]> temp_mask_buffer{}; // temporary buffer to use if mask input is not provided
auto mask_span = [&X_shape, mask, &temp_mask_buffer]() {
if (mask) return mask->MutableDataAsSpan<bool>();
temp_mask_buffer = onnxruntime::make_unique<bool[]>(X_shape.Size());
temp_mask_buffer = std::make_unique<bool[]>(X_shape.Size());
return gsl::make_span(temp_mask_buffer.get(), X_shape.Size());
}();

View file

@ -136,7 +136,7 @@ class Utf8Converter {
// Temporary buffer assumes 1 byte to 1 wchar_t
// to make sure it is enough.
const size_t buffer_len = iconv_in_bytes * sizeof(wchar_t);
auto buffer = onnxruntime::make_unique<char[]>(buffer_len);
auto buffer = std::make_unique<char[]>(buffer_len);
char* iconv_out = buffer.get();
size_t iconv_out_bytes = buffer_len;
auto ret = iconv(icvt, &iconv_in, &iconv_in_bytes, &iconv_out, &iconv_out_bytes);
@ -170,7 +170,7 @@ class Utf8Converter {
// Temp buffer, assume every code point converts into 3 bytes, this should be enough
// We do not convert terminating zeros
const size_t buffer_len = wstr.length() * 3;
auto buffer = onnxruntime::make_unique<char[]>(buffer_len);
auto buffer = std::make_unique<char[]>(buffer_len);
char* iconv_out = buffer.get();
size_t iconv_out_bytes = buffer_len;

View file

@ -67,7 +67,7 @@ inline size_t PopulateGrams(ForwardIter first, size_t ngrams, size_t ngram_size,
size_t n = 1;
Map* m = &c;
while (true) {
auto p = m->emplace(*first, onnxruntime::make_unique<NgramPart<K>>(0));
auto p = m->emplace(*first, std::make_unique<NgramPart<K>>(0));
++first;
if (n == ngram_size) {
ORT_ENFORCE(p.first->second->id_ == 0, "Duplicate ngram detected, size: ", ngram_size, " id: ", ngram_id);

View file

@ -96,7 +96,7 @@ CastToString(const SrcType& input, std::string& output) {
if (required_buffer_size > buffer_span.size()) {
// didn't get it all, allocate a bigger buffer and retry
dynamic_buffer = onnxruntime::make_unique<char[]>(required_buffer_size);
dynamic_buffer = std::make_unique<char[]>(required_buffer_size);
buffer_span = gsl::make_span(dynamic_buffer.get(), required_buffer_size);
snprintf_result = std::snprintf(buffer_span.data(), buffer_span.size(), format, value);
ORT_ENFORCE(

View file

@ -64,7 +64,7 @@ AllocatorPtr CUDAExecutionProvider::CreateCudaAllocator(OrtDevice::DeviceId devi
if (external_allocator_info.UseExternalAllocator()) {
AllocatorCreationInfo default_memory_info(
[external_allocator_info](OrtDevice::DeviceId id) {
return onnxruntime::make_unique<CUDAExternalAllocator>(id, CUDA, external_allocator_info.alloc, external_allocator_info.free);
return std::make_unique<CUDAExternalAllocator>(id, CUDA, external_allocator_info.alloc, external_allocator_info.free);
},
device_id,
false);
@ -74,7 +74,7 @@ AllocatorPtr CUDAExecutionProvider::CreateCudaAllocator(OrtDevice::DeviceId devi
} else {
AllocatorCreationInfo default_memory_info(
[](OrtDevice::DeviceId id) {
return onnxruntime::make_unique<CUDAAllocator>(id, CUDA);
return std::make_unique<CUDAAllocator>(id, CUDA);
},
device_id,
true,
@ -1990,7 +1990,7 @@ static bool CastNeedFallbackToCPU(const onnxruntime::Node& node) {
}
std::unique_ptr<onnxruntime::IDataTransfer> CUDAExecutionProvider::GetDataTransfer() const {
return onnxruntime::make_unique<onnxruntime::GPUDataTransfer>(static_cast<cudaStream_t>(GetComputeStream()), info_.do_copy_in_default_stream);
return std::make_unique<onnxruntime::GPUDataTransfer>(static_cast<cudaStream_t>(GetComputeStream()), info_.do_copy_in_default_stream);
}
std::vector<std::unique_ptr<ComputeCapability>>
@ -2064,9 +2064,9 @@ CUDAExecutionProvider::GetCapability(const onnxruntime::GraphViewer& graph,
if (cpu_nodes.count(node_index) > 0)
continue;
std::unique_ptr<IndexedSubGraph> sub_graph = onnxruntime::make_unique<IndexedSubGraph>();
std::unique_ptr<IndexedSubGraph> sub_graph = std::make_unique<IndexedSubGraph>();
sub_graph->nodes.push_back(node_index);
result.push_back(onnxruntime::make_unique<ComputeCapability>(std::move(sub_graph)));
result.push_back(std::make_unique<ComputeCapability>(std::move(sub_graph)));
}
return result;
}
@ -2088,7 +2088,7 @@ void CUDAExecutionProvider::RegisterAllocator(std::shared_ptr<AllocatorManager>
if (nullptr == cuda_pinned_alloc) {
AllocatorCreationInfo pinned_memory_info(
[](OrtDevice::DeviceId device_id) {
return onnxruntime::make_unique<CUDAPinnedAllocator>(device_id, CUDA_PINNED);
return std::make_unique<CUDAPinnedAllocator>(device_id, CUDA_PINNED);
},
DEFAULT_CPU_ALLOCATOR_DEVICE_ID);
@ -2106,7 +2106,7 @@ void CUDAExecutionProvider::RegisterAllocator(std::shared_ptr<AllocatorManager>
// CPUAllocator is OrtMemTypeDefault for CPU EP
AllocatorCreationInfo cpu_memory_info(
[](int device_id) {
return onnxruntime::make_unique<CPUAllocator>(
return std::make_unique<CPUAllocator>(
OrtMemoryInfo("CUDA_CPU", OrtAllocatorType::OrtDeviceAllocator, OrtDevice(), device_id,
OrtMemTypeCPUInput));
},

View file

@ -8,7 +8,6 @@
#include "gsl/gsl"
#include "core/common/make_unique.h"
#include "core/providers/cuda/cuda_execution_provider.h"
#include "core/providers/cuda/cuda_execution_provider_info.h"
#include "core/session/abi_session_options_impl.h"
@ -31,7 +30,7 @@ struct CUDAProviderFactory : IExecutionProviderFactory {
};
std::unique_ptr<IExecutionProvider> CUDAProviderFactory::CreateProvider() {
return onnxruntime::make_unique<CUDAExecutionProvider>(info_);
return std::make_unique<CUDAExecutionProvider>(info_);
}
std::shared_ptr<IExecutionProviderFactory> CreateExecutionProviderFactory_CUDA(const CUDAExecutionProviderInfo& info) {

View file

@ -65,7 +65,7 @@ class ConstantBufferImpl : public IConstantBuffer<T> {
template <typename T>
std::unique_ptr<IConstantBuffer<T>> CreateConstantOnes() {
return onnxruntime::make_unique<ConstantBufferImpl<T>>(Consts<T>::One);
return std::make_unique<ConstantBufferImpl<T>>(Consts<T>::One);
}
template std::unique_ptr<IConstantBuffer<float>> CreateConstantOnes<float>();

View file

@ -106,7 +106,7 @@ std::unique_ptr<Tensor> Diagonal(const Tensor& input, int64_t dim_1, int64_t dim
// The diagonal values are stored along `first_dim`
output_dims.erase(output_dims.begin() + second_dim);
std::unique_ptr<Tensor> output = onnxruntime::make_unique<Tensor>(input.DataType(), output_dims, allocator);
std::unique_ptr<Tensor> output = std::make_unique<Tensor>(input.DataType(), output_dims, allocator);
TensorPitches input_strides(input.Shape().GetDims());
cuda::TArray<int64_t> gpu_input_strides(input_strides);

View file

@ -54,7 +54,7 @@ class Dropout final : public CudaKernel {
Dropout(const OpKernelInfo& info) : CudaKernel(info) {
int64_t seed = 0;
if (info.GetAttr<int64_t>("seed", &seed).IsOK()) {
generator_ = onnxruntime::make_unique<PhiloxGenerator>(static_cast<uint64_t>(seed));
generator_ = std::make_unique<PhiloxGenerator>(static_cast<uint64_t>(seed));
}
}

View file

@ -232,7 +232,7 @@ std::vector<std::unique_ptr<ComputeCapability>> DNNLExecutionProvider::GetCapabi
// There are several identical graphs in Model zoo and only differ in
// few attribute values. GetGraphName return graph-name + first-node-output name
std::string graph_name = GetGraphName(graph_viewer);
subgraph_ptr = onnxruntime::make_unique<ort_dnnl::Subgraph>(
subgraph_ptr = std::make_unique<ort_dnnl::Subgraph>(
ort_dnnl::Subgraph(graph_name));
// output name to node index map. Using it to find sub-graph end nodes

View file

@ -26,7 +26,7 @@ struct DnnlProviderFactory : IExecutionProviderFactory {
std::unique_ptr<IExecutionProvider> DnnlProviderFactory::CreateProvider() {
DNNLExecutionProviderInfo info;
info.create_arena = create_arena_;
return onnxruntime::make_unique<DNNLExecutionProvider>(info);
return std::make_unique<DNNLExecutionProvider>(info);
}
struct Dnnl_Provider : Provider {

View file

@ -71,18 +71,18 @@ class DnnlRelu : public DnnlKernel {
ort_source_desc_ = dnnl::memory::desc(
{src_dims}, DnnnType<T>(), ort_source_format_);
source_desc_ = ort_source_desc_;
src_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
src_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({src_dims}, DnnnType<T>(), ort_source_format_));
src_mem_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory({{src_dims}, DnnnType<T>(), ort_source_format_}, cpu_engine, nullptr));
if (gpu_available_) {
src_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(*src_md_, gpu_engine);
src_mem_gpu_ = std::make_unique<dnnl::memory>(*src_md_, gpu_engine);
net.push_back(mkldnn::reorder(*src_mem_, *src_mem_gpu_));
net_args.push_back({{MKLDNN_ARG_SRC, *src_mem_},
{MKLDNN_ARG_DST, *src_mem_gpu_}});
}
} else {
src_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
src_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc(parents_[0].get()->primitive_dst_desc_));
if (!gpu_available_) {
src_mem_ = parents_[0].get()->primitive_dst_mem_;
@ -99,9 +99,9 @@ class DnnlRelu : public DnnlKernel {
dnnl::memory::dims dst_dims_mkl(primitive_dst_shape_.GetDims().begin(), primitive_dst_shape_.GetDims().end());
dnnl::algorithm algo = dnnl::algorithm::eltwise_relu;
fwd_desc_ = onnxruntime::make_unique<dnnl::eltwise_forward::desc>(
fwd_desc_ = std::make_unique<dnnl::eltwise_forward::desc>(
dnnl::eltwise_forward::desc(dnnl::prop_kind::forward_inference, algo, *src_md_, 0));
relu_fwd_pd_ = onnxruntime::make_unique<dnnl::eltwise_forward::primitive_desc>(
relu_fwd_pd_ = std::make_unique<dnnl::eltwise_forward::primitive_desc>(
dnnl::eltwise_forward::primitive_desc(*fwd_desc_, engine_to_use));
primitive_src_desc_ = relu_fwd_pd_.get()->src_desc();
@ -127,7 +127,7 @@ class DnnlRelu : public DnnlKernel {
primitive_dst_mem_ = std::make_shared<dnnl::memory>(dnnl::memory(relu_fwd_pd_.get()->dst_desc(), gpu_engine));
}
relu_fwd_ = onnxruntime::make_unique<dnnl::eltwise_forward>(
relu_fwd_ = std::make_unique<dnnl::eltwise_forward>(
dnnl::eltwise_forward(*relu_fwd_pd_));
if (!gpu_available_) {

View file

@ -138,10 +138,10 @@ class DnnlBatchNorm : public DnnlKernel {
ort_source_desc_ = dnnl::memory::desc(
{src_dims}, DnnnType<T>(), ort_source_format_);
source_desc_ = ort_source_desc_;
src_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
src_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({src_dims}, DnnnType<T>(), ort_source_format_));
} else {
src_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
src_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc(parents_[0].get()->primitive_dst_desc_));
x_shape = parents_[0].get()->primitive_dst_shape_;
ort_source_format_ = parents_[0].get()->ort_source_format_;
@ -210,35 +210,35 @@ class DnnlBatchNorm : public DnnlKernel {
dnnl::memory::dims dst_dims_mkl(
primitive_dst_shape_.GetDims().begin(), primitive_dst_shape_.GetDims().end());
scale_shift_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
scale_shift_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({2, scale_dims_mkl[0]}, DnnnType<T>(), dnnl::memory::format_tag::nc));
mean_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
mean_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({mean_dims_mkl}, DnnnType<T>(), dnnl::memory::format_tag::x));
var_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
var_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({var_dims_mkl}, DnnnType<T>(), dnnl::memory::format_tag::x));
primitive_dst_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
primitive_dst_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({dst_dims_mkl}, DnnnType<T>(), dnnl::memory::format_tag::any));
// scale_shift_mem will allocate 2*C*sizeof(float) buffer
//
scale_shift_mem_ = onnxruntime::make_unique<dnnl::memory>(
scale_shift_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory({*scale_shift_md_, cpu_engine}));
mean_mem_ = onnxruntime::make_unique<dnnl::memory>(
mean_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(*mean_md_, cpu_engine, nullptr));
var_mem_ = onnxruntime::make_unique<dnnl::memory>(
var_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(*var_md_, cpu_engine, nullptr));
if (gpu_available_) {
scale_shift_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(
scale_shift_mem_gpu_ = std::make_unique<dnnl::memory>(
dnnl::memory({*scale_shift_md_, gpu_engine}));
mean_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(
mean_mem_gpu_ = std::make_unique<dnnl::memory>(
dnnl::memory(*mean_md_, gpu_engine));
var_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(
var_mem_gpu_ = std::make_unique<dnnl::memory>(
dnnl::memory(*var_md_, gpu_engine));
}
batchnorm_fwd_ = onnxruntime::make_unique<dnnl::batch_normalization_forward::desc>(
batchnorm_fwd_ = std::make_unique<dnnl::batch_normalization_forward::desc>(
dnnl::batch_normalization_forward::desc(
dnnl::prop_kind::forward_inference, *src_md_, epsilon_,
dnnl::normalization_flags::use_scale_shift |
@ -255,10 +255,10 @@ class DnnlBatchNorm : public DnnlKernel {
ops.append_eltwise(ops_scale, dnnl::algorithm::eltwise_relu, ops_alpha, ops_beta);
attr.set_post_ops(ops);
batchnorm_fwd_pd_ = onnxruntime::make_unique<dnnl::batch_normalization_forward::primitive_desc>(
batchnorm_fwd_pd_ = std::make_unique<dnnl::batch_normalization_forward::primitive_desc>(
dnnl::batch_normalization_forward::primitive_desc(*batchnorm_fwd_, attr, engine_to_use));
} else {
batchnorm_fwd_pd_ = onnxruntime::make_unique<dnnl::batch_normalization_forward::primitive_desc>(
batchnorm_fwd_pd_ = std::make_unique<dnnl::batch_normalization_forward::primitive_desc>(
dnnl::batch_normalization_forward::primitive_desc(
*batchnorm_fwd_, engine_to_use));
}
@ -271,16 +271,16 @@ class DnnlBatchNorm : public DnnlKernel {
if (!gpu_available_) {
if (mklnode_ptr_->parent_nodes.empty()) {
src_mem_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(batchnorm_fwd_pd_.get()->src_desc(), cpu_engine, nullptr));
} else {
src_mem_ = parents_[0].get()->primitive_dst_mem_;
}
} else { // gpu_available_
if (mklnode_ptr_->parent_nodes.empty()) {
src_mem_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(batchnorm_fwd_pd_.get()->src_desc(), cpu_engine, nullptr));
src_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_gpu_ = std::make_unique<dnnl::memory>(
dnnl::memory(batchnorm_fwd_pd_.get()->src_desc(), gpu_engine));
net.push_back(dnnl::reorder(*src_mem_, *src_mem_gpu_));
net_args.push_back({{DNNL_ARG_SRC, *src_mem_},
@ -294,19 +294,19 @@ class DnnlBatchNorm : public DnnlKernel {
if (mklnode_ptr_->output_index >= 0) {
// Use Dnnl's internal output buffer
if (primitive_dst_desc_ != ort_source_desc_) {
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(batchnorm_fwd_pd_->dst_desc(), cpu_engine));
} else {
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(batchnorm_fwd_pd_->dst_desc(), cpu_engine, nullptr));
}
} else {
// last node of sub-graph. need to allocate memory for output_tensor
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(batchnorm_fwd_pd_->dst_desc(), cpu_engine));
}
} else { // gpu_available_
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(batchnorm_fwd_pd_->dst_desc(), gpu_engine));
}

View file

@ -91,7 +91,7 @@ class DnnlConv : public DnnlKernel {
LOGS_DEFAULT(INFO) << "gpu engine found" << std::endl;
}
Ort::CustomOpApi ort{*api};
stream_ = onnxruntime::make_unique<dnnl::stream>(dnnl::stream(cpu_engine));
stream_ = std::make_unique<dnnl::stream>(dnnl::stream(cpu_engine));
int input_index = mklnode_ptr_->input_start_index < 0 ? 0 : mklnode_ptr_->input_start_index;
const OrtValue* winput_tensor = ort.KernelContext_GetInput(context, input_index + 1);
@ -182,7 +182,7 @@ class DnnlConv : public DnnlKernel {
primitive_dst_shape_ = TensorShape(y_dims);
TensorShape output_shape = y_shape.Slice(2);
dnnl::memory::dims dst_dims_mkl(y_dims.begin(), y_dims.end());
primitive_dst_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
primitive_dst_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({dst_dims_mkl}, DnnnType<T>(), dnnl::memory::format_tag::any));
dnnl::memory::dims filter_dims_mkl;
@ -245,15 +245,15 @@ class DnnlConv : public DnnlKernel {
source_desc_ = dnnl::memory::desc({src_dims_mkl}, DnnnType<T>(), src_format);
}
src_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
src_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({src_dims_mkl}, DnnnType<T>(), dnnl::memory::format_tag::any));
// Set the memory descriptors to format::any to allow DNNL to decide what the optimal memory layout should be
// for the computation given the input
filter_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
filter_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({filter_dims_mkl}, DnnnType<T>(), dnnl::memory::format_tag::any));
if (!bias_dims_mkl.empty())
bias_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
bias_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({bias_dims_mkl}, DnnnType<T>(), dnnl::memory::format_tag::any));
dnnl::memory::dims conv_zero_padding = {0, 0};
@ -265,14 +265,14 @@ class DnnlConv : public DnnlKernel {
#endif // ENABLE_TRAINING
if (!bias_dims_mkl.empty()) {
fwd_desc_ = onnxruntime::make_unique<dnnl::convolution_forward::desc>(
fwd_desc_ = std::make_unique<dnnl::convolution_forward::desc>(
dnnl::convolution_forward::desc(
prop_kind, dnnl::algorithm::convolution_direct, *src_md_,
*filter_md_, *bias_md_, *primitive_dst_md_,
strides_mkl, dilations_mkl, padding_left_mkl,
padding_right_mkl));
} else {
fwd_desc_ = onnxruntime::make_unique<dnnl::convolution_forward::desc>(
fwd_desc_ = std::make_unique<dnnl::convolution_forward::desc>(
dnnl::convolution_forward::desc(
prop_kind, dnnl::algorithm::convolution_direct, *src_md_,
*filter_md_, *primitive_dst_md_, strides_mkl,
@ -290,10 +290,10 @@ class DnnlConv : public DnnlKernel {
ops.append_eltwise(ops_scale, dnnl::algorithm::eltwise_relu, ops_alpha, ops_beta);
attr.set_post_ops(ops);
conv_fwd_pd_ = onnxruntime::make_unique<dnnl::convolution_forward::primitive_desc>(
conv_fwd_pd_ = std::make_unique<dnnl::convolution_forward::primitive_desc>(
dnnl::convolution_forward::primitive_desc(*fwd_desc_, attr, engine_to_use));
} else {
conv_fwd_pd_ = onnxruntime::make_unique<dnnl::convolution_forward::primitive_desc>(
conv_fwd_pd_ = std::make_unique<dnnl::convolution_forward::primitive_desc>(
dnnl::convolution_forward::primitive_desc(*fwd_desc_, engine_to_use));
}
@ -310,10 +310,10 @@ class DnnlConv : public DnnlKernel {
filter_size_ = conv_fwd_pd_.get()->weights_desc().get_size();
dst_size_ = conv_fwd_pd_.get()->dst_desc().get_size();
filter_mem_ = onnxruntime::make_unique<dnnl::memory>(
filter_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_.get()->weights_desc(), cpu_engine, nullptr));
if (gpu_available_) {
filter_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(
filter_mem_gpu_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_.get()->weights_desc(), gpu_engine, nullptr));
}
@ -323,19 +323,19 @@ class DnnlConv : public DnnlKernel {
auto pd = dnnl::memory::desc({{src_dims}, DnnnType<T>(), ort_source_format_});
if (mklnode_ptr_->parent_nodes.empty())
src_mem_from_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_from_ = std::make_unique<dnnl::memory>(
dnnl::memory(pd, cpu_engine, nullptr));
else
src_mem_from_ = parents_[0].get()->primitive_dst_mem_;
src_mem_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_->src_desc(), cpu_engine, nullptr));
net.push_back(dnnl::reorder(*src_mem_from_, *src_mem_));
net_args.push_back({{DNNL_ARG_FROM, *src_mem_from_},
{DNNL_ARG_TO, *src_mem_}});
} else {
if (mklnode_ptr_->parent_nodes.empty()) {
src_mem_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_->src_desc(), cpu_engine, nullptr));
} else {
src_mem_ = parents_[0].get()->primitive_dst_mem_;
@ -347,21 +347,21 @@ class DnnlConv : public DnnlKernel {
auto pd = dnnl::memory::desc({{src_dims}, DnnnType<T>(), ort_source_format_});
if (mklnode_ptr_->parent_nodes.empty()) {
src_mem_from_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_from_ = std::make_unique<dnnl::memory>(
dnnl::memory(pd, cpu_engine, nullptr));
} else {
src_mem_from_ = parents_[0].get()->primitive_dst_mem_;
}
src_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_gpu_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_->src_desc(), gpu_engine));
net.push_back(dnnl::reorder(*src_mem_from_, *src_mem_gpu_));
net_args.push_back({{DNNL_ARG_FROM, *src_mem_from_},
{DNNL_ARG_TO, *src_mem_gpu_}});
} else {
if (mklnode_ptr_->parent_nodes.empty()) {
src_mem_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_->src_desc(), cpu_engine, nullptr));
src_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_gpu_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_->src_desc(), gpu_engine));
net.push_back(dnnl::reorder(*src_mem_, *src_mem_gpu_));
net_args.push_back({{DNNL_ARG_SRC, *src_mem_},
@ -376,26 +376,26 @@ class DnnlConv : public DnnlKernel {
if (mklnode_ptr_->output_index >= 0) {
// Use Dnnl's internal output buffer
if (primitive_dst_desc_ != ort_source_desc_) {
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_.get()->dst_desc(), cpu_engine));
} else {
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_.get()->dst_desc(), cpu_engine, nullptr));
}
} else {
// last node of sub-graph. need to allocate memory for output_tensor
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_.get()->dst_desc(), cpu_engine));
}
} else { // gpu_available_
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_.get()->dst_desc(), gpu_engine));
}
if (!bias_dims_mkl.empty()) {
bias_mem_ = onnxruntime::make_unique<dnnl::memory>(
bias_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_.get()->bias_desc(), cpu_engine, nullptr));
conv_fwd_ = onnxruntime::make_unique<dnnl::convolution_forward>(
conv_fwd_ = std::make_unique<dnnl::convolution_forward>(
dnnl::convolution_forward(*conv_fwd_pd_));
if (!gpu_available_) {
net.push_back(*conv_fwd_);
@ -404,7 +404,7 @@ class DnnlConv : public DnnlKernel {
{DNNL_ARG_BIAS, *bias_mem_},
{DNNL_ARG_DST, *primitive_dst_mem_}});
} else { // gpu_available_
bias_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(
bias_mem_gpu_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_.get()->bias_desc(), gpu_engine));
net.push_back(dnnl::reorder(*bias_mem_, *bias_mem_gpu_));
net_args.push_back({{DNNL_ARG_SRC, *bias_mem_},
@ -416,7 +416,7 @@ class DnnlConv : public DnnlKernel {
{DNNL_ARG_DST, *primitive_dst_mem_}});
}
} else {
conv_fwd_ = onnxruntime::make_unique<dnnl::convolution_forward>(
conv_fwd_ = std::make_unique<dnnl::convolution_forward>(
dnnl::convolution_forward(*conv_fwd_pd_));
if (!gpu_available_) {
net.push_back(*conv_fwd_);
@ -473,7 +473,7 @@ class DnnlConv : public DnnlKernel {
dnnl::memory src = dnnl::memory({{filter_dims_mkl}, DnnnType<T>(), filter_format_}, cpu_engine, (void*)filter_data);
IAllocatorUniquePtr<void> filter_reorder_buffer = IAllocator::MakeUniquePtr<void>(alloc_, filter_size_);
if (!gpu_available_) {
filter_dst_mem = onnxruntime::make_unique<dnnl::memory>(
filter_dst_mem = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_->weights_desc(), cpu_engine, filter_reorder_buffer.get()));
dnnl::reorder(src, *filter_dst_mem)
@ -482,7 +482,7 @@ class DnnlConv : public DnnlKernel {
provider_->SaveAllocatedMemory(std::move(filter_reorder_buffer));
filter_data = static_cast<T*>(filter_dst_mem->get_data_handle());
} else { // gpu_available_
filter_dst_mem = onnxruntime::make_unique<dnnl::memory>(
filter_dst_mem = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_->weights_desc(), dnnl_engine_gpu_));
dnnl::reorder(src, *filter_dst_mem)

View file

@ -45,7 +45,7 @@ class DnnlConvBatchNorm : public DnnlKernel {
LOGS_DEFAULT(INFO) << "gpu engine found" << std::endl;
}
Ort::CustomOpApi ort{*api};
stream_ = onnxruntime::make_unique<dnnl::stream>(dnnl::stream(cpu_engine));
stream_ = std::make_unique<dnnl::stream>(dnnl::stream(cpu_engine));
int input_index = mklnode_ptr_->input_start_index < 0 ? 0 : mklnode_ptr_->input_start_index;
const OrtValue* winput_tensor = ort.KernelContext_GetInput(context, input_index + 1);
auto wtensor_info = ort.GetTensorTypeAndShape(winput_tensor);
@ -133,7 +133,7 @@ class DnnlConvBatchNorm : public DnnlKernel {
primitive_dst_shape_ = TensorShape(y_dims);
TensorShape output_shape = y_shape.Slice(2);
dnnl::memory::dims dst_dims_mkl(y_dims.begin(), y_dims.end());
primitive_dst_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
primitive_dst_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({dst_dims_mkl}, DnnnType<T>(), dnnl::memory::format_tag::any));
dnnl::memory::dims filter_dims_mkl;
@ -207,19 +207,19 @@ class DnnlConvBatchNorm : public DnnlKernel {
source_desc_ = dnnl::memory::desc({src_dims_mkl}, DnnnType<T>(), src_format);
}
src_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
src_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({src_dims_mkl}, DnnnType<T>(), dnnl::memory::format_tag::any));
// Set the memory descriptors to format::any to allow DNNL to decide what the optimal memory layout should be
// for the computation given the input
filter_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
filter_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({filter_dims_mkl}, DnnnType<T>(), dnnl::memory::format_tag::any));
bias_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
bias_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({bias_dims_mkl}, DnnnType<T>(), dnnl::memory::format_tag::any));
dnnl::memory::dims conv_zero_padding = {0, 0};
fwd_desc_ = onnxruntime::make_unique<dnnl::convolution_forward::desc>(
fwd_desc_ = std::make_unique<dnnl::convolution_forward::desc>(
dnnl::convolution_forward::desc(
dnnl::prop_kind::forward_inference, dnnl::algorithm::convolution_direct, *src_md_,
*filter_md_, *bias_md_, *primitive_dst_md_,
@ -237,10 +237,10 @@ class DnnlConvBatchNorm : public DnnlKernel {
ops.append_eltwise(ops_scale, dnnl::algorithm::eltwise_relu, ops_alpha, ops_beta);
attr.set_post_ops(ops);
conv_fwd_pd_ = onnxruntime::make_unique<dnnl::convolution_forward::primitive_desc>(
conv_fwd_pd_ = std::make_unique<dnnl::convolution_forward::primitive_desc>(
dnnl::convolution_forward::primitive_desc(*fwd_desc_, attr, engine_to_use));
} else {
conv_fwd_pd_ = onnxruntime::make_unique<dnnl::convolution_forward::primitive_desc>(
conv_fwd_pd_ = std::make_unique<dnnl::convolution_forward::primitive_desc>(
dnnl::convolution_forward::primitive_desc(*fwd_desc_, engine_to_use));
}
@ -257,10 +257,10 @@ class DnnlConvBatchNorm : public DnnlKernel {
filter_size_ = conv_fwd_pd_.get()->weights_desc().get_size();
dst_size_ = conv_fwd_pd_.get()->dst_desc().get_size();
filter_mem_ = onnxruntime::make_unique<dnnl::memory>(
filter_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_.get()->weights_desc(), cpu_engine, nullptr));
if (gpu_available_) {
filter_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(
filter_mem_gpu_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_.get()->weights_desc(), gpu_engine));
}
@ -270,19 +270,19 @@ class DnnlConvBatchNorm : public DnnlKernel {
auto pd = dnnl::memory::desc({{src_dims}, DnnnType<T>(), ort_source_format_});
if (mklnode_ptr_->parent_nodes.empty())
src_mem_from_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_from_ = std::make_unique<dnnl::memory>(
dnnl::memory(pd, cpu_engine, nullptr));
else
src_mem_from_ = parents_[0].get()->primitive_dst_mem_;
src_mem_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_->src_desc(), cpu_engine, nullptr));
net.push_back(dnnl::reorder(*src_mem_from_, *src_mem_));
net_args.push_back({{DNNL_ARG_FROM, *src_mem_from_},
{DNNL_ARG_TO, *src_mem_}});
} else {
if (mklnode_ptr_->parent_nodes.empty()) {
src_mem_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_->src_desc(), cpu_engine, nullptr));
} else {
src_mem_ = parents_[0].get()->primitive_dst_mem_;
@ -294,21 +294,21 @@ class DnnlConvBatchNorm : public DnnlKernel {
auto pd = dnnl::memory::desc({{src_dims}, DnnnType<T>(), ort_source_format_});
if (mklnode_ptr_->parent_nodes.empty()) {
src_mem_from_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_from_ = std::make_unique<dnnl::memory>(
dnnl::memory(pd, cpu_engine, nullptr));
} else {
src_mem_from_ = parents_[0].get()->primitive_dst_mem_;
}
src_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_gpu_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_->src_desc(), gpu_engine));
net.push_back(dnnl::reorder(*src_mem_from_, *src_mem_gpu_));
net_args.push_back({{DNNL_ARG_FROM, *src_mem_from_},
{DNNL_ARG_TO, *src_mem_gpu_}});
} else {
if (mklnode_ptr_->parent_nodes.empty()) {
src_mem_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_->src_desc(), cpu_engine, nullptr));
src_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_gpu_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_->src_desc(), gpu_engine));
net.push_back(dnnl::reorder(*src_mem_, *src_mem_gpu_));
net_args.push_back({{DNNL_ARG_SRC, *src_mem_},
@ -323,25 +323,25 @@ class DnnlConvBatchNorm : public DnnlKernel {
if (mklnode_ptr_->output_index >= 0) {
// Use Dnnl's internal output buffer
if (primitive_dst_desc_ != ort_source_desc_) {
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_.get()->dst_desc(), cpu_engine));
} else {
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_.get()->dst_desc(), cpu_engine, nullptr));
}
} else {
// last node of sub-graph. need to allocate memory for output_tensor
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_.get()->dst_desc(), cpu_engine));
}
} else { // gpu_available_
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_.get()->dst_desc(), gpu_engine));
}
bias_mem_ = onnxruntime::make_unique<dnnl::memory>(
bias_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_.get()->bias_desc(), cpu_engine, nullptr));
conv_fwd_ = onnxruntime::make_unique<dnnl::convolution_forward>(
conv_fwd_ = std::make_unique<dnnl::convolution_forward>(
dnnl::convolution_forward(*conv_fwd_pd_));
if (!gpu_available_) {
net.push_back(*conv_fwd_);
@ -350,7 +350,7 @@ class DnnlConvBatchNorm : public DnnlKernel {
{DNNL_ARG_BIAS, *bias_mem_},
{DNNL_ARG_DST, *primitive_dst_mem_}});
} else { // gpu_available_
bias_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(
bias_mem_gpu_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_.get()->bias_desc(), gpu_engine));
net.push_back(dnnl::reorder(*bias_mem_, *bias_mem_gpu_));
net_args.push_back({{DNNL_ARG_SRC, *bias_mem_},
@ -468,7 +468,7 @@ class DnnlConvBatchNorm : public DnnlKernel {
dnnl::memory src = dnnl::memory({{filter_dims_mkl}, DnnnType<T>(), filter_format_}, cpu_engine, (void*)weights_scaled_by_axis.data());
IAllocatorUniquePtr<void> filter_reorder_buffer = IAllocator::MakeUniquePtr<void>(alloc_, filter_size_);
if (!gpu_available_) {
filter_dst_mem = onnxruntime::make_unique<dnnl::memory>(
filter_dst_mem = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_->weights_desc(), cpu_engine, filter_reorder_buffer.get()));
dnnl::reorder(src, *filter_dst_mem)
@ -476,7 +476,7 @@ class DnnlConvBatchNorm : public DnnlKernel {
provider_->SaveAllocatedMemory(std::move(filter_reorder_buffer));
} else { // gpu_available_
filter_dst_mem = onnxruntime::make_unique<dnnl::memory>(
filter_dst_mem = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_->weights_desc(), dnnl_engine_gpu_));
dnnl::reorder(src, *filter_dst_mem)
@ -490,7 +490,7 @@ class DnnlConvBatchNorm : public DnnlKernel {
if (bias_mem == nullptr) {
auto bias_size = conv_fwd_pd_.get()->bias_desc().get_size();
IAllocatorUniquePtr<void> bias_buffer = IAllocator::MakeUniquePtr<void>(alloc_, bias_size);
bias_mem = onnxruntime::make_unique<dnnl::memory>(
bias_mem = std::make_unique<dnnl::memory>(
dnnl::memory(conv_fwd_pd_->bias_desc(), cpu_engine, bias_buffer.get()));
float* bias_buffer_data = static_cast<float*>(bias_buffer.get());
if (mklnode_ptr_->num_inputs == 7) {

View file

@ -82,7 +82,7 @@ class DnnlConvGrad : public DnnlKernel {
LOGS_DEFAULT(INFO) << "gpu engine found" << std::endl;
}
Ort::CustomOpApi ort{*api};
stream_ = onnxruntime::make_unique<dnnl::stream>(dnnl::stream(engine_to_use));
stream_ = std::make_unique<dnnl::stream>(dnnl::stream(engine_to_use));
int input_index = mklnode_ptr_->input_start_index < 0 ? 0 : mklnode_ptr_->input_start_index;
@ -178,15 +178,15 @@ class DnnlConvGrad : public DnnlKernel {
// Setup input and output memory descriptions
dnnl::memory::dims dy_dims(dy_shape.GetDims().begin(), dy_shape.GetDims().end());
diff_dst_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
diff_dst_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({dy_dims}, DnnnType<T>(), ort_source_format_));
dnnl::memory::dims x_dims(x_shape.GetDims().begin(), x_shape.GetDims().end());
src_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
src_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({x_dims}, DnnnType<T>(), ort_source_format_));
dnnl::memory::dims w_dims(w_shape.GetDims().begin(), w_shape.GetDims().end());
weights_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
weights_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({w_dims}, DnnnType<T>(), ort_source_format_));
// Verify that the inputs to the ConvGrad operator match the passed in forward Conv operator
@ -213,22 +213,22 @@ class DnnlConvGrad : public DnnlKernel {
// src and diff_src have the same memory dimensions
TensorShape dx_shape(x_dims);
//diff_src_shape_ = dx_shape;
//diff_src_md_ = onnxruntime::make_unique < dnnl::memory::desc > (
//diff_src_md_ = std::make_unique < dnnl::memory::desc > (
// dnnl::memory::desc({x_dims}, DnnnType<T>(), dnnl::memory::format_tag::any));
primitive_dst_shape_ = dx_shape;
primitive_dst_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
primitive_dst_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({x_dims}, DnnnType<T>(), ort_source_format_));
// weights and diff_weights have the same memory descriptions
TensorShape dw_shape(w_dims);
diff_weights_shape_ = dw_shape;
diff_weights_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
diff_weights_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({w_dims}, DnnnType<T>(), ort_source_format_));
TensorShape db_shape({wshape[0]});
diff_bias_shape_ = db_shape;
diff_bias_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
diff_bias_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({wshape[0]}, DnnnType<T>(), dnnl::memory::format_tag::x));
dnnl::memory::dims filter_dims_mkl;
@ -280,7 +280,7 @@ class DnnlConvGrad : public DnnlKernel {
source_desc_ = dnnl::memory::desc({src_dims_mkl}, DnnnType<T>(), src_format);
}
conv_bwd_data_desc_ = onnxruntime::make_unique<dnnl::convolution_backward_data::desc>(
conv_bwd_data_desc_ = std::make_unique<dnnl::convolution_backward_data::desc>(
dnnl::convolution_backward_data::desc(
dnnl::algorithm::convolution_direct,
*primitive_dst_md_,
@ -291,11 +291,11 @@ class DnnlConvGrad : public DnnlKernel {
conv_padding_left,
conv_padding_right));
conv_bwd_data_pd_ = onnxruntime::make_unique<dnnl::convolution_backward_data::primitive_desc>(
conv_bwd_data_pd_ = std::make_unique<dnnl::convolution_backward_data::primitive_desc>(
dnnl::convolution_backward_data::primitive_desc(
*conv_bwd_data_desc_, engine_to_use, *(conv_fwd_->GetPrimitiveDesc())));
conv_bwd_weights_desc_ = onnxruntime::make_unique<dnnl::convolution_backward_weights::desc>(
conv_bwd_weights_desc_ = std::make_unique<dnnl::convolution_backward_weights::desc>(
dnnl::convolution_backward_weights::desc(
dnnl::algorithm::convolution_direct,
*src_md_,
@ -307,30 +307,30 @@ class DnnlConvGrad : public DnnlKernel {
conv_padding_left,
conv_padding_right));
conv_bwd_weights_pd_ = onnxruntime::make_unique<dnnl::convolution_backward_weights::primitive_desc>(
conv_bwd_weights_pd_ = std::make_unique<dnnl::convolution_backward_weights::primitive_desc>(
dnnl::convolution_backward_weights::primitive_desc(
*conv_bwd_weights_desc_, engine_to_use, *(conv_fwd_->GetPrimitiveDesc())));
diff_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
diff_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_bwd_weights_pd_.get()->diff_dst_desc(), cpu_engine, nullptr));
src_mem_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_bwd_weights_pd_.get()->src_desc(), cpu_engine, nullptr));
weights_mem_ = onnxruntime::make_unique<dnnl::memory>(
weights_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_bwd_data_pd_.get()->weights_desc(), cpu_engine, nullptr));
//diff_src_mem_ = onnxruntime::make_unique<dnnl::memory>(
//diff_src_mem_ = std::make_unique<dnnl::memory>(
// dnnl::memory(conv_bwd_data_pd_.get()->diff_src_desc(), cpu_engine, nullptr));
if (gpu_available_) {
diff_dst_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(*diff_dst_md_, gpu_engine);
diff_dst_mem_gpu_ = std::make_unique<dnnl::memory>(*diff_dst_md_, gpu_engine);
net.push_back(mkldnn::reorder(*diff_dst_mem_, *diff_dst_mem_gpu_));
net_args.push_back({{MKLDNN_ARG_SRC, *diff_dst_mem_}, {MKLDNN_ARG_DST, *diff_dst_mem_gpu_}});
src_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(*src_md_, gpu_engine);
src_mem_gpu_ = std::make_unique<dnnl::memory>(*src_md_, gpu_engine);
net.push_back(mkldnn::reorder(*src_mem_, *src_mem_gpu_));
net_args.push_back({{MKLDNN_ARG_SRC, *src_mem_}, {MKLDNN_ARG_DST, *src_mem_gpu_}});
weights_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(*weights_md_, gpu_engine);
weights_mem_gpu_ = std::make_unique<dnnl::memory>(*weights_md_, gpu_engine);
net.push_back(mkldnn::reorder(*weights_mem_, *weights_mem_gpu_));
net_args.push_back({{MKLDNN_ARG_SRC, *weights_mem_}, {MKLDNN_ARG_DST, *weights_mem_gpu_}});
}
@ -342,26 +342,26 @@ class DnnlConvGrad : public DnnlKernel {
if (mklnode_ptr_->output_index >= 0) {
// Use Dnnl's internal output buffer
if (primitive_dst_desc_ != ort_source_desc_) {
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_bwd_data_pd_.get()->diff_src_desc(), cpu_engine));
} else {
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_bwd_data_pd_.get()->diff_src_desc(), cpu_engine, nullptr));
}
} else {
// last node of sub-graph. need to allocate memory for output_tensor
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_bwd_data_pd_.get()->diff_src_desc(), cpu_engine));
}
} else {
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_bwd_data_pd_.get()->diff_src_desc(), gpu_engine));
}
diff_weights_mem_ = onnxruntime::make_unique<dnnl::memory>(
diff_weights_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_bwd_weights_pd_.get()->diff_weights_desc(), engine_to_use));
diff_bias_mem_ = onnxruntime::make_unique<dnnl::memory>(
diff_bias_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(conv_bwd_weights_pd_.get()->diff_bias_desc(), engine_to_use));
net.push_back(dnnl::convolution_backward_data(*conv_bwd_data_pd_));
@ -394,12 +394,12 @@ class DnnlConvGrad : public DnnlKernel {
// Allocate dst buffer if reorder is necessary
if (gpu_available_) {
// reorder to ONNXRuntime format
diff_weights_reorder_mem_to_ = onnxruntime::make_unique<dnnl::memory>(dnnl::memory(*diff_weights_md_, cpu_engine));
diff_weights_reorder_mem_to_ = std::make_unique<dnnl::memory>(dnnl::memory(*diff_weights_md_, cpu_engine));
net.push_back(dnnl::reorder(*diff_weights_mem_, *diff_weights_reorder_mem_to_));
net_args.push_back({{DNNL_ARG_FROM, *diff_weights_mem_},
{DNNL_ARG_TO, *diff_weights_reorder_mem_to_}});
diff_bias_reorder_mem_to_ = onnxruntime::make_unique<dnnl::memory>(dnnl::memory(*diff_bias_md_, cpu_engine));
diff_bias_reorder_mem_to_ = std::make_unique<dnnl::memory>(dnnl::memory(*diff_bias_md_, cpu_engine));
net.push_back(dnnl::reorder(*diff_bias_mem_, *diff_bias_reorder_mem_to_));
net_args.push_back({{DNNL_ARG_FROM, *diff_bias_mem_},
{DNNL_ARG_TO, *diff_bias_reorder_mem_to_}});

View file

@ -36,9 +36,9 @@ class SubgraphPrimitive : public PrimitiveBase {
dnnl_engine_instance_ = DnnlEngineInstance::getInstance();
std::unordered_map<dnnl::engine::kind, dnnl::engine>::const_iterator iter = dnnl_engine_instance_->getEngineMap().find(dnnl::engine::kind::gpu);
if (iter != dnnl_engine_instance_->getEngineMap().end()) {
context_.stream = onnxruntime::make_unique<dnnl::stream>(dnnl::stream(dnnl_engine_instance_->getEngine(dnnl::engine::kind::gpu)));
context_.stream = std::make_unique<dnnl::stream>(dnnl::stream(dnnl_engine_instance_->getEngine(dnnl::engine::kind::gpu)));
} else {
context_.stream = onnxruntime::make_unique<dnnl::stream>(dnnl::stream(dnnl_engine_instance_->getEngine(dnnl::engine::kind::cpu)));
context_.stream = std::make_unique<dnnl::stream>(dnnl::stream(dnnl_engine_instance_->getEngine(dnnl::engine::kind::cpu)));
}
if (context_.net.size() == 0) {
@ -318,7 +318,7 @@ class SubgraphPrimitivePool : public PrimitivePool<T> {
SubgraphPrimitivePool<T>::GetInstance().GetPrimitive(params.subgraph_key + dims_str));
if (primitive == nullptr) {
auto subgraph_primitive = onnxruntime::make_unique<SubgraphPrimitive<T>>(api, context, params);
auto subgraph_primitive = std::make_unique<SubgraphPrimitive<T>>(api, context, params);
primitive = subgraph_primitive.get();
SubgraphPrimitivePool<T>::GetInstance().SetPrimitive(params.subgraph_key + dims_str, std::move(subgraph_primitive));
}
@ -348,7 +348,7 @@ Status DnnlFuncKernel<T>::Compute(const OrtCustomOpApi* api, OrtKernelContext* c
// training. (If the training running is updated to use a thread pool instead of a new thread each run we may be able to
// revert back to the SubgraphPrimitivePool.)
#ifdef ENABLE_TRAINING
std::unique_ptr<SubgraphPrimitive<T>> primitive = onnxruntime::make_unique<SubgraphPrimitive<T>>(api, context, params_);
std::unique_ptr<SubgraphPrimitive<T>> primitive = std::make_unique<SubgraphPrimitive<T>>(api, context, params_);
#else
SubgraphPrimitive<T>* primitive = SubgraphPrimitivePool<T>::Get(api, context, params_);
#endif // ENABLE_TRAINING

View file

@ -19,7 +19,7 @@ void DnnlKernel::InitDstReorderOutput(dnnl::engine& cpu_engine,
primitive_dst_shape_.GetDims().begin(), primitive_dst_shape_.GetDims().end());
dnnl::memory::desc dst_des = dnnl::memory::desc(dst_dims_mkl,
data_type, ort_source_format_);
reorder_dst_mem_to_ = onnxruntime::make_unique<dnnl::memory>(
reorder_dst_mem_to_ = std::make_unique<dnnl::memory>(
dnnl::memory(dst_des, cpu_engine));
net.push_back(dnnl::reorder(*primitive_dst_mem_, *reorder_dst_mem_to_));
net_args.push_back({{DNNL_ARG_FROM, *primitive_dst_mem_},

View file

@ -60,18 +60,18 @@ class DnnlLrn : public DnnlKernel {
ort_source_desc_ = dnnl::memory::desc(
{src_dims}, DnnnType<T>(), ort_source_format_);
src_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
src_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({src_dims}, DnnnType<T>(), ort_source_format_));
src_mem_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(*src_md_, cpu_engine, nullptr));
if (gpu_available_) {
src_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(*src_md_, gpu_engine);
src_mem_gpu_ = std::make_unique<dnnl::memory>(*src_md_, gpu_engine);
net.push_back(mkldnn::reorder(*src_mem_, *src_mem_gpu_));
net_args.push_back({{MKLDNN_ARG_SRC, *src_mem_},
{MKLDNN_ARG_DST, *src_mem_gpu_}});
}
} else {
src_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
src_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc(parents_[0].get()->primitive_dst_desc_));
if (!gpu_available_) {
src_mem_ = parents_[0].get()->primitive_dst_mem_;
@ -87,11 +87,11 @@ class DnnlLrn : public DnnlKernel {
primitive_dst_shape_ = TensorShape(x_shape);
dnnl::algorithm algo = dnnl::algorithm::lrn_across_channels;
fwd_desc_ = onnxruntime::make_unique<dnnl::lrn_forward::desc>(
fwd_desc_ = std::make_unique<dnnl::lrn_forward::desc>(
dnnl::lrn_forward::desc(dnnl::prop_kind::forward_scoring, algo, *src_md_,
size_, alpha_, beta_, bias_));
fwd_primitive_desc_ = onnxruntime::make_unique<dnnl::lrn_forward::primitive_desc>(
fwd_primitive_desc_ = std::make_unique<dnnl::lrn_forward::primitive_desc>(
dnnl::lrn_forward::primitive_desc(*fwd_desc_, engine_to_use));
primitive_src_desc_ = fwd_primitive_desc_.get()->src_desc();
@ -103,25 +103,25 @@ class DnnlLrn : public DnnlKernel {
if (primitive_dst_desc_ != ort_source_desc_) {
// reorder neded. Use primitive output as input to reorder and
// allocate buffer for reorder output, final output of this subgraph
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(fwd_primitive_desc_.get()->dst_desc(), cpu_engine));
} else {
// Last node but re-order not needed. Allocate buffer to output of this node
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(fwd_primitive_desc_.get()->dst_desc(), cpu_engine, nullptr));
}
} else {
// Intermediate node. Use Dnnl kernel internal memory for output and
// use this as input to next node.
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(fwd_primitive_desc_.get()->dst_desc(), cpu_engine));
}
} else { // gpu_available_
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(fwd_primitive_desc_.get()->dst_desc(), gpu_engine));
}
lrn_fwd_ = onnxruntime::make_unique<dnnl::lrn_forward>(
lrn_fwd_ = std::make_unique<dnnl::lrn_forward>(
dnnl::lrn_forward(*fwd_primitive_desc_));
if (!gpu_available_) {
net.push_back(*lrn_fwd_);

View file

@ -82,18 +82,18 @@ class DnnlMatmul : public DnnlKernel {
InferOutputShape(x_shape, w_shape, y_dims);
primitive_dst_shape_ = TensorShape(y_dims);
std::unique_ptr<dnnl::memory::desc> src_md = onnxruntime::make_unique<dnnl::memory::desc>(
std::unique_ptr<dnnl::memory::desc> src_md = std::make_unique<dnnl::memory::desc>(
dnnl::memory::dims(x_shape.GetDims().begin(), x_shape.GetDims().end()), DnnnType<T>(), dnnl::memory::format_tag::any);
std::unique_ptr<dnnl::memory::desc> weights_md = onnxruntime::make_unique<dnnl::memory::desc>(
std::unique_ptr<dnnl::memory::desc> weights_md = std::make_unique<dnnl::memory::desc>(
dnnl::memory::dims(w_shape.GetDims().begin(), w_shape.GetDims().end()), DnnnType<T>(), dnnl::memory::format_tag::any);
primitive_dst_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
primitive_dst_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::dims(y_dims.begin(), y_dims.end()), DnnnType<T>(), dnnl::memory::format_tag::any);
std::unique_ptr<dnnl::matmul::desc> matmul_desc = onnxruntime::make_unique<dnnl::matmul::desc>(*src_md, *weights_md, *primitive_dst_md_);
matmul_pd_ = onnxruntime::make_unique<dnnl::matmul::primitive_desc>(*matmul_desc, engine_to_use);
matmul_ = onnxruntime::make_unique<dnnl::matmul>(dnnl::matmul(*matmul_pd_));
std::unique_ptr<dnnl::matmul::desc> matmul_desc = std::make_unique<dnnl::matmul::desc>(*src_md, *weights_md, *primitive_dst_md_);
matmul_pd_ = std::make_unique<dnnl::matmul::primitive_desc>(*matmul_desc, engine_to_use);
matmul_ = std::make_unique<dnnl::matmul>(dnnl::matmul(*matmul_pd_));
primitive_src_desc_ = static_cast<dnnl::memory::desc>(matmul_pd_.get()->src_desc());
primitive_dst_desc_ = static_cast<dnnl::memory::desc>(matmul_pd_.get()->dst_desc());
@ -101,10 +101,10 @@ class DnnlMatmul : public DnnlKernel {
weights_size_ = matmul_pd_.get()->weights_desc().get_size();
dst_size_ = matmul_pd_.get()->dst_desc().get_size();
weights_mem_ = onnxruntime::make_unique<dnnl::memory>(
weights_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(matmul_pd_.get()->weights_desc(), cpu_engine, nullptr));
if (gpu_available_) {
weights_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(
weights_mem_gpu_ = std::make_unique<dnnl::memory>(
dnnl::memory(matmul_pd_.get()->weights_desc(), gpu_engine, nullptr));
}
@ -113,20 +113,20 @@ class DnnlMatmul : public DnnlKernel {
if (mklnode_ptr_->parent_nodes.empty()) {
dnnl::memory::dims src_dims(x_shape.GetDims().begin(), x_shape.GetDims().end());
auto pd = dnnl::memory::desc({{src_dims}, DnnnType<T>(), ort_source_format_});
src_mem_from_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_from_ = std::make_unique<dnnl::memory>(
dnnl::memory(pd, cpu_engine, nullptr));
}
else
src_mem_from_ = parents_[0].get()->primitive_dst_mem_;
src_mem_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(matmul_pd_->src_desc(), cpu_engine, nullptr));
net.push_back(dnnl::reorder(*src_mem_from_, *src_mem_));
net_args.push_back({{DNNL_ARG_FROM, *src_mem_from_},
{DNNL_ARG_TO, *src_mem_}});
} else {
if (mklnode_ptr_->parent_nodes.empty()) {
src_mem_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(matmul_pd_->src_desc(), cpu_engine, nullptr));
} else {
src_mem_ = parents_[0].get()->primitive_dst_mem_;
@ -135,10 +135,10 @@ class DnnlMatmul : public DnnlKernel {
if (mklnode_ptr_->output_index >= 0) {
if (primitive_dst_desc_ != ort_source_desc_) {
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(matmul_pd_.get()->dst_desc(), cpu_engine));
} else {
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(matmul_pd_.get()->dst_desc(), cpu_engine, nullptr));
}
}
@ -147,21 +147,21 @@ class DnnlMatmul : public DnnlKernel {
if (mklnode_ptr_->parent_nodes.empty()) {
dnnl::memory::dims src_dims(x_shape.GetDims().begin(), x_shape.GetDims().end());
auto pd = dnnl::memory::desc({{src_dims}, DnnnType<T>(), ort_source_format_});
src_mem_from_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_from_ = std::make_unique<dnnl::memory>(
dnnl::memory(pd, cpu_engine, nullptr));
} else {
src_mem_from_ = parents_[0].get()->primitive_dst_mem_;
}
src_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_gpu_ = std::make_unique<dnnl::memory>(
dnnl::memory(matmul_pd_->src_desc(), gpu_engine));
net.push_back(dnnl::reorder(*src_mem_from_, *src_mem_gpu_));
net_args.push_back({{DNNL_ARG_FROM, *src_mem_from_},
{DNNL_ARG_TO, *src_mem_gpu_}});
} else {
if (mklnode_ptr_->parent_nodes.empty()) {
src_mem_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(matmul_pd_->src_desc(), cpu_engine, nullptr));
src_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_gpu_ = std::make_unique<dnnl::memory>(
dnnl::memory(matmul_pd_->src_desc(), gpu_engine));
net.push_back(dnnl::reorder(*src_mem_, *src_mem_gpu_));
net_args.push_back({{DNNL_ARG_SRC, *src_mem_},
@ -171,7 +171,7 @@ class DnnlMatmul : public DnnlKernel {
}
}
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(matmul_pd_.get()->dst_desc(), gpu_engine));
}
@ -215,7 +215,7 @@ class DnnlMatmul : public DnnlKernel {
dnnl::memory src = dnnl::memory({{weights_dims_dnnl}, DnnnType<T>(), weights_format_}, cpu_engine, (void*)weights_data);
IAllocatorUniquePtr<void> weights_reorder_buffer = IAllocator::MakeUniquePtr<void>(alloc_, weights_size_);
if (!gpu_available_) {
weights_dst_mem = onnxruntime::make_unique<dnnl::memory>(
weights_dst_mem = std::make_unique<dnnl::memory>(
dnnl::memory(matmul_pd_->weights_desc(), cpu_engine, weights_reorder_buffer.get()));
dnnl::reorder(src, *weights_dst_mem)
@ -224,7 +224,7 @@ class DnnlMatmul : public DnnlKernel {
provider_->SaveAllocatedMemory(std::move(weights_reorder_buffer));
weights_data = static_cast<T*>(weights_dst_mem->get_data_handle());
} else { // gpu_available_
weights_dst_mem = onnxruntime::make_unique<dnnl::memory>(
weights_dst_mem = std::make_unique<dnnl::memory>(
dnnl::memory(matmul_pd_->weights_desc(), dnnl_engine_gpu_));
dnnl::reorder(src, *weights_dst_mem)

View file

@ -96,7 +96,7 @@ class DnnlMaxPoolGrad : public DnnlKernel {
// reorder for better performance
dnnl::memory::format_tag diff_dst_format = GetAVXFormat(xgrad_src_dims_mkl);
diff_dst_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
diff_dst_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({xgrad_src_dims_mkl}, DnnnType<T>(), diff_dst_format));
} else {
// get the output of previous node (Dnnl block propagation).
@ -132,7 +132,7 @@ class DnnlMaxPoolGrad : public DnnlKernel {
dnnl::memory::dims padding_left_mkl(pads_.begin(), pads_.begin() + (pads_.size() / 2));
dnnl::memory::dims padding_right_mkl(pads_.begin() + (pads_.size() / 2), pads_.end());
primitive_dst_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
primitive_dst_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({dst_dims_mkl}, DnnnType<T>(), dnnl::memory::format_tag::any));
dnnl::algorithm algo = dnnl::algorithm::pooling_max;
@ -144,12 +144,12 @@ class DnnlMaxPoolGrad : public DnnlKernel {
}
}*/
bwd_desc_ = onnxruntime::make_unique<dnnl::pooling_backward::desc>(
bwd_desc_ = std::make_unique<dnnl::pooling_backward::desc>(
dnnl::pooling_backward::desc(algo, *primitive_dst_md_, *diff_dst_md_,
strides_mkl, kernel_mkl,
padding_left_mkl, padding_right_mkl));
auto pool_fwd_pd = pool_fwd_->GetPrimitiveDesc();
bwd_primitive_desc_ = onnxruntime::make_unique<dnnl::pooling_backward::primitive_desc>(
bwd_primitive_desc_ = std::make_unique<dnnl::pooling_backward::primitive_desc>(
dnnl::pooling_backward::primitive_desc(*bwd_desc_, engine_to_use, *pool_fwd_pd));
primitive_src_desc_ = bwd_primitive_desc_.get()->diff_src_desc();
@ -161,19 +161,19 @@ class DnnlMaxPoolGrad : public DnnlKernel {
dnnl::memory::desc pd(source_desc_);
if (mklnode_ptr_->parent_nodes.empty())
diff_dst_mem_from_ = onnxruntime::make_unique<dnnl::memory>(
diff_dst_mem_from_ = std::make_unique<dnnl::memory>(
dnnl::memory(pd, cpu_engine, DNNL_MEMORY_NONE));
else
diff_dst_mem_from_ = parents_[0].get()->primitive_dst_mem_;
diff_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
diff_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(bwd_primitive_desc_->diff_dst_desc(), cpu_engine, DNNL_MEMORY_NONE));
net.push_back(dnnl::reorder(*diff_dst_mem_from_, *diff_dst_mem_));
net_args.push_back({{DNNL_ARG_FROM, *diff_dst_mem_from_},
{DNNL_ARG_TO, *diff_dst_mem_}});
} else {
if (mklnode_ptr_->parent_nodes.empty()) {
diff_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
diff_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(bwd_primitive_desc_->diff_dst_desc(), cpu_engine, DNNL_MEMORY_NONE));
} else {
diff_dst_mem_ = parents_[0].get()->primitive_dst_mem_;
@ -185,12 +185,12 @@ class DnnlMaxPoolGrad : public DnnlKernel {
dnnl::memory::desc pd(source_desc_);
if (mklnode_ptr_->parent_nodes.empty())
diff_dst_mem_from_ = onnxruntime::make_unique<dnnl::memory>(
diff_dst_mem_from_ = std::make_unique<dnnl::memory>(
dnnl::memory(pd, cpu_engine, DNNL_MEMORY_NONE));
else
diff_dst_mem_from_ = parents_[0].get()->primitive_dst_mem_;
diff_dst_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(
diff_dst_mem_gpu_ = std::make_unique<dnnl::memory>(
dnnl::memory(bwd_primitive_desc_->diff_dst_desc(), gpu_engine));
net.push_back(dnnl::reorder(*diff_dst_mem_from_, *diff_dst_mem_gpu_));
net_args.push_back({{DNNL_ARG_FROM, *diff_dst_mem_from_},
@ -198,9 +198,9 @@ class DnnlMaxPoolGrad : public DnnlKernel {
} else {
if (mklnode_ptr_->parent_nodes.empty()) {
// Sub-graph's first node. Read input from input buffer
diff_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
diff_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(bwd_primitive_desc_->diff_dst_desc(), cpu_engine, DNNL_MEMORY_NONE));
diff_dst_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(
diff_dst_mem_gpu_ = std::make_unique<dnnl::memory>(
dnnl::memory(bwd_primitive_desc_->diff_dst_desc(), gpu_engine));
net.push_back(dnnl::reorder(*diff_dst_mem_, *diff_dst_mem_gpu_));
net_args.push_back({{DNNL_ARG_SRC, *diff_dst_mem_},
@ -217,27 +217,27 @@ class DnnlMaxPoolGrad : public DnnlKernel {
if (primitive_dst_desc_ != ort_source_desc_) {
// reorder neded. Use primitive output as input to reorder and
// allocate buffer for reorder output, final output of this subgraph
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(bwd_primitive_desc_.get()->diff_src_desc(), cpu_engine));
} else {
// Last node but re-order not needed. Allocate buffer to output of this node
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(bwd_primitive_desc_.get()->diff_src_desc(), cpu_engine, DNNL_MEMORY_NONE));
}
} else {
// Intermediate node. Use Dnnl kernel internal memory for output and
// use this as input to next node.
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(bwd_primitive_desc_.get()->diff_src_desc(), cpu_engine));
}
} else {
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(bwd_primitive_desc_.get()->diff_src_desc(), gpu_engine));
}
auto workspace_mem_ = pool_fwd_->GetWorkspacePtr();
pool_bwd_ = onnxruntime::make_unique<dnnl::pooling_backward>(
pool_bwd_ = std::make_unique<dnnl::pooling_backward>(
dnnl::pooling_backward(*bwd_primitive_desc_));
net.push_back(*pool_bwd_);

View file

@ -62,7 +62,7 @@ class DnnlPool : public DnnlKernel {
// reorder for better performance
dnnl::memory::format_tag src_format = GetAVXFormat(src_dims_mkl);
src_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
src_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({src_dims_mkl}, DnnnType<T>(), src_format));
} else {
// get the output of previous node (Dnnl block propagation).
@ -79,14 +79,14 @@ class DnnlPool : public DnnlKernel {
dnnl::memory::dims src_dims_mkl(x_shape_.GetDims().begin(), x_shape_.GetDims().end());
// reorder for better performance
dnnl::memory::format_tag fmt = GetAVXFormat(src_dims_mkl);
src_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
src_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({src_dims_mkl}, DnnnType<T>(), fmt));
} else {
src_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
src_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc(parents_[0].get()->primitive_dst_mem_->get_desc()));
}
} else { // gpu_available_
src_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
src_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc(parents_[0].get()->primitive_dst_mem_->get_desc()));
}
}
@ -116,7 +116,7 @@ class DnnlPool : public DnnlKernel {
dnnl::memory::dims padding_left_mkl(pads_.begin(), pads_.begin() + (pads_.size() / 2));
dnnl::memory::dims padding_right_mkl(pads_.begin() + (pads_.size() / 2), pads_.end());
primitive_dst_md_ = onnxruntime::make_unique<dnnl::memory::desc>(
primitive_dst_md_ = std::make_unique<dnnl::memory::desc>(
dnnl::memory::desc({dst_dims_mkl}, DnnnType<T>(), dnnl::memory::format_tag::any));
dnnl::algorithm algo = dnnl::algorithm::pooling_max;
@ -133,14 +133,14 @@ class DnnlPool : public DnnlKernel {
auto prop_kind = dnnl::prop_kind::forward_inference;
#endif // ENABLE_TRAINING
fwd_desc_ = onnxruntime::make_unique<dnnl::pooling_forward::desc>(
fwd_desc_ = std::make_unique<dnnl::pooling_forward::desc>(
dnnl::pooling_forward::desc(prop_kind, algo,
*src_md_, *primitive_dst_md_,
strides_mkl, kernel_mkl,
padding_left_mkl, padding_right_mkl));
fwd_primitive_desc_ = onnxruntime::make_unique<dnnl::pooling_forward::primitive_desc>(
fwd_primitive_desc_ = std::make_unique<dnnl::pooling_forward::primitive_desc>(
dnnl::pooling_forward::primitive_desc(*fwd_desc_, engine_to_use));
primitive_src_desc_ = fwd_primitive_desc_.get()->src_desc();
@ -152,19 +152,19 @@ class DnnlPool : public DnnlKernel {
auto pd = dnnl::memory::desc(source_desc_);
if (mklnode_ptr_->parent_nodes.empty())
src_mem_from_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_from_ = std::make_unique<dnnl::memory>(
dnnl::memory(pd, cpu_engine, nullptr));
else
src_mem_from_ = parents_[0].get()->primitive_dst_mem_;
src_mem_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(fwd_primitive_desc_->src_desc(), cpu_engine, nullptr));
net.push_back(dnnl::reorder(*src_mem_from_, *src_mem_));
net_args.push_back({{DNNL_ARG_FROM, *src_mem_from_},
{DNNL_ARG_TO, *src_mem_}});
} else {
if (mklnode_ptr_->parent_nodes.empty()) {
src_mem_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(fwd_primitive_desc_->src_desc(), cpu_engine, nullptr));
} else {
src_mem_ = parents_[0].get()->primitive_dst_mem_;
@ -175,21 +175,21 @@ class DnnlPool : public DnnlKernel {
auto pd = dnnl::memory::desc(source_desc_);
if (mklnode_ptr_->parent_nodes.empty()) {
src_mem_from_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_from_ = std::make_unique<dnnl::memory>(
dnnl::memory(pd, cpu_engine, nullptr));
} else {
src_mem_from_ = parents_[0].get()->primitive_dst_mem_;
}
src_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_gpu_ = std::make_unique<dnnl::memory>(
dnnl::memory(fwd_primitive_desc_->src_desc(), gpu_engine));
net.push_back(dnnl::reorder(*src_mem_from_, *src_mem_gpu_));
net_args.push_back({{DNNL_ARG_FROM, *src_mem_from_},
{DNNL_ARG_TO, *src_mem_gpu_}});
} else {
if (mklnode_ptr_->parent_nodes.empty()) {
src_mem_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(fwd_primitive_desc_->src_desc(), cpu_engine, nullptr));
src_mem_gpu_ = onnxruntime::make_unique<dnnl::memory>(
src_mem_gpu_ = std::make_unique<dnnl::memory>(
dnnl::memory(fwd_primitive_desc_->src_desc(), gpu_engine));
net.push_back(dnnl::reorder(*src_mem_, *src_mem_gpu_));
net_args.push_back({{DNNL_ARG_SRC, *src_mem_},
@ -206,30 +206,30 @@ class DnnlPool : public DnnlKernel {
if (primitive_dst_desc_ != ort_source_desc_) {
// reorder neded. Use primitive output as input to reorder and
// allocate buffer for reorder output, final output of this subgraph
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(fwd_primitive_desc_.get()->dst_desc(), cpu_engine));
} else {
// Last node but re-order not needed. Allocate buffer to output of this node
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(fwd_primitive_desc_.get()->dst_desc(), cpu_engine, nullptr));
}
} else {
// Intermediate node. Use Dnnl kernel internal memory for output and
// use this as input to next node.
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(fwd_primitive_desc_.get()->dst_desc(), cpu_engine));
}
} else { // gpu_available_
primitive_dst_mem_ = onnxruntime::make_unique<dnnl::memory>(
primitive_dst_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(fwd_primitive_desc_.get()->dst_desc(), gpu_engine));
}
#ifdef ENABLE_TRAINING
workspace_mem_ = onnxruntime::make_unique<dnnl::memory>(
workspace_mem_ = std::make_unique<dnnl::memory>(
dnnl::memory(fwd_primitive_desc_.get()->workspace_desc(), engine_to_use));
#endif // ENABLE_TRAINING
pool_fwd_ = onnxruntime::make_unique<dnnl::pooling_forward>(
pool_fwd_ = std::make_unique<dnnl::pooling_forward>(
dnnl::pooling_forward(*fwd_primitive_desc_));
net.push_back(*pool_fwd_);

Some files were not shown because too many files have changed in this diff Show more