24.02.1
|
Operator interface.
More...
#include <GpuSoftmax.h>
|
static void | create_op (GpuWorkloadSketch &sketch, ITensorInfo *src, ITensorInfo *dst, const Attributes &attributes) |
| Create an operator and fuse it into the workload sketch. More...
|
|
static Status | is_supported_op (const GpuWorkloadContext &context, const ITensorInfo *src, const ITensorInfo *dst, const Attributes &attributes) |
| Check if the operator configuration is supported, irrespective of fusion. More...
|
|
static Status | validate_op (const GpuWorkloadSketch &sketch, const ITensorInfo *src, const ITensorInfo *dst, const Attributes &attributes) |
| Validate the operator and check if the its configuration is supported and if it can be fused into the workload sketch. More...
|
|
Operator interface.
Definition at line 41 of file GpuSoftmax.h.
◆ Attributes
Attributes are a set of backend-agnostic parameters that define what an operator does.
Definition at line 45 of file GpuSoftmax.h.
◆ create_op()
Create an operator and fuse it into the workload sketch.
- Note
- If validate_op() fails, the creation also fails and may throw an error.
-
If validate_op() fails,
sketch
remains unchanged and valid.
Valid data type configurations:
Valid data layouts:
- Parameters
-
[in,out] | sketch | Workload sketch into which the operator will be fused |
[in] | src | Source tensor info. |
[in] | dst | Destination tensor info. |
[in] | attributes | Operator attributes |
Definition at line 136 of file GpuSoftmax.cpp.
140 TensorShape logits_sum_shape =
src->tensor_shape();
143 logits_sum_shape.set(0, 1);
169 ArgumentPack<ITensorInfo> arguments_exp_sum;
170 ArgumentPack<ITensorInfo> arguments_norm;
173 arguments_exp_sum.add_const_tensor(
ACL_DST_0, sum);
174 arguments_exp_sum.add_const_tensor(
ACL_DST_1, logits);
176 arguments_norm.add_const_tensor(
ACL_SRC_0, logits);
177 arguments_norm.add_const_tensor(
ACL_SRC_1, sum);
180 comp_graph.add_new_component<ClComponentLogits1DMaxShiftExpSum>(properties, arguments_exp_sum, attributes);
181 comp_graph.add_new_component<ClComponentLogits1DNorm>(properties, arguments_norm, attributes);
193 ArgumentPack<ITensorInfo> tensors;
References arm_compute::ACL_DST_0, arm_compute::ACL_DST_1, arm_compute::ACL_SRC_0, arm_compute::ACL_SRC_1, ArgumentPack< T >::add_const_tensor(), GpuOperatorGroup::add_operator(), ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, ARM_COMPUTE_LOG_PARAMS, ARM_COMPUTE_UNUSED, arm_compute::auto_init_if_empty(), GpuWorkloadContext::cl_compile_context(), GpuWorkloadSketch::Implementation::component_graph(), GpuWorkloadSketch::Implementation::context(), GpuWorkloadSketch::Implementation::create_auxiliary_tensor(), arm_compute::test::validation::dst, GpuWorkloadSketch::implementation(), ITensorInfo::invalid_tensor_id, GpuOperatorGroup::new_operator(), arm_compute::experimental::dynamic_fusion::OpenCL, GpuWorkloadSketch::Implementation::operator_group(), UnitWorkloadStage::Run, TensorShape::set(), arm_compute::test::validation::sketch, arm_compute::test::validation::src, and GpuSoftmax::validate_op().
◆ is_supported_op()
Check if the operator configuration is supported, irrespective of fusion.
- Parameters
-
[in] | context | Workload context within which the operator is running |
[in] | src | Source tensor info. |
[in] | dst | Destination tensor info. |
[in] | attributes | Operator attributes |
- Returns
- Status
Definition at line 47 of file GpuSoftmax.cpp.
53 TensorInfo dst_info_to_validate;
58 dst_info_to_validate = *
dst;
67 const auto cl_compile_ctx =
context.cl_compile_context();
69 const KernelProperties properties =
72 TensorShape logits_sum_shape =
src->tensor_shape();
73 TensorInfo logits(
src->clone()->set_tensor_shape(logits_sum_shape));
76 logits_sum_shape.set(0, 1);
77 TensorInfo sum(
src->clone()->set_tensor_shape(logits_sum_shape));
80 ArgumentPack<ITensorInfo> arguments_exp_sum;
81 ArgumentPack<ITensorInfo> arguments_norm;
84 arguments_exp_sum.add_const_tensor(
ACL_DST_0, &sum);
85 arguments_exp_sum.add_const_tensor(
ACL_DST_1, &logits);
87 arguments_norm.add_const_tensor(
ACL_SRC_0, &logits);
88 arguments_norm.add_const_tensor(
ACL_SRC_1, &sum);
89 arguments_norm.add_const_tensor(
ACL_DST_0, &dst_info_to_validate);
References arm_compute::ACL_DST_0, arm_compute::ACL_DST_1, arm_compute::ACL_SRC_0, arm_compute::ACL_SRC_1, ArgumentPack< T >::add_const_tensor(), ARM_COMPUTE_RETURN_ERROR_MSG, ARM_COMPUTE_RETURN_ERROR_ON, ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR, ARM_COMPUTE_RETURN_ON_ERROR, arm_compute::auto_init_if_empty(), arm_compute::test::validation::context, arm_compute::test::validation::dst, arm_compute::experimental::dynamic_fusion::OpenCL, UnitWorkloadStage::Run, arm_compute::RUNTIME_ERROR, TensorShape::set(), arm_compute::test::validation::src, KernelProperties::stage(), ClComponentLogits1DNorm::validate(), and ClComponentLogits1DMaxShiftExpSum::validate().
Referenced by GpuSoftmax::validate_op().
◆ validate_op()
Validate the operator and check if the its configuration is supported and if it can be fused into the workload sketch.
Similar to GpuSoftmax::create_op()
- Returns
- a status
Definition at line 103 of file GpuSoftmax.cpp.
112 static_cast<int32_t
>(
src->num_dimensions()) <= attributes.axis());
115 TensorInfo dst_info_to_validate = *
dst;
118 const size_t actual_axis =
119 static_cast<size_t>(
wrap_around(attributes.axis(),
static_cast<int32_t
>(
src->num_dimensions())));
120 const bool needs_permute = actual_axis != 0;
124 ArgumentPack<ITensorInfo> tensors;
126 tensors.add_const_tensor(
ACL_DST_0, &dst_info_to_validate);
130 "Operator fusion test failed. This operator cannot be fused into the workload");
References arm_compute::ACL_DST_0, arm_compute::ACL_SRC_0, ArgumentPack< T >::add_const_tensor(), ARM_COMPUTE_RETURN_ERROR_ON, ARM_COMPUTE_RETURN_ERROR_ON_MSG, ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR, arm_compute::auto_init_if_empty(), SoftmaxAttributes::axis(), arm_compute::test::validation::dst, GpuWorkloadSketch::gpu_context(), GpuWorkloadSketch::implementation(), GpuSoftmax::is_supported_op(), GpuOperatorGroup::new_operator(), GpuWorkloadSketch::Implementation::operator_group(), arm_compute::test::validation::sketch, arm_compute::test::validation::src, GpuOperatorGroup::try_add_operator(), and arm_compute::wrap_around().
Referenced by GpuSoftmax::create_op().
The documentation for this class was generated from the following files:
Operator new_operator(const GpuOperatorType &operator_type, const ArgumentPack< ITensorInfo > &tensors) const
Create a new operator.
SimpleTensor< float > src
@ Run
Run every time after the first time.
const GpuOperatorGroup & operator_group() const
Get operator group.
bool try_add_operator(const Operator &op, bool is_output=false) const
Try adding (without actually adding) an operator to the group.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
T wrap_around(T x, T m)
Wrap-around a number within the range 0 <= x < m.
const GpuWorkloadContext * gpu_context() const
Get the gpu workload context of this sketch.
static Status is_supported_op(const GpuWorkloadContext &context, const ITensorInfo *src, const ITensorInfo *dst, const Attributes &attributes)
Check if the operator configuration is supported, irrespective of fusion.
Implementation & implementation()
Get the implementation.
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
@ RUNTIME_ERROR
Generic runtime error.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
const GpuKernelComponentGraph & component_graph() const
Get component graph.
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
bool auto_init_if_empty(ITensorInfo &info, const TensorShape &shape, int num_channels, DataType data_type, QuantizationInfo quantization_info=QuantizationInfo())
Auto initialize the tensor info (shape, number of channels and data type) if the current assignment i...
const CLCompileContext * cl_compile_context() const
Get CLCompileContext If the gpu language is not OpenCL, then return nullptr.
const Context * context() const
Get workload context.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
KernelProperties & stage(const UnitWorkloadStage &stage)
static Status validate(const Properties &properties, const ArgumentPack< ITensorInfo > &tensors, const Attributes &attributes)
Validate the component.
static constexpr Id invalid_tensor_id
An invalid tensor id within a domain.
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
static Status validate(const Properties &properties, const ArgumentPack< ITensorInfo > &tensors, const Attributes &attributes)
Validate the component.
static Status validate_op(const GpuWorkloadSketch &sketch, const ITensorInfo *src, const ITensorInfo *dst, const Attributes &attributes)
Validate the operator and check if the its configuration is supported and if it can be fused into the...
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
KernelProperties Properties
#define ARM_COMPUTE_RETURN_ERROR_MSG(...)
An error is returned with the given description.
void add_operator(const Operator &op, bool is_output=false)
Add an operator to the group.
#define ARM_COMPUTE_LOG_PARAMS(...)
ITensorInfo * create_auxiliary_tensor(const ITensorInfo &tensor_info)
Create an auxiliary (see MemoryType) tensor info and save it.