diff options
Diffstat (limited to 'arm_compute/graph/backends')
18 files changed, 527 insertions, 1014 deletions
diff --git a/arm_compute/graph/backends/BackendRegistrar.h b/arm_compute/graph/backends/BackendRegistrar.h index 902c12b0a6..2879361fef 100644 --- a/arm_compute/graph/backends/BackendRegistrar.h +++ b/arm_compute/graph/backends/BackendRegistrar.h @@ -24,8 +24,8 @@ #ifndef ARM_COMPUTE_GRAPH_BACKEND_REGISTRAR_H #define ARM_COMPUTE_GRAPH_BACKEND_REGISTRAR_H -#include "arm_compute/graph/Types.h" #include "arm_compute/graph/backends/BackendRegistry.h" +#include "arm_compute/graph/Types.h" #include <utility> @@ -58,4 +58,4 @@ inline BackendRegistrar<T>::BackendRegistrar(Target target) } // namespace backends } // namespace graph } // namespace arm_compute -#endif /* ARM_COMPUTE_GRAPH_BACKEND_REGISTRAR_H */
\ No newline at end of file +#endif /* ARM_COMPUTE_GRAPH_BACKEND_REGISTRAR_H */ diff --git a/arm_compute/graph/backends/BackendRegistry.h b/arm_compute/graph/backends/BackendRegistry.h index c4414a23f6..7c11d35faf 100644 --- a/arm_compute/graph/backends/BackendRegistry.h +++ b/arm_compute/graph/backends/BackendRegistry.h @@ -26,7 +26,6 @@ #include "arm_compute/graph/IDeviceBackend.h" #include "arm_compute/graph/Types.h" -#include "support/MemorySupport.h" #include <map> #include <memory> @@ -93,7 +92,7 @@ private: template <typename T> inline void BackendRegistry::add_backend(Target target) { - _registered_backends[target] = support::cpp14::make_unique<T>(); + _registered_backends[target] = std::make_unique<T>(); } } // namespace backends } // namespace graph diff --git a/arm_compute/graph/backends/CL/CLDeviceBackend.h b/arm_compute/graph/backends/CL/CLDeviceBackend.h index a8ee25d7e2..09e19d7688 100644 --- a/arm_compute/graph/backends/CL/CLDeviceBackend.h +++ b/arm_compute/graph/backends/CL/CLDeviceBackend.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 Arm Limited. + * Copyright (c) 2018-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -25,9 +25,10 @@ #define ARM_COMPUTE_GRAPH_CLDEVICEBACKEND_H #include "arm_compute/graph/IDeviceBackend.h" - #include "arm_compute/runtime/CL/CLBufferAllocator.h" +#include "arm_compute/runtime/CL/CLGEMMHeuristicsHandle.h" #include "arm_compute/runtime/CL/CLTuner.h" +#include "arm_compute/runtime/CL/CLTypes.h" namespace arm_compute { @@ -57,23 +58,27 @@ public: void set_kernel_tuning_mode(CLTunerMode tuning_mode); // Inherited overridden methods - void initialize_backend() override; - void setup_backend_context(GraphContext &ctx) override; - void release_backend_context(GraphContext &ctx) override; + void initialize_backend() override; + void setup_backend_context(GraphContext &ctx) override; + void release_backend_context(GraphContext &ctx) override; bool is_backend_supported() override; IAllocator *backend_allocator() override; std::unique_ptr<ITensorHandle> create_tensor(const Tensor &tensor) override; - std::unique_ptr<ITensorHandle> create_subtensor(ITensorHandle *parent, TensorShape shape, Coordinates coords, bool extend_parent) override; - std::unique_ptr<arm_compute::IFunction> configure_node(INode &node, GraphContext &ctx) override; - Status validate_node(INode &node) override; - std::shared_ptr<arm_compute::IMemoryManager> create_memory_manager(MemoryManagerAffinity affinity) override; + std::unique_ptr<ITensorHandle> + create_subtensor(ITensorHandle *parent, TensorShape shape, Coordinates coords, bool extend_parent) override; + std::unique_ptr<arm_compute::IFunction> configure_node(INode &node, GraphContext &ctx) override; + Status validate_node(INode &node) override; + std::shared_ptr<arm_compute::IMemoryManager> create_memory_manager(MemoryManagerAffinity affinity) override; std::shared_ptr<arm_compute::IWeightsManager> create_weights_manager() override; + void sync() override; private: int _context_count; /**< Counts how many contexts are currently using the backend */ CLTuner _tuner; /**< CL kernel tuner */ - std::unique_ptr<CLBufferAllocator> _allocator; /**< CL buffer affinity allocator */ - std::string _tuner_file; /**< Filename to load/store the tuner's values from */ + CLGEMMHeuristicsHandle _gemm_heuristics; /**< GEMM heuristics */ + std::unique_ptr<CLBufferAllocator> _allocator; /**< CL buffer affinity allocator */ + std::string _tuner_file; /**< Filename to load/store the tuner's values from */ + CLBackendType _backend_type; /**< OpenCL backend type to use */ }; } // namespace backends } // namespace graph diff --git a/arm_compute/graph/backends/CL/CLSubTensorHandle.h b/arm_compute/graph/backends/CL/CLSubTensorHandle.h index 3750fc85ee..85eebec639 100644 --- a/arm_compute/graph/backends/CL/CLSubTensorHandle.h +++ b/arm_compute/graph/backends/CL/CLSubTensorHandle.h @@ -25,7 +25,6 @@ #define ARM_COMPUTE_GRAPH_CLSUBTENSORHANDLE_H #include "arm_compute/graph/ITensorHandle.h" - #include "arm_compute/runtime/CL/CLSubTensor.h" namespace arm_compute @@ -45,7 +44,10 @@ public: * @param[in] coords Starting coordinates * @param[in] extend_parent Extends parent shape if true */ - CLSubTensorHandle(ITensorHandle *parent_handle, const TensorShape &shape, const Coordinates &coords, bool extend_parent = false); + CLSubTensorHandle(ITensorHandle *parent_handle, + const TensorShape &shape, + const Coordinates &coords, + bool extend_parent = false); /** Destructor: free the tensor's memory */ ~CLSubTensorHandle() = default; /** Allow instances of this class to be move constructed */ @@ -58,10 +60,10 @@ public: CLSubTensorHandle &operator=(const CLSubTensorHandle &) = delete; // Inherited overridden methods - void allocate() override; - void free() override; - void manage(IMemoryGroup *mg) override; - void map(bool blocking) override; + void allocate() override; + void free() override; + void manage(IMemoryGroup *mg) override; + void map(bool blocking) override; void unmap() override; void release_if_unused() override; arm_compute::ITensor &tensor() override; diff --git a/arm_compute/graph/backends/CL/CLTensorHandle.h b/arm_compute/graph/backends/CL/CLTensorHandle.h index 16e30efc43..57e9794ec3 100644 --- a/arm_compute/graph/backends/CL/CLTensorHandle.h +++ b/arm_compute/graph/backends/CL/CLTensorHandle.h @@ -25,7 +25,6 @@ #define ARM_COMPUTE_GRAPH_CLTENSORHANDLE_H #include "arm_compute/graph/ITensorHandle.h" - #include "arm_compute/runtime/CL/CLTensor.h" namespace arm_compute @@ -51,10 +50,10 @@ public: CLTensorHandle &operator=(CLTensorHandle &&) = default; // Inherited overridden methods - void allocate() override; - void free() override; - void manage(IMemoryGroup *mg) override; - void map(bool blocking) override; + void allocate() override; + void free() override; + void manage(IMemoryGroup *mg) override; + void map(bool blocking) override; void unmap() override; void release_if_unused() override; arm_compute::ITensor &tensor() override; diff --git a/arm_compute/graph/backends/FunctionHelpers.h b/arm_compute/graph/backends/FunctionHelpers.h index e2904af0b5..fd8b6b5a69 100644 --- a/arm_compute/graph/backends/FunctionHelpers.h +++ b/arm_compute/graph/backends/FunctionHelpers.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020 Arm Limited. + * Copyright (c) 2018-2021, 2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -21,22 +21,22 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef ARM_COMPUTE_GRAPH_BACKENDS_DETAIL_FUNCTION_HELPERS_H -#define ARM_COMPUTE_GRAPH_BACKENDS_DETAIL_FUNCTION_HELPERS_H +#ifndef ACL_ARM_COMPUTE_GRAPH_BACKENDS_FUNCTIONHELPERS_H +#define ACL_ARM_COMPUTE_GRAPH_BACKENDS_FUNCTIONHELPERS_H +#include "arm_compute/core/Error.h" +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/ITensorInfo.h" +#include "arm_compute/graph/backends/FusedConvolutionBatchNormalizationFunction.h" +#include "arm_compute/graph/backends/FusedDepthwiseConvolutionBatchNormalizationFunction.h" +#include "arm_compute/graph/backends/Utils.h" #include "arm_compute/graph/Logger.h" +#include "arm_compute/graph/nodes/Nodes.h" #include "arm_compute/graph/Tensor.h" #include "arm_compute/graph/TypePrinter.h" #include "arm_compute/graph/Types.h" #include "arm_compute/graph/Utils.h" -#include "arm_compute/graph/backends/FusedConvolutionBatchNormalizationFunction.h" -#include "arm_compute/graph/backends/FusedDepthwiseConvolutionBatchNormalizationFunction.h" -#include "arm_compute/graph/backends/Utils.h" -#include "arm_compute/graph/nodes/Nodes.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/ITensorInfo.h" #include "support/Cast.h" namespace arm_compute @@ -47,13 +47,6 @@ namespace backends { namespace detail { -// Address rule DR-9R5 (1579. Return by converting move constructor) -#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5)) -#define RETURN_UNIQUE_PTR(x) (x) -#else /* defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5)) */ -#define RETURN_UNIQUE_PTR(x) (std::move(x)) -#endif /* defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5)) */ - /** Returns backing tensor of a given tensor * * @tparam TargetInfo Target information @@ -66,13 +59,16 @@ template <typename TargetInfo> typename TargetInfo::TensorType *get_backing_tensor(arm_compute::graph::Tensor *tensor) { typename TargetInfo::TensorType *backing_tensor = nullptr; - if(tensor != nullptr) + if (tensor != nullptr) { ARM_COMPUTE_ERROR_ON(tensor->desc().target != TargetInfo::TargetType); // Get backing tensor handle ITensorHandle *tensor_handle = tensor->handle(); // Get backing tensor - backing_tensor = (tensor_handle != nullptr) ? arm_compute::utils::cast::polymorphic_cast<typename TargetInfo::TensorType *>(&tensor_handle->tensor()) : nullptr; + backing_tensor = (tensor_handle != nullptr) + ? arm_compute::utils::cast::polymorphic_cast<typename TargetInfo::TensorType *>( + &tensor_handle->tensor()) + : nullptr; } return backing_tensor; @@ -81,11 +77,8 @@ typename TargetInfo::TensorType *get_backing_tensor(arm_compute::graph::Tensor * template <typename TargetInfo> void validate_node(const INode &node, size_t num_expected_inputs, size_t num_expected_outputs) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Creating " << node.type() - << " Target: " << TargetInfo::TargetType - << " ID: " << node.id() - << node.name() - << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE("Creating " << node.type() << " Target: " << TargetInfo::TargetType + << " ID: " << node.id() << node.name() << std::endl); ARM_COMPUTE_ERROR_ON(TargetInfo::TargetType != node.assigned_target()); ARM_COMPUTE_ERROR_ON(node.num_inputs() != num_expected_inputs); @@ -113,22 +106,16 @@ std::unique_ptr<IFunction> create_activation_layer(ActivationLayerNode &node) const ActivationLayerInfo act_info = node.activation_info(); // Create function - auto func = support::cpp14::make_unique<ActivationLayerFunction>(); + auto func = std::make_unique<ActivationLayerFunction>(); func->configure(input, output, act_info); - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Shape: " << input->info()->tensor_shape() - << " Activation function: " << act_info.activation() - << " a: " << act_info.a() - << " b: " << act_info.b() - << " InPlace : " << is_in_place_operation(input, output) - << std::endl); - - return RETURN_UNIQUE_PTR(func); + ARM_COMPUTE_LOG_GRAPH_INFO( + "Instantiated " << node.name() << " Type: " << node.type() << " Target: " << TargetInfo::TargetType + << " Data Type: " << input->info()->data_type() << " Shape: " << input->info()->tensor_shape() + << " Activation function: " << act_info.activation() << " a: " << act_info.a() << " b: " + << act_info.b() << " InPlace : " << is_in_place_operation(input, output) << std::endl); + + return func; } /** Creates a backend argminmax layer function @@ -152,20 +139,15 @@ std::unique_ptr<IFunction> create_arg_min_max_layer(ArgMinMaxLayerNode &node) unsigned int axis = node.axis(); // Create function - auto func = support::cpp14::make_unique<ArgMinMaxLayerFunction>(); + auto func = std::make_unique<ArgMinMaxLayerFunction>(); func->configure(input, axis, output, op); - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Shape: " << input->info()->tensor_shape() - << " Reduction Operation: " << op - << " axis: " << axis - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Shape: " << input->info()->tensor_shape() + << " Reduction Operation: " << op << " axis: " << axis << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend batch normalization layer function @@ -194,22 +176,17 @@ std::unique_ptr<IFunction> create_batch_normalization_layer(BatchNormalizationLa const ActivationLayerInfo fused_act = node.fused_activation(); // Create and configure function - auto func = support::cpp14::make_unique<BatchNormalizationLayerFunction>(); + auto func = std::make_unique<BatchNormalizationLayerFunction>(); func->configure(input, output, mean, var, beta, gamma, epsilon, fused_act); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Shape: " << input->info()->tensor_shape() - << " Epsilon: " << epsilon << " " - << (fused_act.enabled() ? to_string(fused_act.activation()) : "") - << " InPlace: " << is_in_place_operation(input, output) - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Shape: " << input->info()->tensor_shape() << " Epsilon: " << epsilon + << " " << (fused_act.enabled() ? to_string(fused_act.activation()) : "") + << " InPlace: " << is_in_place_operation(input, output) << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend batch normalization layer function @@ -223,7 +200,8 @@ std::unique_ptr<IFunction> create_batch_normalization_layer(BatchNormalizationLa * @return Backend batch normalization layer function */ template <typename FusedLayerTypes, typename TargetInfo> -std::unique_ptr<IFunction> create_fused_convolution_batch_normalization_layer(FusedConvolutionBatchNormalizationNode &node, GraphContext &ctx) +std::unique_ptr<IFunction> +create_fused_convolution_batch_normalization_layer(FusedConvolutionBatchNormalizationNode &node, GraphContext &ctx) { validate_node<TargetInfo>(node, 7 /* expected inputs */, 1 /* expected outputs */); @@ -253,20 +231,17 @@ std::unique_ptr<IFunction> create_fused_convolution_batch_normalization_layer(Fu // Create and configure function std::tie(func, func_name) = create_named_memory_managed_function<FType>( - std::string("FusedConvolutionBatchNormalizationLayer"), mm, input, weights, biases, output, mean, var, beta, gamma, epsilon, conv_info, num_groups, fast_math, fused_act); + std::string("FusedConvolutionBatchNormalizationLayer"), mm, input, weights, biases, output, mean, var, beta, + gamma, epsilon, conv_info, num_groups, fast_math, fused_act); // Log info ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Weights shape: " << weights->info()->tensor_shape() + << node.name() << " Type: " << node.type() << " Target: " << TargetInfo::TargetType + << " Data Type: " << input->info()->data_type() << " Input shape: " + << input->info()->tensor_shape() << " Weights shape: " << weights->info()->tensor_shape() << " Output shape: " << output->info()->tensor_shape() - << (fused_act.enabled() ? " " + to_string(fused_act.activation()) : "") - << std::endl); - return RETURN_UNIQUE_PTR(func); + << (fused_act.enabled() ? " " + to_string(fused_act.activation()) : "") << std::endl); + return func; } /** Create a backend fused depthwise convolution batch normalization layer function @@ -280,7 +255,9 @@ std::unique_ptr<IFunction> create_fused_convolution_batch_normalization_layer(Fu * @return Backend fused depthwise convolution batch normalization layer function */ template <typename FusedLayerTypes, typename TargetInfo> -std::unique_ptr<IFunction> create_fused_depthwise_convolution_batch_normalization_layer(FusedDepthwiseConvolutionBatchNormalizationNode &node, GraphContext &ctx) +std::unique_ptr<IFunction> +create_fused_depthwise_convolution_batch_normalization_layer(FusedDepthwiseConvolutionBatchNormalizationNode &node, + GraphContext &ctx) { validate_node<TargetInfo>(node, 7 /* expected inputs */, 1 /* expected outputs */); @@ -309,20 +286,17 @@ std::unique_ptr<IFunction> create_fused_depthwise_convolution_batch_normalizatio // Create and configure function std::tie(func, func_name) = create_named_memory_managed_function<FType>( - std::string("FusedDepthwiseConvolutionBatchNormalizationLayer"), mm, input, weights, biases, output, mean, var, beta, gamma, epsilon, conv_info, depth_multiplier, fused_act); + std::string("FusedDepthwiseConvolutionBatchNormalizationLayer"), mm, input, weights, biases, output, mean, var, + beta, gamma, epsilon, conv_info, depth_multiplier, fused_act); // Log info ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Weights shape: " << weights->info()->tensor_shape() + << node.name() << " Type: " << node.type() << " Target: " << TargetInfo::TargetType + << " Data Type: " << input->info()->data_type() << " Input shape: " + << input->info()->tensor_shape() << " Weights shape: " << weights->info()->tensor_shape() << " Output shape: " << output->info()->tensor_shape() - << (fused_act.enabled() ? " " + to_string(fused_act.activation()) : "") - << std::endl); - return RETURN_UNIQUE_PTR(func); + << (fused_act.enabled() ? " " + to_string(fused_act.activation()) : "") << std::endl); + return func; } /** Create a backend bounding box transform layer function @@ -346,21 +320,17 @@ std::unique_ptr<IFunction> create_bounding_box_transform_layer(BoundingBoxTransf const BoundingBoxTransformInfo bbox_info = node.info(); // Create and configure function - auto func = support::cpp14::make_unique<BoundingBoxTransformLayerFunction>(); + auto func = std::make_unique<BoundingBoxTransformLayerFunction>(); func->configure(input, output, deltas, bbox_info); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Shape: " << input->info()->tensor_shape() - << " BoundingBox Info img W: " << bbox_info.img_width() << " " - << " BoundingBox Info img H: " << bbox_info.img_height() << " " - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO( + "Instantiated " << node.name() << " Type: " << node.type() << " Target: " << TargetInfo::TargetType + << " Data Type: " << input->info()->data_type() << " Shape: " << input->info()->tensor_shape() + << " BoundingBox Info img W: " << bbox_info.img_width() << " " + << " BoundingBox Info img H: " << bbox_info.img_height() << " " << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend channel shuffle layer function @@ -383,19 +353,15 @@ std::unique_ptr<IFunction> create_channel_shuffle_layer(ChannelShuffleLayerNode const unsigned int num_groups = node.num_groups(); // Create function - auto func = support::cpp14::make_unique<ChannelShuffleLayerFunction>(); + auto func = std::make_unique<ChannelShuffleLayerFunction>(); func->configure(input, output, num_groups); - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Shape: " << input->info()->tensor_shape() - << " Num groups: " << num_groups - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Shape: " << input->info()->tensor_shape() + << " Num groups: " << num_groups << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend layer concatenate function @@ -410,54 +376,49 @@ std::unique_ptr<IFunction> create_channel_shuffle_layer(ChannelShuffleLayerNode template <typename ConcatenateLayerFunction, typename TargetInfo> std::unique_ptr<arm_compute::IFunction> create_concatenate_layer(ConcatenateLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Creating Concatenate node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE("Creating Concatenate node with ID : " << node.id() << " and Name: " << node.name() + << std::endl); ARM_COMPUTE_ERROR_ON(node.num_outputs() != 1); // Return nullptr if depth concatenate is switched off - if(!node.is_enabled()) + if (!node.is_enabled()) { return nullptr; } // Extract IO and info std::vector<typename TargetInfo::SrcTensorType *> inputs; - for(unsigned int i = 0; i < node.num_inputs(); ++i) + for (unsigned int i = 0; i < node.num_inputs(); ++i) { inputs.push_back(get_backing_tensor<TargetInfo>(node.input(i))); } - typename TargetInfo::TensorType *output = get_backing_tensor<TargetInfo>(node.output(0)); - const DataLayout data_layout = node.output(0) != nullptr ? node.output(0)->desc().layout : DataLayout::UNKNOWN; - const size_t concat_axis = get_dimension_idx(data_layout, node.concatenation_axis()); + typename TargetInfo::TensorType *output = get_backing_tensor<TargetInfo>(node.output(0)); + const DataLayout data_layout = node.output(0) != nullptr ? node.output(0)->desc().layout : DataLayout::UNKNOWN; + const size_t concat_axis = get_dimension_idx(data_layout, node.concatenation_axis()); // Create and configure function - auto func = support::cpp14::make_unique<ConcatenateLayerFunction>(); + auto func = std::make_unique<ConcatenateLayerFunction>(); func->configure(inputs, output, concat_axis); // Log info const bool is_quantized = is_data_type_quantized_asymmetric(output->info()->data_type()); std::ostringstream qss; - if(is_quantized) + if (is_quantized) { qss << " Output QuantInfo: " << output->info()->quantization_info(); } - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << output->info()->data_type() - << " Shape: " << output->info()->tensor_shape() - << " Num Inputs: " << inputs.size() - << " Axis: " << concat_axis - << qss.str() - << std::endl); - - return RETURN_UNIQUE_PTR(func); + ARM_COMPUTE_LOG_GRAPH_INFO( + "Instantiated " << node.name() << " Type: " << node.type() << " Target: " << TargetInfo::TargetType + << " Data Type: " << output->info()->data_type() << " Shape: " << output->info()->tensor_shape() + << " Num Inputs: " << inputs.size() << " Axis: " << concat_axis << qss.str() << std::endl); + + return func; } /** Create a backend convolution layer function * * @tparam ConvolutionLayerFunctions Backend convolution functions - * @tparam TargetInfo Target-specific information + * @tparam TargetInfo Target-specific information * * @param[in] node Node to create the backend function for * @param[in] ctx Graph context @@ -477,7 +438,7 @@ std::unique_ptr<IFunction> create_convolution_layer(ConvolutionLayerNode &node, const bool is_quantized = is_data_type_quantized_asymmetric(input->info()->data_type()); - if(is_quantized) + if (is_quantized) { biases->info()->set_data_type(DataType::S32); } @@ -493,56 +454,51 @@ std::unique_ptr<IFunction> create_convolution_layer(ConvolutionLayerNode &node, std::unique_ptr<IFunction> func; std::string func_name; - if(conv_algorithm == ConvolutionMethod::Winograd) + if (conv_algorithm == ConvolutionMethod::Winograd) { ARM_COMPUTE_ERROR_ON_MSG(num_groups != 1, "WinogradConvolutionLayer does not support grouping!"); - std::tie(func, func_name) = create_named_memory_managed_function<typename ConvolutionLayerFunctions::WinogradConvolutionLayer>( - std::string("WinogradConvolutionLayer"), mm, - input, weights, biases, output, conv_info, fused_act, fast_math); + std::tie(func, func_name) = + create_named_memory_managed_function<typename ConvolutionLayerFunctions::WinogradConvolutionLayer>( + std::string("WinogradConvolutionLayer"), mm, input, weights, biases, output, conv_info, fused_act, + fast_math); } - else if(conv_algorithm == ConvolutionMethod::Direct) + else if (conv_algorithm == ConvolutionMethod::Direct) { ARM_COMPUTE_ERROR_ON_MSG(num_groups != 1, "DirectConvolutionLayer does not support grouping!"); std::tie(func, func_name) = create_named_function<typename ConvolutionLayerFunctions::DirectConvolutionLayer>( - std::string("DirectConvolutionLayer"), - input, weights, biases, output, conv_info, fused_act); + std::string("DirectConvolutionLayer"), input, weights, biases, output, conv_info, fused_act); } - else if(conv_algorithm == ConvolutionMethod::GEMM) + else if (conv_algorithm == ConvolutionMethod::GEMM) { - std::tie(func, func_name) = create_named_memory_managed_function<typename ConvolutionLayerFunctions::GEMMConvolutionLayer>( - std::string("GEMMConvolutionLayer"), mm, - input, weights, biases, output, conv_info, - WeightsInfo(), Size2D(1U, 1U), fused_act, num_groups); + std::tie(func, func_name) = + create_named_memory_managed_function<typename ConvolutionLayerFunctions::GEMMConvolutionLayer>( + std::string("GEMMConvolutionLayer"), mm, input, weights, biases, output, conv_info, WeightsInfo(), + Size2D(1U, 1U), fused_act, num_groups); } else { - std::tie(func, func_name) = create_named_memory_managed_function<typename ConvolutionLayerFunctions::GenericConvolutionLayer>( - std::string("GenericConvolutionLayer"), mm, - input, weights, biases, output, conv_info, - WeightsInfo(), Size2D(1U, 1U), fused_act, fast_math, num_groups); + std::tie(func, func_name) = + create_named_memory_managed_function<typename ConvolutionLayerFunctions::GenericConvolutionLayer>( + std::string("GenericConvolutionLayer"), mm, input, weights, biases, output, conv_info, WeightsInfo(), + Size2D(1U, 1U), fused_act, fast_math, num_groups); } // Log info std::ostringstream qss; - if(is_quantized) + if (is_quantized) { qss << " Input QuantInfo: " << input->info()->quantization_info() << " Weights QuantInfo: " << weights->info()->quantization_info() << " Output QuantInfo: " << output->info()->quantization_info(); } ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << func_name - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Groups: " << num_groups + << node.name() << " Type: " << func_name << " Target: " << TargetInfo::TargetType + << " Data Type: " << input->info()->data_type() << " Groups: " << num_groups << " Input shape: " << input->info()->tensor_shape() << " Weights shape: " << weights->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << qss.str() - << (fused_act.enabled() ? " " + to_string(fused_act.activation()) : "") - << std::endl); - return RETURN_UNIQUE_PTR(func); + << " Output shape: " << output->info()->tensor_shape() << qss.str() + << (fused_act.enabled() ? " " + to_string(fused_act.activation()) : "") << std::endl); + return func; } /** Create a backend deconvolution layer function @@ -573,19 +529,14 @@ std::unique_ptr<IFunction> create_deconvolution_layer(DeconvolutionLayerNode &no std::unique_ptr<IFunction> func; std::tie(func, std::ignore) = create_named_memory_managed_function<DeconvolutionLayerFunction>( - std::string(), mm, - input, weights, biases, output, deconv_info); + std::string(), mm, input, weights, biases, output, deconv_info); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Weights shape: " << weights->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Input shape: " << input->info()->tensor_shape() + << " Weights shape: " << weights->info()->tensor_shape() + << " Output shape: " << output->info()->tensor_shape() << std::endl); return func; } @@ -611,7 +562,7 @@ std::unique_ptr<IFunction> create_depthwise_convolution_layer(DepthwiseConvoluti const bool is_quantized = is_data_type_quantized_asymmetric(input->info()->data_type()); - if(is_quantized) + if (is_quantized) { biases->info()->set_data_type(DataType::S32); } @@ -624,31 +575,26 @@ std::unique_ptr<IFunction> create_depthwise_convolution_layer(DepthwiseConvoluti std::unique_ptr<IFunction> func; std::string func_name; - std::tie(func, func_name) = create_named_function<DepthwiseConvolutionLayer>( - std::string("DepthwiseConvolutionLayer"), - input, weights, biases, output, conv_info, depth_multiplier, fused_act); + std::tie(func, func_name) = + create_named_function<DepthwiseConvolutionLayer>(std::string("DepthwiseConvolutionLayer"), input, weights, + biases, output, conv_info, depth_multiplier, fused_act); // Log info std::ostringstream qss; - if(is_quantized) + if (is_quantized) { qss << " Input QuantInfo: " << input->info()->quantization_info() << " Weights QuantInfo: " << weights->info()->quantization_info() << " Output QuantInfo: " << output->info()->quantization_info(); } ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << func_name - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Weights shape: " << weights->info()->tensor_shape() + << node.name() << " Type: " << func_name << " Target: " << TargetInfo::TargetType + << " Data Type: " << input->info()->data_type() << " Input shape: " + << input->info()->tensor_shape() << " Weights shape: " << weights->info()->tensor_shape() << " Output shape: " << output->info()->tensor_shape() - << " Depth multiplier: " << depth_multiplier - << qss.str() - << (fused_act.enabled() ? " " + to_string(fused_act.activation()) : "") - << std::endl); - return RETURN_UNIQUE_PTR(func); + << " Depth multiplier: " << depth_multiplier << qss.str() + << (fused_act.enabled() ? " " + to_string(fused_act.activation()) : "") << std::endl); + return func; } /** Create a backend depth to space layer function @@ -673,21 +619,17 @@ std::unique_ptr<IFunction> create_depth_to_space_layer(DepthToSpaceLayerNode &no ARM_COMPUTE_ERROR_ON(output == nullptr); // Create and configure function - auto func = support::cpp14::make_unique<DepthToSpaceLayerFunction>(); + auto func = std::make_unique<DepthToSpaceLayerFunction>(); func->configure(input, output, node.block_shape()); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Block Size: " << node.block_shape() - << " Output shape: " << output->info()->tensor_shape() - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Input shape: " << input->info()->tensor_shape() + << " Block Size: " << node.block_shape() + << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend dequantize layer function @@ -712,21 +654,17 @@ std::unique_ptr<IFunction> create_dequantization_layer(DequantizationLayerNode & ARM_COMPUTE_ERROR_ON(output == nullptr); // Create and configure function - auto func = support::cpp14::make_unique<DequantizationLayerFunction>(); + auto func = std::make_unique<DequantizationLayerFunction>(); func->configure(input, output); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Input quantization info: " << output->info()->quantization_info() - << " Output shape: " << output->info()->tensor_shape() - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Input shape: " << input->info()->tensor_shape() + << " Input quantization info: " << output->info()->quantization_info() + << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend detection output layer function * @@ -755,23 +693,19 @@ std::unique_ptr<IFunction> create_detection_output_layer(DetectionOutputLayerNod ARM_COMPUTE_ERROR_ON(output == nullptr); // Create and configure function - auto func = support::cpp14::make_unique<DetectionOutputLayerFunction>(); + auto func = std::make_unique<DetectionOutputLayerFunction>(); func->configure(input0, input1, input2, output, detect_info); // Log info ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input0->info()->data_type() - << " Input0 shape: " << input0->info()->tensor_shape() - << " Input1 shape: " << input1->info()->tensor_shape() + << node.name() << " Type: " << node.type() << " Target: " << TargetInfo::TargetType + << " Data Type: " << input0->info()->data_type() << " Input0 shape: " + << input0->info()->tensor_shape() << " Input1 shape: " << input1->info()->tensor_shape() << " Input2 shape: " << input2->info()->tensor_shape() << " Output shape: " << output->info()->tensor_shape() - << " DetectionOutputLayer info: " << detect_info - << std::endl); + << " DetectionOutputLayer info: " << detect_info << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend detection post process layer function @@ -807,26 +741,22 @@ std::unique_ptr<IFunction> create_detection_post_process_layer(DetectionPostProc ARM_COMPUTE_ERROR_ON(output3 == nullptr); // Create and configure function - auto func = support::cpp14::make_unique<DetectionPostProcessLayerFunction>(); + auto func = std::make_unique<DetectionPostProcessLayerFunction>(); func->configure(input0, input1, input2, output0, output1, output2, output3, detect_info); // Log info ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input0->info()->data_type() - << " Input0 shape: " << input0->info()->tensor_shape() - << " Input1 shape: " << input1->info()->tensor_shape() + << node.name() << " Type: " << node.type() << " Target: " << TargetInfo::TargetType + << " Data Type: " << input0->info()->data_type() << " Input0 shape: " + << input0->info()->tensor_shape() << " Input1 shape: " << input1->info()->tensor_shape() << " Input2 shape: " << input2->info()->tensor_shape() << " Output0 shape: " << output0->info()->tensor_shape() << " Output1 shape: " << output1->info()->tensor_shape() << " Output2 shape: " << output2->info()->tensor_shape() << " Output3 shape: " << output3->info()->tensor_shape() - << " DetectionPostProcessLayer info: " << detect_info - << std::endl); + << " DetectionPostProcessLayer info: " << detect_info << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend element-wise operation layer function @@ -856,29 +786,31 @@ std::unique_ptr<IFunction> create_eltwise_layer(EltwiseLayerNode &node) std::unique_ptr<IFunction> func = nullptr; std::string func_name; - if(eltwise_op == EltwiseOperation::Add) + if (eltwise_op == EltwiseOperation::Add) { std::tie(func, func_name) = create_named_function<typename EltwiseFunctions::Addition>( - std::string("ArithmeticAddition"), - input1, input2, output, convert_policy, act_info); + std::string("ArithmeticAddition"), input1, input2, output, convert_policy, act_info); } - else if(eltwise_op == EltwiseOperation::Sub) + else if (eltwise_op == EltwiseOperation::Sub) { std::tie(func, func_name) = create_named_function<typename EltwiseFunctions::Subtraction>( - std::string("ArithmeticSubtraction"), - input1, input2, output, convert_policy, act_info); + std::string("ArithmeticSubtraction"), input1, input2, output, convert_policy, act_info); } - else if(eltwise_op == EltwiseOperation::Mul) + else if (eltwise_op == EltwiseOperation::Mul) { std::tie(func, func_name) = create_named_function<typename EltwiseFunctions::Multiplication>( - std::string("PixelWiseMultiplication"), - input1, input2, output, 1.f, convert_policy, node.rounding_policy(), act_info); + std::string("PixelWiseMultiplication"), input1, input2, output, 1.f, convert_policy, node.rounding_policy(), + act_info); } - else if(eltwise_op == EltwiseOperation::Max) + else if (eltwise_op == EltwiseOperation::Max) { std::tie(func, func_name) = create_named_function<typename EltwiseFunctions::Maximum>( - std::string("ElementwiseMaximum"), - input1, input2, output, act_info); + std::string("ElementwiseMaximum"), input1, input2, output, act_info); + } + else if (eltwise_op == EltwiseOperation::Div) + { + std::tie(func, func_name) = create_named_function<typename EltwiseFunctions::Division>( + std::string("ArithmeticDivision"), input1, input2, output, act_info); } else { @@ -886,16 +818,12 @@ std::unique_ptr<IFunction> create_eltwise_layer(EltwiseLayerNode &node) } // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Operation: " << func_name - << " Data Type: " << input1->info()->data_type() - << " Shape: " << input1->info()->tensor_shape() - << std::endl); - - return RETURN_UNIQUE_PTR(func); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() + << " Target: " << TargetInfo::TargetType << " Operation: " << func_name + << " Data Type: " << input1->info()->data_type() + << " Shape: " << input1->info()->tensor_shape() << std::endl); + + return func; } /** Create a backend unary element-wise operation layer function @@ -922,11 +850,10 @@ std::unique_ptr<IFunction> create_unary_eltwise_layer(UnaryEltwiseLayerNode &nod std::unique_ptr<IFunction> func = nullptr; std::string func_name; - if(eltwise_op == UnaryEltwiseOperation::Exp) + if (eltwise_op == UnaryEltwiseOperation::Exp) { - std::tie(func, func_name) = create_named_function<typename UnaryEltwiseFunctions::Exp>( - std::string("Exp"), - input, output); + std::tie(func, func_name) = + create_named_function<typename UnaryEltwiseFunctions::Exp>(std::string("Exp"), input, output); } else { @@ -934,16 +861,12 @@ std::unique_ptr<IFunction> create_unary_eltwise_layer(UnaryEltwiseLayerNode &nod } // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Operation: " << func_name - << " Data Type: " << input->info()->data_type() - << " Shape: " << input->info()->tensor_shape() - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() + << " Target: " << TargetInfo::TargetType << " Operation: " << func_name + << " Data Type: " << input->info()->data_type() + << " Shape: " << input->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend flatten layer function @@ -968,20 +891,16 @@ std::unique_ptr<IFunction> create_flatten_layer(FlattenLayerNode &node) ARM_COMPUTE_ERROR_ON(output == nullptr); // Create and configure function - auto func = support::cpp14::make_unique<FlattenLayerFunction>(); + auto func = std::make_unique<FlattenLayerFunction>(); func->configure(input, output); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Input shape: " << input->info()->tensor_shape() + << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend fully connected layer function @@ -1004,7 +923,8 @@ std::unique_ptr<IFunction> create_fully_connected_layer(FullyConnectedLayerNode typename TargetInfo::TensorType *weights = get_backing_tensor<TargetInfo>(node.input(1)); typename TargetInfo::TensorType *biases = get_backing_tensor<TargetInfo>(node.input(2)); typename TargetInfo::TensorType *output = get_backing_tensor<TargetInfo>(node.output(0)); - const FullyConnectedLayerInfo fc_info = node.info(); + FullyConnectedLayerInfo fc_info = node.info(); + fc_info.enable_fast_math = (node.fast_math_hint() == FastMathHint::Enabled); ARM_COMPUTE_ERROR_ON(input == nullptr); ARM_COMPUTE_ERROR_ON(weights == nullptr); @@ -1013,31 +933,26 @@ std::unique_ptr<IFunction> create_fully_connected_layer(FullyConnectedLayerNode // Create and configure function auto wm = get_weights_manager(ctx, TargetInfo::TargetType); auto mm = get_memory_manager(ctx, TargetInfo::TargetType); - auto func = support::cpp14::make_unique<FullyConnectedLayerFunction>(mm, wm.get()); + auto func = std::make_unique<FullyConnectedLayerFunction>(mm, wm.get()); func->configure(input, weights, biases, output, fc_info); const bool is_quantized = is_data_type_quantized_asymmetric(input->info()->data_type()); // Log info std::ostringstream qss; - if(is_quantized) + if (is_quantized) { qss << " Input QuantInfo: " << input->info()->quantization_info() << " Weights QuantInfo: " << weights->info()->quantization_info() << " Output QuantInfo: " << output->info()->quantization_info(); } - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << qss.str() - << " Input shape: " << input->info()->tensor_shape() - << " Weights shape: " << weights->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << qss.str() << " Input shape: " << input->info()->tensor_shape() + << " Weights shape: " << weights->info()->tensor_shape() + << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend generate proposals layer function @@ -1071,22 +986,20 @@ std::unique_ptr<IFunction> create_generate_proposals_layer(GenerateProposalsLaye ARM_COMPUTE_ERROR_ON(scores_out == nullptr); // Create and configure function - auto func = support::cpp14::make_unique<GenerateProposalsLayerFunction>(get_memory_manager(ctx, TargetInfo::TargetType)); + auto func = std::make_unique<GenerateProposalsLayerFunction>(get_memory_manager(ctx, TargetInfo::TargetType)); func->configure(scores, deltas, anchors, proposals, scores_out, num_valid_proposals, info); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.type() - << " Target " << TargetInfo::TargetType - << " Data Type: " << scores->info()->data_type() - << " Scores shape: " << scores->info()->tensor_shape() + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " + << node.type() << " Target " << TargetInfo::TargetType << " Data Type: " + << scores->info()->data_type() << " Scores shape: " << scores->info()->tensor_shape() << " Deltas shape: " << deltas->info()->tensor_shape() << " Anchors shape: " << anchors->info()->tensor_shape() << " Proposals shape: " << proposals->info()->tensor_shape() << " Num valid proposals shape: " << num_valid_proposals->info()->tensor_shape() - << " Scores Out shape: " << scores_out->info()->tensor_shape() - << std::endl); + << " Scores Out shape: " << scores_out->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend l2 normalization layer function @@ -1115,22 +1028,17 @@ std::unique_ptr<IFunction> create_l2_normalize_layer(L2NormalizeLayerNode &node, // Create and configure function auto mm = get_memory_manager(ctx, TargetInfo::TargetType); - auto func = support::cpp14::make_unique<L2NormalizeLayerFunction>(mm); + auto func = std::make_unique<L2NormalizeLayerFunction>(mm); func->configure(input, output, axis, epsilon); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << " Axis: " << axis - << " Epsilon: " << epsilon - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Input shape: " << input->info()->tensor_shape() + << " Output shape: " << output->info()->tensor_shape() + << " Axis: " << axis << " Epsilon: " << epsilon << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend normalization layer function @@ -1158,21 +1066,17 @@ std::unique_ptr<IFunction> create_normalization_layer(NormalizationLayerNode &no ARM_COMPUTE_ERROR_ON(output == nullptr); // Create and configure function - auto func = support::cpp14::make_unique<NormalizationLayerFunction>(); + auto func = std::make_unique<NormalizationLayerFunction>(); func->configure(input, output, norm_info); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << " Normalization info: " << norm_info.type() - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Input shape: " << input->info()->tensor_shape() + << " Output shape: " << output->info()->tensor_shape() + << " Normalization info: " << norm_info.type() << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend normalize planar YUV layer function @@ -1200,19 +1104,15 @@ std::unique_ptr<IFunction> create_normalize_planar_yuv_layer(NormalizePlanarYUVL ARM_COMPUTE_ERROR_ON(output == nullptr); // Create and configure function - auto func = support::cpp14::make_unique<NormalizePlanarYUVLayerFunction>(); + auto func = std::make_unique<NormalizePlanarYUVLayerFunction>(); func->configure(input, output, mean, std); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Shape: " << input->info()->tensor_shape() - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Shape: " << input->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return std::move(func); } /** Create a backend pad layer function @@ -1238,20 +1138,16 @@ std::unique_ptr<IFunction> create_pad_layer(PadLayerNode &node) ARM_COMPUTE_ERROR_ON(output == nullptr); // Create and configure function - auto func = support::cpp14::make_unique<PadLayerFunction>(); + auto func = std::make_unique<PadLayerFunction>(); func->configure(input, output, padding, pad_value); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Input shape: " << input->info()->tensor_shape() + << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend permute layer function @@ -1276,21 +1172,17 @@ std::unique_ptr<IFunction> create_permute_layer(PermuteLayerNode &node) ARM_COMPUTE_ERROR_ON(output == nullptr); // Create and configure function - auto func = support::cpp14::make_unique<PermuteLayerFunction>(); + auto func = std::make_unique<PermuteLayerFunction>(); func->configure(input, output, perm); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << " Permutation vector: " << perm - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Input shape: " << input->info()->tensor_shape() + << " Output shape: " << output->info()->tensor_shape() + << " Permutation vector: " << perm << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend pooling layer function @@ -1315,21 +1207,17 @@ std::unique_ptr<IFunction> create_pooling_layer(PoolingLayerNode &node) ARM_COMPUTE_ERROR_ON(output == nullptr); // Create and configure function - auto func = support::cpp14::make_unique<PoolingLayerFunction>(); + auto func = std::make_unique<PoolingLayerFunction>(); func->configure(input, output, pool_info); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << " Pooling info: " << pool_info.pool_type - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Input shape: " << input->info()->tensor_shape() + << " Output shape: " << output->info()->tensor_shape() + << " Pooling info: " << pool_info.pool_type << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend PRelu layer function @@ -1354,20 +1242,16 @@ std::unique_ptr<IFunction> create_prelu_layer(PReluLayerNode &node) ARM_COMPUTE_ERROR_ON(output == nullptr); // Create and configure function - auto func = support::cpp14::make_unique<PReluFunction>(); + auto func = std::make_unique<PReluFunction>(); func->configure(input, alpha, output); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Input shape: " << input->info()->tensor_shape() + << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend print layer function @@ -1388,13 +1272,9 @@ std::unique_ptr<IFunction> create_print_layer(PrintLayerNode &node) ARM_COMPUTE_UNUSED(input); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Input shape: " << input->info()->tensor_shape() << std::endl); return nullptr; } @@ -1423,22 +1303,18 @@ std::unique_ptr<IFunction> create_priorbox_layer(PriorBoxLayerNode &node) ARM_COMPUTE_ERROR_ON(output == nullptr); // Create and configure function - auto func = support::cpp14::make_unique<PriorBoxLayerFunction>(); + auto func = std::make_unique<PriorBoxLayerFunction>(); func->configure(input0, input1, output, prior_info); // Log info ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input0->info()->data_type() - << " Input0 shape: " << input0->info()->tensor_shape() - << " Input1 shape: " << input1->info()->tensor_shape() + << node.name() << " Type: " << node.type() << " Target: " << TargetInfo::TargetType + << " Data Type: " << input0->info()->data_type() << " Input0 shape: " + << input0->info()->tensor_shape() << " Input1 shape: " << input1->info()->tensor_shape() << " Output shape: " << output->info()->tensor_shape() - << " PriorBoxLayer info: " << prior_info - << std::endl); + << " PriorBoxLayer info: " << prior_info << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend quantization layer function @@ -1462,20 +1338,16 @@ std::unique_ptr<IFunction> create_quantization_layer(QuantizationLayerNode &node ARM_COMPUTE_ERROR_ON(output == nullptr); // Create and configure function - auto func = support::cpp14::make_unique<QuantizationLayerFunction>(); + auto func = std::make_unique<QuantizationLayerFunction>(); func->configure(input, output); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Input shape: " << input->info()->tensor_shape() + << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend reduction operation layer function @@ -1503,23 +1375,18 @@ std::unique_ptr<IFunction> create_reduction_operation_layer(ReductionLayerNode & ARM_COMPUTE_ERROR_ON(output == nullptr); // Create and configure function - auto func = support::cpp14::make_unique<ReductionOperationFunction>(get_memory_manager(ctx, TargetInfo::TargetType)); + auto func = std::make_unique<ReductionOperationFunction>(get_memory_manager(ctx, TargetInfo::TargetType)); func->configure(input, output, axis, op, keep_dims); // Log info ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType + << node.name() << " Type: " << node.type() << " Target: " << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() << " Input shape: " << input->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << " Operation: " << op - << " Axis: " << axis - << " Keep dimensions:" << keep_dims - << std::endl); + << " Output shape: " << output->info()->tensor_shape() << " Operation: " << op + << " Axis: " << axis << " Keep dimensions:" << keep_dims << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend reorg layer function @@ -1543,20 +1410,16 @@ std::unique_ptr<IFunction> create_reorg_layer(ReorgLayerNode &node) ARM_COMPUTE_ERROR_ON(output == nullptr); // Create and configure function - auto func = support::cpp14::make_unique<ReorgLayerFunction>(); + auto func = std::make_unique<ReorgLayerFunction>(); func->configure(input, output, node.stride()); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Input shape: " << input->info()->tensor_shape() + << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend reshape layer function @@ -1580,20 +1443,16 @@ std::unique_ptr<IFunction> create_reshape_layer(ReshapeLayerNode &node) ARM_COMPUTE_ERROR_ON(output == nullptr); // Create and configure function - auto func = support::cpp14::make_unique<ReshapeLayerFunction>(); + auto func = std::make_unique<ReshapeLayerFunction>(); func->configure(input, output); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Input shape: " << input->info()->tensor_shape() + << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend resize layer function @@ -1618,21 +1477,18 @@ std::unique_ptr<IFunction> create_resize_layer(ResizeLayerNode &node) const InterpolationPolicy policy = node.policy(); // Create and configure function - auto func = support::cpp14::make_unique<ResizeLayerFunction>(); - func->configure(input, output, ScaleKernelInfo{ policy, BorderMode::CONSTANT }); + auto func = std::make_unique<ResizeLayerFunction>(); + func->configure(input, output, + ScaleKernelInfo{policy, BorderMode::CONSTANT, PixelValue(), SamplingPolicy::CENTER, false, false}); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << " Interpolation: " << policy - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Input shape: " << input->info()->tensor_shape() + << " Output shape: " << output->info()->tensor_shape() + << " Interpolation: " << policy << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend ROI align layer function @@ -1660,24 +1516,20 @@ std::unique_ptr<IFunction> create_roi_align_layer(ROIAlignLayerNode &node) const ROIPoolingLayerInfo pool_info = node.pooling_info(); // Create and configure function - auto func = support::cpp14::make_unique<ROIAlignLayerFunction>(); + auto func = std::make_unique<ROIAlignLayerFunction>(); func->configure(input, rois, output, pool_info); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << " ROIs shape: " << rois->info()->tensor_shape() - << " ROIPooling width: " << pool_info.pooled_width() - << " ROIPooling height: " << pool_info.pooled_height() - << std::endl); - - return RETURN_UNIQUE_PTR(func); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Input shape: " << input->info()->tensor_shape() + << " Output shape: " << output->info()->tensor_shape() + << " ROIs shape: " << rois->info()->tensor_shape() + << " ROIPooling width: " << pool_info.pooled_width() + << " ROIPooling height: " << pool_info.pooled_height() << std::endl); + + return std::move(func); } /** Create a backend slice layer function @@ -1701,20 +1553,16 @@ std::unique_ptr<IFunction> create_slice_layer(SliceLayerNode &node) ARM_COMPUTE_ERROR_ON(output == nullptr); // Create and configure function - auto func = support::cpp14::make_unique<SliceLayerFunction>(); + auto func = std::make_unique<SliceLayerFunction>(); func->configure(input, output, node.starts(), node.ends()); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Input shape: " << input->info()->tensor_shape() + << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend softmax layer function @@ -1740,20 +1588,16 @@ std::unique_ptr<IFunction> create_softmax_layer(SoftmaxLayerNode &node, GraphCon ARM_COMPUTE_ERROR_ON(output == nullptr); // Create and configure function - auto func = support::cpp14::make_unique<SoftmaxLayerFunction>(get_memory_manager(ctx, TargetInfo::TargetType)); + auto func = std::make_unique<SoftmaxLayerFunction>(get_memory_manager(ctx, TargetInfo::TargetType)); func->configure(input, output, beta); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Input shape: " << input->info()->tensor_shape() + << " Output shape: " << output->info()->tensor_shape() << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend layer stack function @@ -1768,12 +1612,13 @@ std::unique_ptr<IFunction> create_softmax_layer(SoftmaxLayerNode &node, GraphCon template <typename StackLayerFunction, typename TargetInfo> std::unique_ptr<arm_compute::IFunction> create_stack_layer(StackLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Creating Stack node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE("Creating Stack node with ID : " << node.id() << " and Name: " << node.name() + << std::endl); ARM_COMPUTE_ERROR_ON(node.num_outputs() != 1); // Extract IO and info std::vector<typename TargetInfo::TensorType *> inputs; - for(unsigned int i = 0; i < node.num_inputs(); ++i) + for (unsigned int i = 0; i < node.num_inputs(); ++i) { inputs.push_back(get_backing_tensor<TargetInfo>(node.input(i))); } @@ -1781,22 +1626,18 @@ std::unique_ptr<arm_compute::IFunction> create_stack_layer(StackLayerNode &node) const int axis = node.axis(); // Create and configure function - auto func = support::cpp14::make_unique<StackLayerFunction>(); + auto func = std::make_unique<StackLayerFunction>(); func->configure(inputs, axis, output); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << output->info()->data_type() - << " Inputs shape: " << inputs[0]->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << " Num Inputs: " << inputs.size() - << " Axis: " << axis - << std::endl); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() + << " Target: " << TargetInfo::TargetType + << " Data Type: " << output->info()->data_type() + << " Inputs shape: " << inputs[0]->info()->tensor_shape() + << " Output shape: " << output->info()->tensor_shape() + << " Num Inputs: " << inputs.size() << " Axis: " << axis << std::endl); - return RETURN_UNIQUE_PTR(func); + return func; } /** Create a backend slice layer function @@ -1825,112 +1666,20 @@ std::unique_ptr<IFunction> create_strided_slice_layer(StridedSliceLayerNode &nod ARM_COMPUTE_ERROR_ON(output == nullptr); // Create and configure function - auto func = support::cpp14::make_unique<StridedSliceLayerFunction>(); + auto func = std::make_unique<StridedSliceLayerFunction>(); func->configure(input, output, starts, ends, strides, info.begin_mask(), info.end_mask(), info.shrink_axis_mask()); // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << std::endl); - - return RETURN_UNIQUE_PTR(func); -} - -/** Create a backend Upsample layer function - * - * @tparam UpsampleLayerFunction Backend Upsample function - * @tparam TargetInfo Target-specific information - * - * @param[in] node Node to create the backend function for - * @param[in] ctx Graph context - * - * @return Backend Upsample layer function - */ -template <typename UpsampleLayerFunction, typename TargetInfo> -std::unique_ptr<IFunction> create_upsample_layer(UpsampleLayerNode &node, GraphContext &ctx) -{ - ARM_COMPUTE_UNUSED(ctx); - validate_node<TargetInfo>(node, 1 /* expected inputs */, 1 /* expected outputs */); - - // Extract IO and info - typename TargetInfo::TensorType *input = get_backing_tensor<TargetInfo>(node.input(0)); - typename TargetInfo::TensorType *output = get_backing_tensor<TargetInfo>(node.output(0)); - const Size2D info = node.info(); - const InterpolationPolicy upsampling_policy = node.upsampling_policy(); - ARM_COMPUTE_ERROR_ON(upsampling_policy != InterpolationPolicy::NEAREST_NEIGHBOR); - ARM_COMPUTE_ERROR_ON(info.x() != 2 || info.y() != 2); - ARM_COMPUTE_ERROR_ON(input == nullptr); - ARM_COMPUTE_ERROR_ON(output == nullptr); - - // Create and configure function - auto func = support::cpp14::make_unique<UpsampleLayerFunction>(); - func->configure(input, output, info, upsampling_policy); - - // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << " Strides: " << info - << " Upsampling policy: " << upsampling_policy - << std::endl); - - return RETURN_UNIQUE_PTR(func); -} -/** Create a backend YOLO layer function - * - * @tparam YoloLayerFunction Backend YOLO function - * @tparam TargetInfo Target-specific information - * - * @param[in] node Node to create the backend function for - * @param[in] ctx Graph context - * - * @return Backend YOLO layer function - */ -template <typename YOLOlayerFunction, typename TargetInfo> -std::unique_ptr<IFunction> create_yolo_layer(YOLOLayerNode &node, GraphContext &ctx) -{ - ARM_COMPUTE_UNUSED(ctx); - validate_node<TargetInfo>(node, 1 /* expected inputs */, 1 /* expected outputs */); + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " << node.name() << " Type: " << node.type() << " Target: " + << TargetInfo::TargetType << " Data Type: " << input->info()->data_type() + << " Input shape: " << input->info()->tensor_shape() + << " Output shape: " << output->info()->tensor_shape() << std::endl); - // Extract IO and info - typename TargetInfo::TensorType *input = get_backing_tensor<TargetInfo>(node.input(0)); - typename TargetInfo::TensorType *output = get_backing_tensor<TargetInfo>(node.output(0)); - const ActivationLayerInfo act_info = node.activation_info(); - const int32_t num_classes = node.num_classes(); - ARM_COMPUTE_ERROR_ON(num_classes <= 0); - ARM_COMPUTE_ERROR_ON(input == nullptr); - ARM_COMPUTE_ERROR_ON(output == nullptr); - - // Create and configure function - auto func = support::cpp14::make_unique<YOLOlayerFunction>(); - func->configure(input, output, act_info, num_classes); - - // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << " Activation function: " << act_info.activation() - << " Num classes: " << num_classes - << std::endl); - - return RETURN_UNIQUE_PTR(func); + return func; } } // namespace detail } // namespace backends } // namespace graph } // namespace arm_compute -#endif /* ARM_COMPUTE_GRAPH_BACKENDS_DETAIL_FUNCTION_HELPERS_H */ +#endif // ACL_ARM_COMPUTE_GRAPH_BACKENDS_FUNCTIONHELPERS_H diff --git a/arm_compute/graph/backends/FusedConvolutionBatchNormalizationFunction.h b/arm_compute/graph/backends/FusedConvolutionBatchNormalizationFunction.h index ec03bcc952..27e21cbc7e 100644 --- a/arm_compute/graph/backends/FusedConvolutionBatchNormalizationFunction.h +++ b/arm_compute/graph/backends/FusedConvolutionBatchNormalizationFunction.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Arm Limited. + * Copyright (c) 2019, 2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -22,11 +22,12 @@ * SOFTWARE. */ -#ifndef ARM_COMPUTE_GRAPH_BACKENDS_FUSED_CONVOLUTION_BATCH_NORMAZLIZATION_FUNCTION_H -#define ARM_COMPUTE_GRAPH_BACKENDS_FUSED_CONVOLUTION_BATCH_NORMAZLIZATION_FUNCTION_H +#ifndef ACL_ARM_COMPUTE_GRAPH_BACKENDS_FUSEDCONVOLUTIONBATCHNORMALIZATIONFUNCTION_H +#define ACL_ARM_COMPUTE_GRAPH_BACKENDS_FUSEDCONVOLUTIONBATCHNORMALIZATIONFUNCTION_H #include "arm_compute/core/Types.h" #include "arm_compute/runtime/IFunction.h" +#include "arm_compute/runtime/IMemoryManager.h" namespace arm_compute { @@ -69,15 +70,19 @@ public: * @param[in] fused_act Activation layer information in case of a fused activation. * */ - void configure(TensorType *input, - TensorType *weights, - TensorType *bias, - TensorType *output, - const TensorType *mean, - const TensorType *var, - const TensorType *beta, - const TensorType *gamma, - float epsilon, const PadStrideInfo &conv_info, unsigned int num_groups, bool fast_math, ActivationLayerInfo const &fused_act) + void configure(TensorType *input, + TensorType *weights, + TensorType *bias, + TensorType *output, + const TensorType *mean, + const TensorType *var, + const TensorType *beta, + const TensorType *gamma, + float epsilon, + const PadStrideInfo &conv_info, + unsigned int num_groups, + bool fast_math, + ActivationLayerInfo const &fused_act) { // We don't run any validate, as we assume that the layers have been already validated const bool has_bias = (bias != nullptr); @@ -85,7 +90,7 @@ public: // We check if the layer has a bias. If yes, use it in-place. If not, we need to create one // as batch normalization might end up with a bias != 0 - if(has_bias) + if (has_bias) { _fused_batch_norm_layer.configure(weights, mean, var, nullptr, nullptr, bias, beta, gamma, epsilon); bias_to_use = bias; @@ -96,9 +101,10 @@ public: bias_to_use = &_fused_bias; } - _conv_layer.configure(input, weights, bias_to_use, output, conv_info, WeightsInfo(), Size2D(1U, 1U), fused_act, fast_math, num_groups); + _conv_layer.configure(input, weights, bias_to_use, output, conv_info, WeightsInfo(), Size2D(1U, 1U), fused_act, + fast_math, num_groups); - if(!has_bias) + if (!has_bias) { _fused_bias.allocator()->allocate(); } @@ -113,7 +119,7 @@ public: void prepare() { - if(!_is_prepared) + if (!_is_prepared) { _fused_batch_norm_layer.run(); _is_prepared = true; @@ -130,4 +136,4 @@ private: } // namespace graph } // namespace arm_compute -#endif /* ARM_COMPUTE_GRAPH_BACKENDS_FUSED_CONVOLUTION_BATCH_NORMAZLIZATION_FUNCTION_H */ +#endif // ACL_ARM_COMPUTE_GRAPH_BACKENDS_FUSEDCONVOLUTIONBATCHNORMALIZATIONFUNCTION_H diff --git a/arm_compute/graph/backends/FusedDepthwiseConvolutionBatchNormalizationFunction.h b/arm_compute/graph/backends/FusedDepthwiseConvolutionBatchNormalizationFunction.h index 4f8a8da1fb..07a2cdd8b8 100644 --- a/arm_compute/graph/backends/FusedDepthwiseConvolutionBatchNormalizationFunction.h +++ b/arm_compute/graph/backends/FusedDepthwiseConvolutionBatchNormalizationFunction.h @@ -67,15 +67,18 @@ public: * @param[in] fused_act Activation layer information in case of a fused activation. * */ - void configure(TensorType *input, - TensorType *weights, - TensorType *bias, - TensorType *output, - const TensorType *mean, - const TensorType *var, - const TensorType *beta, - const TensorType *gamma, - float epsilon, const PadStrideInfo &conv_info, unsigned int depth_multiplier, ActivationLayerInfo const &fused_act) + void configure(TensorType *input, + TensorType *weights, + TensorType *bias, + TensorType *output, + const TensorType *mean, + const TensorType *var, + const TensorType *beta, + const TensorType *gamma, + float epsilon, + const PadStrideInfo &conv_info, + unsigned int depth_multiplier, + ActivationLayerInfo const &fused_act) { // We don't run any validate, as we assume that the layers have been already validated const bool has_bias = (bias != nullptr); @@ -83,20 +86,23 @@ public: // We check if the layer has a bias. If yes, use it in-place. If not, we need to create one // as batch normalization might end up with a bias != 0 - if(has_bias) + if (has_bias) { - _fused_batch_norm_layer.configure(weights, mean, var, nullptr, nullptr, bias, beta, gamma, epsilon, FuseBatchNormalizationType::DEPTHWISECONVOLUTION); + _fused_batch_norm_layer.configure(weights, mean, var, nullptr, nullptr, bias, beta, gamma, epsilon, + FuseBatchNormalizationType::DEPTHWISECONVOLUTION); bias_to_use = bias; } else { - _fused_batch_norm_layer.configure(weights, mean, var, nullptr, &_fused_bias, nullptr, beta, gamma, epsilon, FuseBatchNormalizationType::DEPTHWISECONVOLUTION); + _fused_batch_norm_layer.configure(weights, mean, var, nullptr, &_fused_bias, nullptr, beta, gamma, epsilon, + FuseBatchNormalizationType::DEPTHWISECONVOLUTION); bias_to_use = &_fused_bias; } - _depth_conv_layer.configure(input, weights, bias_to_use, output, conv_info, depth_multiplier, fused_act.enabled() ? fused_act : ActivationLayerInfo()); + _depth_conv_layer.configure(input, weights, bias_to_use, output, conv_info, depth_multiplier, + fused_act.enabled() ? fused_act : ActivationLayerInfo()); - if(!has_bias) + if (!has_bias) { _fused_bias.allocator()->allocate(); } @@ -111,7 +117,7 @@ public: void prepare() { - if(!_is_prepared) + if (!_is_prepared) { _fused_batch_norm_layer.run(); _is_prepared = true; diff --git a/arm_compute/graph/backends/GLES/GCDeviceBackend.h b/arm_compute/graph/backends/GLES/GCDeviceBackend.h deleted file mode 100644 index 41805cdbfa..0000000000 --- a/arm_compute/graph/backends/GLES/GCDeviceBackend.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2018-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_GRAPH_GCDEVICEBACKEND_H -#define ARM_COMPUTE_GRAPH_GCDEVICEBACKEND_H - -#include "arm_compute/graph/IDeviceBackend.h" - -#include "arm_compute/runtime/GLES_COMPUTE/GCBufferAllocator.h" - -namespace arm_compute -{ -namespace graph -{ -namespace backends -{ -/** GLES Compute device backend */ -class GCDeviceBackend final : public IDeviceBackend -{ -public: - /** Default Constructor */ - GCDeviceBackend(); - - // Inherited overridden methods - void initialize_backend() override; - void setup_backend_context(GraphContext &ctx) override; - void release_backend_context(GraphContext &ctx) override; - bool is_backend_supported() override; - IAllocator *backend_allocator() override; - std::unique_ptr<ITensorHandle> create_tensor(const Tensor &tensor) override; - std::unique_ptr<ITensorHandle> create_subtensor(ITensorHandle *parent, TensorShape shape, Coordinates coords, bool extend_parent) override; - std::unique_ptr<arm_compute::IFunction> configure_node(INode &node, GraphContext &ctx) override; - Status validate_node(INode &node) override; - std::shared_ptr<arm_compute::IMemoryManager> create_memory_manager(MemoryManagerAffinity affinity) override; - std::shared_ptr<arm_compute::IWeightsManager> create_weights_manager() override; - -private: - bool _initialized; /**< Flag that specifies if the backend has been default initialized */ - GCBufferAllocator _allocator; /**< GLES buffer affinity allocator */ -}; -} // namespace backends -} // namespace graph -} // namespace arm_compute -#endif //ARM_COMPUTE_GRAPH_GCDEVICEBACKEND_H diff --git a/arm_compute/graph/backends/GLES/GCFunctionFactory.h b/arm_compute/graph/backends/GLES/GCFunctionFactory.h deleted file mode 100644 index e5c00e5b29..0000000000 --- a/arm_compute/graph/backends/GLES/GCFunctionFactory.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2018-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_GRAPH_GCFUNCTIONFACTORY_H -#define ARM_COMPUTE_GRAPH_GCFUNCTIONFACTORY_H - -#include "arm_compute/runtime/IFunction.h" - -#include <memory> - -namespace arm_compute -{ -namespace graph -{ -// Forward declarations -class INode; -class GraphContext; - -namespace backends -{ -/** Factory for generating GLES compute backend functions **/ -class GCFunctionFactory final -{ -public: - /** Create a backend execution function depending on the node type - * - * @param[in] node Node to create the backend function for - * @param[in] ctx Context to use - * - * @return Backend function - */ - static std::unique_ptr<arm_compute::IFunction> create(INode *node, GraphContext &ctx); -}; -} // namespace backends -} // namespace graph -} // namespace arm_compute -#endif //ARM_COMPUTE_GRAPH_GCFUNCTIONFACTORY_H diff --git a/arm_compute/graph/backends/GLES/GCNodeValidator.h b/arm_compute/graph/backends/GLES/GCNodeValidator.h deleted file mode 100644 index ab3864acf7..0000000000 --- a/arm_compute/graph/backends/GLES/GCNodeValidator.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2018-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_GRAPH_GCNODEVALIDATOR_H -#define ARM_COMPUTE_GRAPH_GCNODEVALIDATOR_H - -#include "arm_compute/core/Error.h" - -namespace arm_compute -{ -namespace graph -{ -// Forward declarations -class INode; - -namespace backends -{ -class GCNodeValidator final -{ -public: - /** Validate a node - * - * @param[in] node Node to validate - * - * @return An error status - */ - static Status validate(INode *node); -}; -} // namespace backends -} // namespace graph -} // namespace arm_compute -#endif //ARM_COMPUTE_GRAPH_GCNODEVALIDATOR_H diff --git a/arm_compute/graph/backends/GLES/GCTensorHandle.h b/arm_compute/graph/backends/GLES/GCTensorHandle.h deleted file mode 100644 index bf4897a3b9..0000000000 --- a/arm_compute/graph/backends/GLES/GCTensorHandle.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2018-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_GRAPH_GCTENSORHANDLE_H -#define ARM_COMPUTE_GRAPH_GCTENSORHANDLE_H - -#include "arm_compute/graph/ITensorHandle.h" - -#include "arm_compute/runtime/GLES_COMPUTE/GCTensor.h" - -namespace arm_compute -{ -namespace graph -{ -namespace backends -{ -/** GLES compute tensor handle interface object **/ -class GCTensorHandle final : public ITensorHandle -{ -public: - /** Default Constructor - * - * @param[in] info Tensor metadata - */ - GCTensorHandle(const ITensorInfo &info); - /** Destructor: free the tensor's memory */ - ~GCTensorHandle() = default; - /** Allow instances of this class to be move constructed */ - GCTensorHandle(GCTensorHandle &&) = default; - /** Allow instances of this class to be moved */ - GCTensorHandle &operator=(GCTensorHandle &&) = default; - - // Inherited overridden methods - void allocate() override; - void free() override; - void manage(IMemoryGroup *mg) override; - void map(bool blocking) override; - void unmap() override; - void release_if_unused() override; - arm_compute::ITensor &tensor() override; - const arm_compute::ITensor &tensor() const override; - ITensorHandle *parent_handle() override; - bool is_subtensor() const override; - Target target() const override; - -private: - arm_compute::GCTensor _tensor; /**< Backend Tensor */ -}; -} // namespace backends -} // namespace graph -} // namespace arm_compute -#endif /* ARM_COMPUTE_GRAPH_GCTENSORHANDLE_H */ diff --git a/arm_compute/graph/backends/NEON/NEDeviceBackend.h b/arm_compute/graph/backends/NEON/NEDeviceBackend.h index d0c8c27203..cd817a20d8 100644 --- a/arm_compute/graph/backends/NEON/NEDeviceBackend.h +++ b/arm_compute/graph/backends/NEON/NEDeviceBackend.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 Arm Limited. + * Copyright (c) 2018-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -25,7 +25,6 @@ #define ARM_COMPUTE_GRAPH_NEDEVICEBACKEND_H #include "arm_compute/graph/IDeviceBackend.h" - #include "arm_compute/runtime/Allocator.h" namespace arm_compute @@ -34,27 +33,29 @@ namespace graph { namespace backends { -/** NEON device backend */ +/** CPU device backend */ class NEDeviceBackend final : public IDeviceBackend { public: NEDeviceBackend(); // Inherited overridden methods - void initialize_backend() override; - void setup_backend_context(GraphContext &ctx) override; - void release_backend_context(GraphContext &ctx) override; + void initialize_backend() override; + void setup_backend_context(GraphContext &ctx) override; + void release_backend_context(GraphContext &ctx) override; bool is_backend_supported() override; IAllocator *backend_allocator() override; std::unique_ptr<ITensorHandle> create_tensor(const Tensor &tensor) override; - std::unique_ptr<ITensorHandle> create_subtensor(ITensorHandle *parent, TensorShape shape, Coordinates coords, bool extend_parent) override; - std::unique_ptr<arm_compute::IFunction> configure_node(INode &node, GraphContext &ctx) override; - Status validate_node(INode &node) override; - std::shared_ptr<arm_compute::IMemoryManager> create_memory_manager(MemoryManagerAffinity affinity) override; + std::unique_ptr<ITensorHandle> + create_subtensor(ITensorHandle *parent, TensorShape shape, Coordinates coords, bool extend_parent) override; + std::unique_ptr<arm_compute::IFunction> configure_node(INode &node, GraphContext &ctx) override; + Status validate_node(INode &node) override; + std::shared_ptr<arm_compute::IMemoryManager> create_memory_manager(MemoryManagerAffinity affinity) override; std::shared_ptr<arm_compute::IWeightsManager> create_weights_manager() override; + void sync() override; private: - Allocator _allocator; /**< NEON backend allocator */ + Allocator _allocator; /**< Backend allocator */ }; } // namespace backends } // namespace graph diff --git a/arm_compute/graph/backends/NEON/NEFunctionFactory.h b/arm_compute/graph/backends/NEON/NEFunctionFactory.h index 5d0e175fb0..6365b71f32 100644 --- a/arm_compute/graph/backends/NEON/NEFunctionFactory.h +++ b/arm_compute/graph/backends/NEON/NEFunctionFactory.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 Arm Limited. + * Copyright (c) 2018-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -38,7 +38,7 @@ class GraphContext; namespace backends { -/** Factory for generating NEON backend functions **/ +/** Factory for generating CPU backend functions **/ class NEFunctionFactory final { public: diff --git a/arm_compute/graph/backends/NEON/NESubTensorHandle.h b/arm_compute/graph/backends/NEON/NESubTensorHandle.h index 259be7822c..3619f4ed1b 100644 --- a/arm_compute/graph/backends/NEON/NESubTensorHandle.h +++ b/arm_compute/graph/backends/NEON/NESubTensorHandle.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 Arm Limited. + * Copyright (c) 2018-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -25,7 +25,6 @@ #define ARM_COMPUTE_GRAPH_NESUBTENSORHANDLE_H #include "arm_compute/graph/ITensorHandle.h" - #include "arm_compute/runtime/SubTensor.h" namespace arm_compute @@ -34,7 +33,7 @@ namespace graph { namespace backends { -/** NEON Sub-Tensor handle interface object **/ +/** CPU Sub-Tensor handle interface object **/ class NESubTensorHandle final : public ITensorHandle { public: @@ -45,7 +44,10 @@ public: * @param[in] coords Starting coordinates * @param[in] extend_parent Extends parent shape if true */ - NESubTensorHandle(ITensorHandle *parent_handle, const TensorShape &shape, const Coordinates &coords, bool extend_parent = false); + NESubTensorHandle(ITensorHandle *parent_handle, + const TensorShape &shape, + const Coordinates &coords, + bool extend_parent = false); /** Destructor: free the tensor's memory */ ~NESubTensorHandle() = default; /** Allow instances of this class to be move constructed */ @@ -58,10 +60,10 @@ public: NESubTensorHandle &operator=(const NESubTensorHandle &) = delete; // Inherited overridden methods - void allocate() override; - void free() override; - void manage(IMemoryGroup *mg) override; - void map(bool blocking) override; + void allocate() override; + void free() override; + void manage(IMemoryGroup *mg) override; + void map(bool blocking) override; void unmap() override; void release_if_unused() override; arm_compute::ITensor &tensor() override; diff --git a/arm_compute/graph/backends/NEON/NETensorHandle.h b/arm_compute/graph/backends/NEON/NETensorHandle.h index 86aba302a5..1df90822ba 100644 --- a/arm_compute/graph/backends/NEON/NETensorHandle.h +++ b/arm_compute/graph/backends/NEON/NETensorHandle.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 Arm Limited. + * Copyright (c) 2018-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -25,7 +25,6 @@ #define ARM_COMPUTE_GRAPH_NETENSORHANDLE_H #include "arm_compute/graph/ITensorHandle.h" - #include "arm_compute/runtime/Tensor.h" namespace arm_compute @@ -34,7 +33,7 @@ namespace graph { namespace backends { -/** NEON Tensor handle interface object **/ +/** CPU Tensor handle interface object **/ class NETensorHandle final : public ITensorHandle { public: @@ -51,10 +50,10 @@ public: NETensorHandle &operator=(NETensorHandle &&) = default; // Inherited overridden methods - void allocate() override; - void free() override; - void manage(IMemoryGroup *mg) override; - void map(bool blocking) override; + void allocate() override; + void free() override; + void manage(IMemoryGroup *mg) override; + void map(bool blocking) override; void unmap() override; void release_if_unused() override; arm_compute::ITensor &tensor() override; diff --git a/arm_compute/graph/backends/Utils.h b/arm_compute/graph/backends/Utils.h index 7d67f3b9e3..5f4e66c207 100644 --- a/arm_compute/graph/backends/Utils.h +++ b/arm_compute/graph/backends/Utils.h @@ -42,9 +42,10 @@ namespace backends * @return A configured backend function */ template <typename FunctionType, typename FunctionNameType, typename... ParameterType> -std::tuple<std::unique_ptr<arm_compute::IFunction>, FunctionNameType> create_named_function(FunctionNameType name, ParameterType... args) +std::tuple<std::unique_ptr<arm_compute::IFunction>, FunctionNameType> create_named_function(FunctionNameType name, + ParameterType... args) { - auto f = arm_compute::support::cpp14::make_unique<FunctionType>(); + auto f = std::make_unique<FunctionType>(); f->configure(std::forward<ParameterType>(args)...); return std::make_pair(std::move(f), name); } @@ -58,11 +59,10 @@ std::tuple<std::unique_ptr<arm_compute::IFunction>, FunctionNameType> create_nam * @return A configured backend function */ template <typename FunctionType, typename FunctionNameType, typename MemoryManagerType, typename... ParameterType> -std::tuple<std::unique_ptr<arm_compute::IFunction>, FunctionNameType> create_named_memory_managed_function(FunctionNameType name, - MemoryManagerType mm, - ParameterType... args) +std::tuple<std::unique_ptr<arm_compute::IFunction>, FunctionNameType> +create_named_memory_managed_function(FunctionNameType name, MemoryManagerType mm, ParameterType... args) { - auto f = arm_compute::support::cpp14::make_unique<FunctionType>(mm); + auto f = std::make_unique<FunctionType>(mm); f->configure(std::forward<ParameterType>(args)...); return std::make_pair(std::move(f), name); } diff --git a/arm_compute/graph/backends/ValidateHelpers.h b/arm_compute/graph/backends/ValidateHelpers.h index dd519fbd5e..0e102942a7 100644 --- a/arm_compute/graph/backends/ValidateHelpers.h +++ b/arm_compute/graph/backends/ValidateHelpers.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020 Arm Limited. + * Copyright (c) 2018-2021, 2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -21,17 +21,16 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef ARM_COMPUTE_GRAPH_BACKENDS_DETAIL_VALIDATE_HELPERS_H -#define ARM_COMPUTE_GRAPH_BACKENDS_DETAIL_VALIDATE_HELPERS_H - -#include "arm_compute/graph/Logger.h" -#include "arm_compute/graph/Tensor.h" -#include "arm_compute/graph/Types.h" -#include "arm_compute/graph/nodes/Nodes.h" +#ifndef ACL_ARM_COMPUTE_GRAPH_BACKENDS_VALIDATEHELPERS_H +#define ACL_ARM_COMPUTE_GRAPH_BACKENDS_VALIDATEHELPERS_H #include "arm_compute/core/Error.h" #include "arm_compute/core/Helpers.h" #include "arm_compute/core/ITensorInfo.h" +#include "arm_compute/graph/Logger.h" +#include "arm_compute/graph/nodes/Nodes.h" +#include "arm_compute/graph/Tensor.h" +#include "arm_compute/graph/Types.h" namespace arm_compute { @@ -63,7 +62,8 @@ inline arm_compute::ITensorInfo *get_backing_tensor_info(arm_compute::graph::Ten template <typename ArgMinMaxLayer> Status validate_arg_min_max_layer(ArgMinMaxLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating ArgMinMaxLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE( + "Validating ArgMinMaxLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); @@ -86,7 +86,8 @@ Status validate_arg_min_max_layer(ArgMinMaxLayerNode &node) template <typename BoundingBoxTransformLayer> Status validate_bounding_box_transform_layer(BoundingBoxTransformLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating BoundingBoxTransformLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating BoundingBoxTransformLayer node with ID : " << node.id() << " and Name: " + << node.name() << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 2); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); @@ -110,7 +111,8 @@ Status validate_bounding_box_transform_layer(BoundingBoxTransformLayerNode &node template <typename ChannelShuffleLayer> Status validate_channel_shuffle_layer(ChannelShuffleLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating ChannelShuffle node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE( + "Validating ChannelShuffle node with ID : " << node.id() << " and Name: " << node.name() << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); @@ -133,10 +135,14 @@ Status validate_channel_shuffle_layer(ChannelShuffleLayerNode &node) * * @return Status */ -template <typename ConvolutionLayer, typename DirectConvolutionLayer, typename GEMMConvolutionLayer, typename WinogradConvolutionLayer> +template <typename ConvolutionLayer, + typename DirectConvolutionLayer, + typename GEMMConvolutionLayer, + typename WinogradConvolutionLayer> Status validate_convolution_layer(ConvolutionLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating ConvolutionLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE( + "Validating ConvolutionLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 3); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); @@ -146,7 +152,7 @@ Status validate_convolution_layer(ConvolutionLayerNode &node) arm_compute::ITensorInfo *biases = get_backing_tensor_info(node.input(2)); arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); - if(is_data_type_quantized_asymmetric(input->data_type())) + if (is_data_type_quantized_asymmetric(input->data_type())) { biases->set_data_type(DataType::S32); } @@ -158,23 +164,24 @@ Status validate_convolution_layer(ConvolutionLayerNode &node) // Validate function Status status{}; - switch(conv_algorithm) + switch (conv_algorithm) { case ConvolutionMethod::Direct: ARM_COMPUTE_RETURN_ERROR_ON_MSG(num_groups != 1, "DirectConvolutionLayer does not support grouping!"); status = DirectConvolutionLayer::validate(input, weights, biases, output, conv_info); break; case ConvolutionMethod::GEMM: - status = GEMMConvolutionLayer::validate(input, weights, biases, output, conv_info, - WeightsInfo(), Size2D(1, 1), ActivationLayerInfo(), num_groups); + status = GEMMConvolutionLayer::validate(input, weights, biases, output, conv_info, WeightsInfo(), + Size2D(1, 1), ActivationLayerInfo(), num_groups); break; case ConvolutionMethod::Winograd: ARM_COMPUTE_RETURN_ERROR_ON_MSG(num_groups != 1, "WinogradConvolutionLayer does not support grouping!"); - status = WinogradConvolutionLayer::validate(input, weights, biases, output, conv_info, ActivationLayerInfo(), fast_math); + status = WinogradConvolutionLayer::validate(input, weights, biases, output, conv_info, + ActivationLayerInfo(), fast_math); break; case ConvolutionMethod::Default: - status = ConvolutionLayer::validate(input, weights, biases, output, conv_info, - WeightsInfo(), Size2D(1, 1), ActivationLayerInfo(), fast_math, num_groups); + status = ConvolutionLayer::validate(input, weights, biases, output, conv_info, WeightsInfo(), Size2D(1, 1), + ActivationLayerInfo(), fast_math, num_groups); break; default: ARM_COMPUTE_RETURN_ERROR_MSG("Unsupported convolution method"); @@ -194,7 +201,8 @@ Status validate_convolution_layer(ConvolutionLayerNode &node) template <typename DepthwiseConvolutionLayer> Status validate_depthwise_convolution_layer(DepthwiseConvolutionLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating DepthwiseConvolutionLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating DepthwiseConvolutionLayer node with ID : " << node.id() << " and Name: " + << node.name() << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 3); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); @@ -210,7 +218,7 @@ Status validate_depthwise_convolution_layer(DepthwiseConvolutionLayerNode &node) // Validate function Status status{}; - switch(dwc_algorithm) + switch (dwc_algorithm) { case DepthwiseConvolutionMethod::Default: case DepthwiseConvolutionMethod::Optimized3x3: @@ -233,7 +241,8 @@ Status validate_depthwise_convolution_layer(DepthwiseConvolutionLayerNode &node) template <typename DepthToSpaceLayer> Status validate_depth_to_space_layer(DepthToSpaceLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating DetectionOutputLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE( + "Validating DetectionOutputLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); @@ -254,7 +263,8 @@ Status validate_depth_to_space_layer(DepthToSpaceLayerNode &node) template <typename DequantizationLayer> Status validate_dequantization_layer(DequantizationLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating DetectionOutputLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE( + "Validating DetectionOutputLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); @@ -275,7 +285,8 @@ Status validate_dequantization_layer(DequantizationLayerNode &node) template <typename DetectionOutputLayer> Status validate_detection_output_layer(DetectionOutputLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating DetectionOutputLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE( + "Validating DetectionOutputLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 3); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); @@ -299,7 +310,8 @@ Status validate_detection_output_layer(DetectionOutputLayerNode &node) template <typename DetectionPostProcessLayer> Status validate_detection_post_process_layer(DetectionPostProcessLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating DetectionPostProcessLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating DetectionPostProcessLayer node with ID : " << node.id() << " and Name: " + << node.name() << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 3); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 4); @@ -327,7 +339,8 @@ Status validate_detection_post_process_layer(DetectionPostProcessLayerNode &node template <typename GenerateProposalsLayer> Status validate_generate_proposals_layer(GenerateProposalsLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating GenerateProposalsLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE( + "Validating GenerateProposalsLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 3); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 3); @@ -354,7 +367,8 @@ Status validate_generate_proposals_layer(GenerateProposalsLayerNode &node) template <typename L2NormalizeLayer> Status validate_l2_normalize_layer(L2NormalizeLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating L2NormalizeLayerNode node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE( + "Validating L2NormalizeLayerNode node with ID : " << node.id() << " and Name: " << node.name() << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); @@ -379,7 +393,8 @@ Status validate_l2_normalize_layer(L2NormalizeLayerNode &node) template <typename NormalizePlanarYUVLayer> Status validate_normalize_planar_yuv_layer(NormalizePlanarYUVLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating NormalizePlanarYUVLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE( + "Validating NormalizePlanarYUVLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 3); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); @@ -404,7 +419,8 @@ Status validate_normalize_planar_yuv_layer(NormalizePlanarYUVLayerNode &node) template <typename PadLayer> Status validate_pad_layer(PadLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating PadLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating PadLayer node with ID : " << node.id() << " and Name: " << node.name() + << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); @@ -427,14 +443,15 @@ Status validate_pad_layer(PadLayerNode &node) template <typename PermuteLayer> Status validate_permute_layer(PermuteLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating PermuteLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating PermuteLayer node with ID : " << node.id() << " and Name: " << node.name() + << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); // Extract IO and info arm_compute::ITensorInfo *input = get_backing_tensor_info(node.input(0)); arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); - const PermutationVector &perm = node.permutation_vector(); + const PermutationVector &perm = node.permutation_vector(); return PermuteLayer::validate(input, output, perm); } @@ -450,7 +467,8 @@ Status validate_permute_layer(PermuteLayerNode &node) template <typename PReluLayer> Status validate_prelu_layer(PReluLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating PRelu node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating PRelu node with ID : " << node.id() << " and Name: " << node.name() + << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 2); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); @@ -473,7 +491,8 @@ Status validate_prelu_layer(PReluLayerNode &node) template <typename PriorBoxLayer> Status validate_priorbox_layer(PriorBoxLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating PriorBoxLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE( + "Validating PriorBoxLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 2); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); @@ -497,7 +516,8 @@ Status validate_priorbox_layer(PriorBoxLayerNode &node) template <typename QuantizationLayer> Status validate_quantization_layer(QuantizationLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating QuantizationLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE( + "Validating QuantizationLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); @@ -520,7 +540,8 @@ Status validate_quantization_layer(QuantizationLayerNode &node) template <typename ReductionLayer> Status validate_reduction_operation_layer(ReductionLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating ReductionLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE( + "Validating ReductionLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); @@ -544,7 +565,8 @@ Status validate_reduction_operation_layer(ReductionLayerNode &node) template <typename ReorgLayer> Status validate_reorg_layer(ReorgLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating ReorgLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating ReorgLayer node with ID : " << node.id() << " and Name: " << node.name() + << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); @@ -567,7 +589,8 @@ Status validate_reorg_layer(ReorgLayerNode &node) template <typename ReshapeLayer> Status validate_reshape_layer(ReshapeLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating ReshapeLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating ReshapeLayer node with ID : " << node.id() << " and Name: " << node.name() + << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); @@ -590,14 +613,15 @@ Status validate_reshape_layer(ReshapeLayerNode &node) template <typename ROIAlignLayer> Status validate_roi_align_layer(ROIAlignLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating ROIAlignLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE( + "Validating ROIAlignLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 2); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); // Extract input and output - arm_compute::ITensorInfo *input = detail::get_backing_tensor_info(node.input(0)); - arm_compute::ITensorInfo *rois = detail::get_backing_tensor_info(node.input(1)); - arm_compute::ITensorInfo *output = detail::get_backing_tensor_info(node.output(0)); + arm_compute::ITensorInfo *input = detail::get_backing_tensor_info(node.input(0)); + arm_compute::ITensorInfo *rois = detail::get_backing_tensor_info(node.input(1)); + arm_compute::ITensorInfo *output = detail::get_backing_tensor_info(node.output(0)); const ROIPoolingLayerInfo &pool_info = node.pooling_info(); // Validate function @@ -615,7 +639,8 @@ Status validate_roi_align_layer(ROIAlignLayerNode &node) template <typename SliceLayer> Status validate_slice_layer(SliceLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating Slice node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating Slice node with ID : " << node.id() << " and Name: " << node.name() + << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); @@ -639,7 +664,8 @@ Status validate_slice_layer(SliceLayerNode &node) template <typename StridedSliceLayer> Status validate_strided_slice_layer(StridedSliceLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating StridedSlice node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating StridedSlice node with ID : " << node.id() << " and Name: " << node.name() + << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); @@ -651,53 +677,10 @@ Status validate_strided_slice_layer(StridedSliceLayerNode &node) const BiStrides strides = node.strides(); const StridedSliceLayerInfo info = node.strided_slice_info(); - return StridedSliceLayer::validate(input, output, starts, ends, strides, info.begin_mask(), info.end_mask(), info.shrink_axis_mask()); + return StridedSliceLayer::validate(input, output, starts, ends, strides, info.begin_mask(), info.end_mask(), + info.shrink_axis_mask()); } -/** Validates a Upsample layer node - * - * @tparam UpsampleLayer Upsample layer type - * - * @param[in] node Node to validate - * - * @return Status - */ -template <typename UpsampleLayer> -Status validate_upsample_layer(UpsampleLayerNode &node) -{ - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating UpsampleLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); - ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); - ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); - - // Extract input and output - arm_compute::ITensorInfo *input = detail::get_backing_tensor_info(node.input(0)); - arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); - - // Validate function - return UpsampleLayer::validate(input, output, node.info(), node.upsampling_policy()); -} -/** Validates a YOLO layer node - * - * @tparam YOLOLayer YOLO layer type - * - * @param[in] node Node to validate - * - * @return Status - */ -template <typename YOLOLayer> -Status validate_yolo_layer(YOLOLayerNode &node) -{ - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating YOLOLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); - ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); - ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); - - // Extract input and output - arm_compute::ITensorInfo *input = detail::get_backing_tensor_info(node.input(0)); - arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); - - // Validate function - return YOLOLayer::validate(input, output, node.activation_info(), node.num_classes()); -} /** Validates a element-wise layer node * * @param[in] node Node to validate @@ -707,7 +690,8 @@ Status validate_yolo_layer(YOLOLayerNode &node) template <typename EltwiseLayerFunctions> Status validate_eltwise_Layer(EltwiseLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating EltwiseLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating EltwiseLayer node with ID : " << node.id() << " and Name: " << node.name() + << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 2); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); @@ -722,22 +706,27 @@ Status validate_eltwise_Layer(EltwiseLayerNode &node) const QuantizationInfo quant_info = node.output_quant_info(); // Validate function - if(eltwise_op == EltwiseOperation::Add) + if (eltwise_op == EltwiseOperation::Add) { return EltwiseLayerFunctions::ArithmeticAddition::validate(input1, input2, output, convert_policy, act_info); } - else if(eltwise_op == EltwiseOperation::Sub) + else if (eltwise_op == EltwiseOperation::Sub) { return EltwiseLayerFunctions::ArithmeticSubtraction::validate(input1, input2, output, convert_policy, act_info); } - else if(eltwise_op == EltwiseOperation::Mul) + else if (eltwise_op == EltwiseOperation::Mul) { - return EltwiseLayerFunctions::PixelWiseMultiplication::validate(input1, input2, output, 1.0f, convert_policy, round_policy, act_info); + return EltwiseLayerFunctions::PixelWiseMultiplication::validate(input1, input2, output, 1.0f, convert_policy, + round_policy, act_info); } - else if(eltwise_op == EltwiseOperation::Max) + else if (eltwise_op == EltwiseOperation::Max) { return EltwiseLayerFunctions::ElementwiseMax::validate(input1, input2, output, act_info); } + else if (eltwise_op == EltwiseOperation::Div) + { + return EltwiseLayerFunctions::ArithmeticDivision::validate(input1, input2, output, act_info); + } else { ARM_COMPUTE_ERROR("Unsupported element-wise operation!"); @@ -753,7 +742,8 @@ Status validate_eltwise_Layer(EltwiseLayerNode &node) template <typename UnaryEltwiseLayerFunctions> Status validate_unary_eltwise_layer(UnaryEltwiseLayerNode &node) { - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating EltwiseLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating EltwiseLayer node with ID : " << node.id() << " and Name: " << node.name() + << std::endl); ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); @@ -763,7 +753,7 @@ Status validate_unary_eltwise_layer(UnaryEltwiseLayerNode &node) const UnaryEltwiseOperation eltwise_op = node.eltwise_descriptor().op; // Validate function - if(eltwise_op == UnaryEltwiseOperation::Exp) + if (eltwise_op == UnaryEltwiseOperation::Exp) { return UnaryEltwiseLayerFunctions::ExpLayer::validate(input, output); } @@ -779,4 +769,4 @@ Status validate_unary_eltwise_layer(UnaryEltwiseLayerNode &node) } // namespace graph } // namespace arm_compute -#endif /* ARM_COMPUTE_GRAPH_BACKENDS_DETAIL_VALIDATE_HELPERS_H */ +#endif // ACL_ARM_COMPUTE_GRAPH_BACKENDS_VALIDATEHELPERS_H |