22.11
IPostOp< TensorRelatedT > Struct Template Referenceabstract

An elementwise n-ary operation that can be appended to and fused with (at kernel-level) other operators It contains: More...

#include <IPostOp.h>

## Public Member Functions

size_t arity () const
Get the arity of the post op. More...

virtual int prev_dst_pos () const =0
The position of previous op's dst in current op's argument list. More...

virtual PostOpType type () const =0
The IPostOp type. More...

virtual std::vector< TensorRelatedT * > arguments ()=0
The argument tensors The order of the argument tensor is strictly preserved. More...

virtual std::vector< const TensorRelatedT * > arguments () const =0

virtual std::unique_ptr< IPostOp< TensorRelatedT > > clone () const =0
Clone method used in cases where PostOps are owned by unique_ptr. More...

virtual ~IPostOp ()

## Detailed Description

### template<typename TensorRelatedT> struct arm_compute::experimental::IPostOp< TensorRelatedT >

An elementwise n-ary operation that can be appended to and fused with (at kernel-level) other operators It contains:

1. The attributes of the original operator.
3. The position of the previous op's dst tensor in its argument list ( prev_dst_pos )

For example, a series of chained ops:

    div(src1, relu(conv(src0, weights, bias, conv_info), act_info), div_info)

translates to

dst = conv(src0, weights, bias, conv_info)  // main op
dst = relu(dst, act_info)                   // previous dst is placed in the first (and only) argument
dst = div(src1, dst, div_info)              // previous dst is placed in the second argument

which in turn translates to:

main op: conv(src0, weights, bias, conv_info)
post op1: relu(act_info, prev_dst_pos = 0)
post op2: div(div_info, src1, prev_dst_pos = 1)

Note
: On Broadcasting For n-ary post ops, the tensor arguments must not "widen" the dst tensor of the main op For example, for a dst of shape [14, 1, 34]:
• post_op_arg1 = [1, 1, 34] is allowed: broadcast in dim 0
• post_op_arg1 = [14, 1, 34] is allowed: no broadcast
• post_op_arg1 = [1, 1, 34] is allowed: broadcast in dims 0 and 1
• post_op_arg1 = [14, 15, 34] is NOT allowed: broadcast widens the dst tensor
: On Data layout All post ops are data layout agnostic. This means post ops do not have an inherent idea of "width", "height" and so on. Should we want to perform a post op with 2 tensors of different data layouts (where data layouts are significant to both), then we need to perform necessary permutation op beforehand to unify their data layout before they can be fused with a post op

Note although post ops themselves should be able to support any data layout, the main op they fuse to may impose additional restrictions in the presence of post ops. For example, the implementation of a gemm op may only allow NHWC data layout if post ops are provided. Such restrictions are main op implementation specific.

Note
: PostOps do not own any resources pointed to by TensorRelatedT if it's a pointer type
: If TensorRelatedT points to a resource, IPostOp assumes that resource is valid throughout its lifetime and the lifetime of its copies. This is almost guaranteed as IPostOp is only meant to be used at configure time after the ITensor or ITensorInfo objects are already constructed

Definition at line 89 of file IPostOp.h.

## ◆ ~IPostOp()

 virtual ~IPostOp ( )
inlinevirtual

Definition at line 112 of file IPostOp.h.

113  {
114  }

## ◆ arguments() [1/2]

 virtual std::vector arguments ( )
pure virtual

The argument tensors The order of the argument tensor is strictly preserved.

## ◆ arguments() [2/2]

 virtual std::vector arguments ( ) const
pure virtual

## ◆ arity()

 size_t arity ( ) const
inline

Get the arity of the post op.

Note
: that this is one fewer than the arity of the original op, because we implicitly pass the previous op's dst tensor as one of the arguments

Definition at line 95 of file IPostOp.h.

References type.

96  {
97  return arguments().size();
98  }
virtual std::vector< TensorRelatedT * > arguments()=0
The argument tensors The order of the argument tensor is strictly preserved.

## ◆ clone()

 virtual std::unique_ptr > clone ( ) const
pure virtual

Clone method used in cases where PostOps are owned by unique_ptr.

Note
: This performs a shallow copy of the TensorRelatedT if TensorRelatedT points to a resource

## ◆ prev_dst_pos()

 virtual int prev_dst_pos ( ) const
pure virtual

The position of previous op's dst in current op's argument list.

## ◆ type()

 virtual PostOpType type ( ) const
pure virtual

The IPostOp type.

The documentation for this struct was generated from the following file: