/** * Copyright 2020 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef GE_GRAPH_PASSES_FOLDING_KERNEL_STRIDED_SLICE_KERNEL_H_ #define GE_GRAPH_PASSES_FOLDING_KERNEL_STRIDED_SLICE_KERNEL_H_ #include "inc/kernel.h" #include namespace ge { class StridedSliceKernel : public Kernel { public: Status Compute(const OpDescPtr attr, const std::vector &input, vector &v_output) override; private: Status CheckAndGetAttr(const OpDescPtr &attr); static Status CheckInputParam(const std::vector &input) ; Status InitParamWithAttrs(const std::vector &input, std::vector &input_dims, std::vector &begin_vec, std::vector &output_dims, std::vector &stride_vec); Status MaskCal(const size_t i, int64_t &begin_i, int64_t &end_i, int64_t &dim_i) const; static Status StrideCal(const int64_t x_dims_i, int64_t &begin_i, int64_t &end_i, int64_t &stride_i, int64_t &dim_final) ; void ExpandDimsWithNewAxis(const ConstGeTensorPtr &begin_tensor, const size_t x_dims_num, vector &x_dims); void ExpandStrideWithEllipsisMask(const size_t x_dims_num, const vector &x_dims, vector &orig_begin_vec, vector &orig_end_vec, vector &orig_stride_vec); void GetOutputDims(uint32_t dims_size, const std::vector &output_dims, vector &v_dims); map attr_value_map_ = {{STRIDE_SLICE_ATTR_BEGIN_MASK, 0}, {STRIDE_SLICE_ATTR_END_MASK, 0}, {STRIDE_SLICE_ATTR_ELLIPSIS_MASK, 0}, {STRIDE_SLICE_ATTR_NEW_AXIS_MASK, 0}, {STRIDE_SLICE_ATTR_SHRINK_AXIS_MASK, 0}}; }; } // namespace ge #endif // GE_GRAPH_PASSES_FOLDING_KERNEL_STRIDED_SLICE_KERNEL_H_