From 44af63b9e92bce8facdca676298da7789056a7d7 Mon Sep 17 00:00:00 2001 From: "yuenan.li" Date: Wed, 20 Jan 2021 10:45:00 +0800 Subject: [PATCH] [NNRT-811]Map Slice Signed-off-by: yuenan.li --- include/tim/vx/ops/slice.h | 49 ++++++++++++++++++++++++++++++++++++++ src/tim/vx/ops/slice.cc | 47 ++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 include/tim/vx/ops/slice.h create mode 100644 src/tim/vx/ops/slice.cc diff --git a/include/tim/vx/ops/slice.h b/include/tim/vx/ops/slice.h new file mode 100644 index 0000000..11d7834 --- /dev/null +++ b/include/tim/vx/ops/slice.h @@ -0,0 +1,49 @@ +/**************************************************************************** +* +* Copyright (c) 2020 Vivante Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +*****************************************************************************/ +#ifndef TIM_VX_OPS_SLICE_H_ +#define TIM_VX_OPS_SLICE_H_ +#include "tim/vx/operation.h" + +namespace tim { +namespace vx { +namespace ops { + +class Slice : public Operation { + public: + Slice(Graph* graph, + uint32_t dims, + const std::vector& start, + const std::vector& length); + + protected: + uint32_t dims_; + const std::vector start_; + const std::vector length_; +}; + +} // namespace ops +} // namespace vx +} // namespace tim + +#endif /* TIM_VX_OPS_SLICE_H_ */ diff --git a/src/tim/vx/ops/slice.cc b/src/tim/vx/ops/slice.cc new file mode 100644 index 0000000..6c0ba89 --- /dev/null +++ b/src/tim/vx/ops/slice.cc @@ -0,0 +1,47 @@ +/**************************************************************************** +* +* Copyright (c) 2020 Vivante Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +*****************************************************************************/ +#include "tim/vx/ops/slice.h" + +#include "operation_private.h" +#include "vsi_nn_pub.h" + +namespace tim { +namespace vx { +namespace ops { + +Slice::Slice(Graph* graph, uint32_t dims, const std::vector& start, + const std::vector& length) + : Operation(graph, VSI_NN_OP_SLICE), + dims_(dims), + start_(start), + length_(length) { + this->impl()->node()->nn_param.slice.dims = dims_; + this->impl()->node()->nn_param.slice.start = + reinterpret_cast(start_.data()); + this->impl()->node()->nn_param.slice.length = + reinterpret_cast(length_.data()); +} +} // namespace ops +} // namespace vx +} // namespace tim \ No newline at end of file