From e472082f831815c217677e3f1802ecaae1348e65 Mon Sep 17 00:00:00 2001 From: Michalis Spyrou Date: Mon, 2 Oct 2017 17:44:52 +0100 Subject: COMPMID-549 Create a Logger for GraphAPI Change-Id: If912d8232e12cd496923d55d386898450dac09e2 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/89897 Tested-by: Kaizen Reviewed-by: Anthony Barbier --- arm_compute/core/Logger.h | 71 +++++++++++++++++++++++++++ arm_compute/graph/Graph.h | 6 +-- arm_compute/graph/INode.h | 4 -- arm_compute/graph/nodes/ActivationLayer.h | 1 - arm_compute/graph/nodes/ConvolutionLayer.h | 9 ++-- arm_compute/graph/nodes/FullyConnectedLayer.h | 1 - arm_compute/graph/nodes/NormalizationLayer.h | 1 - arm_compute/graph/nodes/PoolingLayer.h | 1 - arm_compute/graph/nodes/SoftmaxLayer.h | 2 - 9 files changed, 78 insertions(+), 18 deletions(-) create mode 100644 arm_compute/core/Logger.h (limited to 'arm_compute') diff --git a/arm_compute/core/Logger.h b/arm_compute/core/Logger.h new file mode 100644 index 0000000000..0848479d37 --- /dev/null +++ b/arm_compute/core/Logger.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2017 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_LOGGER_H__ +#define __ARM_COMPUTE_LOGGER_H__ + +#include +#include + +#ifdef ARM_COMPUTE_DEBUG_ENABLED +#define ARM_COMPUTE_LOG(x) (arm_compute::Logger::get().log_info() << x) +#else /* ARM_COMPUTE_DEBUG_ENABLED */ +#define ARM_COMPUTE_LOG(...) +#endif /* ARM_COMPUTE_DEBUG_ENABLED */ + +namespace arm_compute +{ +/**< Verbosity of the logger */ +enum class LoggerVerbosity +{ + NONE, /**< No info */ + INFO /**< Log info */ +}; + +/** Logger singleton class */ +class Logger +{ +public: + static Logger &get(); + void set_logger(std::ostream &ostream, LoggerVerbosity verbosity); + std::ostream &log_info(); + +private: + /** Default constructor */ + Logger(); + /** Allow instances of this class to be moved */ + Logger(Logger &&) = default; + /** Prevent instances of this class from being copied (As this class contains pointers) */ + Logger(const Logger &) = delete; + /** Prevent instances of this class from being copied (As this class contains pointers) */ + Logger &operator=(const Logger &) = delete; + /** Allow instances of this class to be moved */ + Logger &operator=(Logger &&) = default; + + std::ostream *_ostream; + std::ostream _nullstream; + LoggerVerbosity _verbosity; +}; +} // arm_compute +#endif /* __ARM_COMPUTE_LOGGER_H__ */ \ No newline at end of file diff --git a/arm_compute/graph/Graph.h b/arm_compute/graph/Graph.h index da41548119..9d06f44bee 100644 --- a/arm_compute/graph/Graph.h +++ b/arm_compute/graph/Graph.h @@ -70,11 +70,7 @@ public: * @param[in] tmp Output info to set */ void set_temp(TensorInfo &&tmp); - /** Sets whether to enable information print out - * - * @param[in] is_enabled Set to true if need info printed out - */ - void set_info_enablement(bool is_enabled); + /** Returns the graph hints that are currently used * * @return Graph hints diff --git a/arm_compute/graph/INode.h b/arm_compute/graph/INode.h index 6ce9b1b986..1b22bdf639 100644 --- a/arm_compute/graph/INode.h +++ b/arm_compute/graph/INode.h @@ -58,8 +58,6 @@ public: */ TargetHint override_target_hint(TargetHint target_hint) const; - virtual void print_info() = 0; - protected: /** Interface to be implement that override the hints * @@ -71,8 +69,6 @@ protected: protected: TargetHint _target_hint{ TargetHint::DONT_CARE }; - ITensor *_input{ nullptr }; - ITensor *_output{ nullptr }; }; } // namespace graph } // namespace arm_compute diff --git a/arm_compute/graph/nodes/ActivationLayer.h b/arm_compute/graph/nodes/ActivationLayer.h index ea32dd02a2..efe8112e77 100644 --- a/arm_compute/graph/nodes/ActivationLayer.h +++ b/arm_compute/graph/nodes/ActivationLayer.h @@ -45,7 +45,6 @@ public: // Inherited methods overriden: std::unique_ptr instantiate_node(GraphContext &ctx, ITensor *input, ITensor *output) override; - void print_info() override; private: const ActivationLayerInfo _activation_info; /**< Activation layer info */ diff --git a/arm_compute/graph/nodes/ConvolutionLayer.h b/arm_compute/graph/nodes/ConvolutionLayer.h index 086bf03dfe..04ba3dd6b7 100644 --- a/arm_compute/graph/nodes/ConvolutionLayer.h +++ b/arm_compute/graph/nodes/ConvolutionLayer.h @@ -78,23 +78,26 @@ public: // Inherited methods overriden: std::unique_ptr instantiate_node(GraphContext &ctx, ITensor *input, ITensor *output) override; - void print_info() override; private: /** Instantiates a non-grouped convolution * + * @param[in] input Input tensor + * @param[in] output Output tensor * @param[in] conv_method_hint Hint that specifies which convolution layer method to use * * @return Convolution function */ - std::unique_ptr instantiate_convolution(ConvolutionMethodHint conv_method_hint); + std::unique_ptr instantiate_convolution(ITensor *input, ITensor *output, ConvolutionMethodHint conv_method_hint); /** Instantiates a grouped convolution * + * @param[in] input Input tensor + * @param[in] output Output tensor * @param[in] conv_method_hint Hint that specifies which convolution layer method to use * * @return Grouped Convolution function */ - std::unique_ptr instantiate_grouped_convolution(ConvolutionMethodHint conv_method_hint); + std::unique_ptr instantiate_grouped_convolution(ITensor *input, ITensor *output, ConvolutionMethodHint conv_method_hint); private: unsigned int _conv_width; /**< Convolution width */ diff --git a/arm_compute/graph/nodes/FullyConnectedLayer.h b/arm_compute/graph/nodes/FullyConnectedLayer.h index b05bc96c99..d31e060457 100644 --- a/arm_compute/graph/nodes/FullyConnectedLayer.h +++ b/arm_compute/graph/nodes/FullyConnectedLayer.h @@ -51,7 +51,6 @@ public: // Inherited methods overriden: std::unique_ptr instantiate_node(GraphContext &ctx, ITensor *input, ITensor *output) override; - void print_info() override; // Inherited methods overriden: private: diff --git a/arm_compute/graph/nodes/NormalizationLayer.h b/arm_compute/graph/nodes/NormalizationLayer.h index 52f67d2c31..02efd1cbeb 100644 --- a/arm_compute/graph/nodes/NormalizationLayer.h +++ b/arm_compute/graph/nodes/NormalizationLayer.h @@ -44,7 +44,6 @@ public: // Inherited methods overriden: std::unique_ptr instantiate_node(GraphContext &ctx, ITensor *input, ITensor *output) override; - void print_info() override; private: const NormalizationLayerInfo _norm_info; /**< Normalization layer information */ diff --git a/arm_compute/graph/nodes/PoolingLayer.h b/arm_compute/graph/nodes/PoolingLayer.h index f07800a7b8..87b15d06cb 100644 --- a/arm_compute/graph/nodes/PoolingLayer.h +++ b/arm_compute/graph/nodes/PoolingLayer.h @@ -45,7 +45,6 @@ public: // Inherited methods overriden: std::unique_ptr instantiate_node(GraphContext &ctx, ITensor *input, ITensor *output) override; - void print_info() override; private: const PoolingLayerInfo _pool_info; /**< Pooling layer information */ diff --git a/arm_compute/graph/nodes/SoftmaxLayer.h b/arm_compute/graph/nodes/SoftmaxLayer.h index 1515a0f28a..2e1bd98c8d 100644 --- a/arm_compute/graph/nodes/SoftmaxLayer.h +++ b/arm_compute/graph/nodes/SoftmaxLayer.h @@ -28,7 +28,6 @@ #include "arm_compute/graph/INode.h" #include "arm_compute/graph/Tensor.h" #include "arm_compute/graph/Types.h" - namespace arm_compute { namespace graph @@ -39,7 +38,6 @@ class SoftmaxLayer : public INode public: // Inherited methods overriden: std::unique_ptr instantiate_node(GraphContext &ctx, ITensor *input, ITensor *output) override; - void print_info() override; }; } // namespace graph -- cgit v1.2.1