24.02.1
|
Go to the documentation of this file.
25 #ifndef ACL_TESTS_VALIDATE_EXAMPLES_GRAPH_VALIDATE_UTILS_H
26 #define ACL_TESTS_VALIDATE_EXAMPLES_GRAPH_VALIDATE_UTILS_H
54 static const std::map<std::string, ConvolutionPaddingMode> modes =
62 #ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED
67 #ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED
69 catch(
const std::out_of_range &)
71 throw std::invalid_argument(value);
99 throw std::invalid_argument(
"Unsupported padding mode format");
239 const std::set<arm_compute::graph::Target> supported_targets
245 const std::set<arm_compute::DataType> supported_data_types
278 common_params.common_params.target =
target->
value();
295 os <<
"Data type : " << common_params.
data_type << std::endl;
336 return std::make_unique<arm_compute::graph_utils::NumPyBinLoader>(
tensor.npy);
340 return std::make_unique<arm_compute::graph_utils::RandomAccessor>(lower, upper, seed);
345 template <
typename D>
454 std::mt19937 gen(seed);
455 std::uniform_int_distribution<uint8_t>
distribution(qasymm8_low, qasymm8_high);
457 for(
int i = 0; i <
tensor.num_elements(); ++i)
473 std::mt19937 gen(seed);
474 std::uniform_int_distribution<int32_t>
distribution(
static_cast<int32_t
>(low),
static_cast<uint32_t
>(high));
476 for(
int i = 0; i <
tensor.num_elements(); ++i)
493 std::mt19937 gen(seed);
494 std::uniform_real_distribution<float>
distribution(low, high);
496 for(
int i = 0; i <
tensor.num_elements(); ++i)
513 std::mt19937 gen(seed);
514 std::uniform_real_distribution<float>
distribution(
static_cast<half>(low),
static_cast<half>(high));
516 for(
int i = 0; i <
tensor.num_elements(); ++i)
557 if(user_relative_tolerance == -1)
562 if(user_absolute_tolerance == -1)
567 if(user_tolerance_num == -1)
588 template <
template <
typename D>
class VerifyAccessorT>
595 return std::make_unique<VerifyAccessorT<uint8_t>>(
600 return std::make_unique<VerifyAccessorT<half>>(
605 return std::make_unique<VerifyAccessorT<float>>(
613 template <
typename LayerT,
typename OptionsT,
template <
typename D>
class VerifyAccessorT>
634 Options.consume_common_parameters(params);
635 Options.consume_parameters(params);
639 parser.print_help(argv[0]);
643 Options.print_parameters(std::cout, params);
681 #endif // ACL_TESTS_VALIDATE_EXAMPLES_GRAPH_VALIDATE_UTILS_H
@ NCHW
Num samples, channels, height, width.
@ Default
Default approach using internal heuristics.
virtual void print_parameters(::std::ostream &os, const ExampleParams &common_params)
Formatted output of the ExampleParams type.
QuantizationInfo quant_info
struct arm_compute::utils::ConvolutionParams::@6 padding
arm_compute::DataLayout data_layout
virtual arm_compute::test::SimpleTensor< D > reference(arm_compute::test::SimpleTensor< D > &src, arm_compute::test::SimpleTensor< D > &weights, arm_compute::test::SimpleTensor< TBias > &bias, const arm_compute::TensorShape &output_shape)=0
Calculate reference tensor.
virtual TensorShape output_shape(ITensor &tensor)
Calculate reference output tensor shape.
SimpleTensor< float > src
int num_threads
Number of threads to use (thread capable backends), if 0 the backend will auto-initialize,...
decltype(strategy::transforms) typedef type
std::string tolower(std::string string)
Convert string to lower case.
void consume_common_parameters(CommonParams &common_params)
@ CL
OpenCL capable target device.
Quantization information.
Class describing the value of a pixel for any image format.
Abstract ValidateExample class.
DataLayout
[DataLayout enum definition]
std::unique_ptr< graph::ITensorAccessor > get_accessor(const TensorParams &tensor, PixelValue lower, PixelValue upper, const std::random_device::result_type seed=0)
Generates appropriate accessor according to the specified graph parameters.
@ QASYMM8
quantized, asymmetric fixed-point 8-bit number unsigned
void do_run() override
Run the example.
PadStrideInfo calculate_same_pad(TensorShape input_shape, TensorShape weights_shape, PadStrideInfo conv_info, DataLayout data_layout=DataLayout::NCHW, const Size2D &dilation=Size2D(1u, 1u), const DimensionRoundingType &rounding_type=DimensionRoundingType::FLOOR)
Calculate padding requirements in case of SAME padding.
@ NEON
Arm® Neon™ capable target device.
uint8_t quantize_qasymm8(float value, const INFO_TYPE &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
Quantize a value given an unsigned 8-bit asymmetric quantization scheme.
constexpr float tolerance_num
Tolerance number.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
EnumOption< arm_compute::DataType > * data_type
Graph data type.
Structure holding all the Convolution layer graph parameters.
Interface for CPU tensor.
ConvolutionPaddingMode padding_mode
Structure holding all the fully_connected layer graph parameters.
bool access_tensor(ITensor &tensor) override
Interface to be implemented to access a given tensor.
Accessor implementation for Tensor objects.
inline ::std::istream & operator>>(::std::istream &stream, ConvolutionPaddingMode &Mode)
Stream Input operator for the ConvolutionPaddingMode type.
void fill_tensor(arm_compute::test::SimpleTensor< float > &tensor, std::random_device::result_type seed, float low, float high)
Fill F32 tensor with Random values.
bool do_setup(int argc, char **argv) override
Setup the example.
arm_compute::DataType data_type
Graph configuration structure.
SimpleOption< float > * relative_tolerance
Relative tolerance used in verification.
Fully connected layer info.
validate(CLAccessor(output_state), expected_output)
int padding_top
Padding graph parameters.
half_float::half half
16-bit floating point type
virtual LayerT GraphFunctionLayer(ExampleParams ¶ms)=0
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Class to parse command line arguments.
CommonGraphValidateOptions & operator=(const CommonGraphValidateOptions &)=delete
Prevent instances of this class from being copied (As this class contains pointers)
std::unique_ptr< graph::ITensorAccessor > get_verify_accessor(ExampleParams params)
Generates appropriate convolution verify accessor.
virtual float relative_tolerance()=0
Select relative tolerance.
TensorShape permute_shape(TensorShape tensor_shape, DataLayout in_data_layout, DataLayout out_data_layout)
Permutes a given tensor shape given the input and output data layout.
Structure holding all the graph Example parameters.
CommonGraphValidateOptions command line options used to configure the graph examples.
Implementation of an option that can be either true or false.
SimpleOption< float > * absolute_tolerance
Absolute tolerance used in verification.
Structure holding all the input tensor graph parameters.
VerifyAccessor(ExampleParams ¶ms)
Constructor.
Structure holding all the common graph parameters.
VerificationParams verification
Structure holding all the graph Example parameters.
void consume_common_graph_parameters(CommonGraphValidateOptions &options, CommonParams &common_params)
Consumes the consume_common_graph_parameters graph options and creates a structure containing any inf...
bool is_set() const
Has a value been assigned to the option?
SimpleOption< float > * tolerance_number
Tolerance number used in verification.
const T & value() const
Get the selected value.
SimpleOption< int > * threads
Number of threads option.
ToggleOption * help
show help message
typename std::conditional< std::is_same< typename std::decay< D >::type, uint8_t >::value, int32_t, D >::type TBias
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
FullyConnectedLayerInfo info
CLTensor * tensor
Pointer to the auxiliary tensor.
virtual void create_tensors(arm_compute::test::SimpleTensor< D > &src, arm_compute::test::SimpleTensor< D > &weights, arm_compute::test::SimpleTensor< TBias > &bias, ITensor &tensor)
Create reference tensors.
ConvolutionPaddingMode mode
void set_help(std::string help)
Set the help message for the option.
TensorShape input_shape
Validate test suite is to test ARM_COMPUTE_RETURN_ON_* macros we use to check the validity of given a...
arm_compute::graph::DepthwiseConvolutionMethod depth_convolution_method
void fill_tensor(arm_compute::test::SimpleTensor< uint8_t > &tensor, std::random_device::result_type seed, uint8_t low, uint8_t high)
Fill QASYMM tensor with Random values.
inline ::std::ostream & operator<<(::std::ostream &os, ConvolutionPaddingMode Mode)
Formatted output of the ConvolutionPaddingMode type.
Simple tensor object that stores elements in a consecutive chunk of memory.
void do_teardown() override
Teardown the example.
Tensor accessor interface.
ConvolutionMethod
Supported Convolution layer methods.
const T & value() const
Get the option value.
Copyright (c) 2017-2024 Arm Limited.
@ F16
16-bit floating-point number
Stream frontend class to construct simple graphs in a stream fashion.
void fill_tensor(arm_compute::test::SimpleTensor< int32_t > &tensor, std::random_device::result_type seed, int32_t low, int32_t high)
Fill S32 tensor with Random values.
bool access_tensor(ITensor &tensor) override
Interface to be implemented to access a given tensor.
std::uniform_real_distribution< float > distribution(-5.f, 5.f)
EnumOption< arm_compute::graph::Target > * target
Graph execution target.
DepthwiseConvolutionMethod
Supported Depthwise Convolution layer methods.
@ Default
Default approach using internal heuristics.
@ F32
32-bit floating-point number
FullyConnectedParams fully_connected
Structure holding all the verification graph parameters.
GraphValidateExample(std::string name)
virtual float tolerance_number()=0
Select tolerance number.
void run()
Executes the stream.
Class reprensenting a relative tolerance value.
Class reprensenting an absolute tolerance value.
void fill_tensor(arm_compute::test::SimpleTensor< half > &tensor, std::random_device::result_type seed, half low, half high)
Fill F16 tensor with Random values.
arm_compute::graph::ConvolutionMethod convolution_method
arm_compute::graph::frontend::Stream graph
void finalize(Target target, const GraphConfig &config)
Finalizes the stream for an execution target.
arm_compute::graph::Target target
DataType
Available data types.
FrameworkParams common_params
CommonGraphValidateOptions(CommandLineParser &parser) noexcept
Graph example validation accessor class.
PadStrideInfo calculate_convolution_padding(ExampleParams params)
Calculate stride information.
virtual float absolute_tolerance()=0
Select absolute tolerance.
Includes all the Graph headers at once.
const QuantizationInfo qinfo
struct arm_compute::utils::ConvolutionParams::@6::@7 stride
ConvolutionParams convolution
void validate(ITensor &tensor, arm_compute::test::SimpleTensor< D > output)
Validate the output versus the reference.