17#include "../KernelGenerator.h"
18#include "../Validator.h"
25void Validator::visit(
const ir::operation::Transpose &) {
_supported =
true; }
27void KernelGenerator::visit(
const ir::operation::Transpose &node)
29 const auto ofm_idx{node.getOutputs().at(0)};
33 auto ofm_tensor = _tensor_reg->getAclTensor(ofm_idx);
34 const auto ifm_tensor = _tensor_reg->getAclTensor(ifm_idx);
35 const auto rank = _ctx.
at(ifm_idx).shape().rank();
37 const auto &perms = _ctx.
at(perm_idx);
38 std::vector<int32_t> pv;
39 if (perms.shape() == ir::Shape{0})
42 std::iota(pv.begin(), pv.end(), 0);
43 std::reverse(pv.begin(), pv.end());
47 pv = _ctx.
at(perm_idx).asVector<int32_t>();
50 std::unique_ptr<arm_compute::IFunction> fn;
53 fn = acl_common::generateLayer<arm_compute::NECopy>(ifm_tensor->handle(), ofm_tensor->handle());
57 assert(pv.size() == 2 && pv.at(0) == 1 && pv.at(1) == 0);
58 fn = acl_common::generateLayer<arm_compute::NETranspose>(ifm_tensor->handle(),
59 ofm_tensor->handle());
65 fn = acl_common::generateLayer<arm_compute::NEPermute>(ifm_tensor->handle(),
66 ofm_tensor->handle(), backend_pv);
std::unique_ptr< exec::IFunction > _return_fn
const Object & at(const Index &index) const
Get the object that is associated with the given index.
inline ::arm_compute::PermutationVector getARMComputePermutationVector(uint32_t rank, const std::vector< int32_t > runtime_pv)
std::unique_ptr< AclFunction > asAclFunction(std::unique_ptr<::arm_compute::IFunction > &&layer)