37 cl_channel_type cl_data_type;
42 cl_data_type = CL_FLOAT;
45 cl_data_type = CL_HALF_FLOAT;
52 cl_int err = CL_SUCCESS;
54 const cl_image_format format = { CL_RGBA, cl_data_type };
57 memset(&desc, 0,
sizeof(desc));
58 desc.image_type = CL_MEM_OBJECT_IMAGE2D;
59 desc.mem_object = buffer();
60 desc.image_row_pitch = image_row_pitch;
61 desc.image_width = shape2d[0];
62 desc.image_height = shape2d[1];
64 cl_image =
clCreateImage(ctx(), CL_MEM_READ_ONLY, &format, &desc,
nullptr, &err);
69 return cl::Image2D(cl_image);
72 namespace experimental
75 : _supported_config(supported_config)
78 for(
auto it = _supported_config.begin(); it != _supported_config.end(); ++it)
80 auto post_op_sequence = it->first;
81 auto post_op_slots = std::get<1>(it->second);
82 ARM_COMPUTE_ERROR_ON_MSG(post_op_sequence.size() != post_op_slots.size(),
"The number of PostOps must be the same as that of the assigned slots");
88 for(
const auto &op : post_ops.
get_list())
90 for(
const auto &tensor : op->arguments())
102 if(dst->
dimension(0) > 1 && dst->
dimension(1) > 1 && (*tensor)->dimension(0) == 1 && (*tensor)->dimension(1) > 1)
113 if(post_ops.
size() == 0)
119 return _supported_config.find(post_op_sequence) != _supported_config.end();
125 const auto slots = std::get<1>(_supported_config.at(post_op_sequence));
126 for(
size_t post_op_id = 0; post_op_id < post_ops.
size(); ++post_op_id)
128 const auto &post_op = post_ops.
get_list().at(post_op_id);
132 const auto _post_op = utils::cast::polymorphic_downcast<const experimental::PostOpAct<ITensorInfo *> *>(post_op.get());
143 const auto eltwise_op = slot_prefix +
"_ELTWISE_OP=ADD" +
"_X_POS_" +
support::cpp11::to_string(post_op->prev_dst_pos());
145 for(
const auto &tensor : post_op->arguments())
157 const auto eltwise_op = slot_prefix +
"_ELTWISE_OP=PRELU" +
"_X_POS_" +
support::cpp11::to_string(post_op->prev_dst_pos());
159 for(
const auto &tensor : post_op->arguments())
174 const auto postfix = std::get<0>(_supported_config.at(post_op_sequence));
175 kernel_name += postfix;
std::vector< std::unique_ptr< IPostOp< TensorRelatedT > > > & get_list()
Get the underlying post op list.
experimental::PostOpList< ITensorInfo * > post_ops
bool is_post_op_sequence_supported(const PostOpList< ITensorInfo *> &post_ops) const
Check if the post op sequence is supported in the current configuration.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
std::string to_string(T &&value)
Convert integer and float values to string.
1 channel, 1 F32 per channel
static TensorShape broadcast_shape(const Shapes &... shapes)
If shapes are broadcast compatible, return the broadcasted shape.
const std::string & string_from_activation_func(ActivationLayerInfo::ActivationFunction act)
Translates a given activation function to a string.
Store the tensor's metadata.
cl_mem clCreateImage(cl_context context, cl_mem_flags flags, const cl_image_format *image_format, const cl_image_desc *image_desc, void *host_ptr, cl_int *errcode_ret)
std::string lower_string(const std::string &val)
Lower a given string.
Copyright (c) 2017-2022 Arm Limited.
1 channel, 1 F16 per channel
void add_option(std::string option)
Adds option to the existing build option list.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
void set_post_ops_cl_kernel_name(std::string &kernel_name, const PostOpList< ITensorInfo *> &post_ops) const
Helper function to set PostOp kernel name.
PostOpCLKernelUtils(const Config &config)
std::string float_to_string_with_full_precision(float val)
Create a string with the float in full precision.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
void set_post_ops_cl_build_options(CLBuildOptions &built_opts, const PostOpList< ITensorInfo *> &post_ops) const
Helper function to set PostOp related build options.
bool have_different_dimensions(const Dimensions< T > &dim1, const Dimensions< T > &dim2, unsigned int upper_dim)
static bool are_post_op_shapes_compliant(const ITensorInfo *dst, const experimental::PostOpList< ITensorInfo *> &post_ops)
Check if post op argument tensor shapes are compliant All post ops must not alter the shape of the or...
std::map< PostOpTypeSequence, std::tuple< NamePostfix, Slots > > Config
size_t size() const
Number of post ops.
cl::Image2D create_image2d_from_buffer(const cl::Context &ctx, const cl::Buffer &buffer, const TensorShape &shape2d, DataType data_type, size_t image_row_pitch)
Create a cl::Image2D object from an OpenCL buffer.
DataType
Available data types.
PostOpTypeSequence get_post_op_sequence(const PostOpList< T > &post_ops)
Get a sequence of PostOp Types from PostOpList.
A sequence of PostOps that can be appended to the end of other operators.