1 /** 2 * Copyright 2019 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_OPENCL_KERNEL_CONCAT_H_ 18 #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_OPENCL_KERNEL_CONCAT_H_ 19 20 #include <vector> 21 #include <string> 22 #include "src/litert/kernel/opencl/opencl_kernel.h" 23 #include "nnacl/concat_parameter.h" 24 25 namespace mindspore { 26 namespace kernel { 27 class ConcatOpenCLKernel : public OpenCLKernel { 28 public: 29 using OpenCLKernel::OpenCLKernel; 30 31 ~ConcatOpenCLKernel() override = default; 32 33 int Prepare() override; 34 35 int CheckSpecs() override; SetConstArgs()36 int SetConstArgs() override { return RET_OK; } 37 int SetGlobalLocal() override; 38 int Run() override; 39 DumpCode()40 std::string DumpCode() override { return dump_code_; } 41 42 private: 43 std::vector<size_t> local; 44 uint32_t OH = {1}; 45 uint32_t OW = {1}; 46 uint32_t OC = {1}; 47 std::vector<size_t> global; 48 bool Align_{true}; 49 std::vector<void *> weight_ptrs_; 50 cl_int stride_w{1}; 51 cl_int4 in_shape_{}; 52 cl_int4 out_shape_{}; 53 int axis_{0}; 54 std::string dump_code_; 55 56 private: 57 int RunAxis0(); 58 int ConvertWeightToTensor(); 59 std::string GenMainCodeAxis3UnAlign(); 60 std::string GenMainCodeOthers(); 61 std::string GenCode(); 62 }; 63 64 } // namespace kernel 65 } // namespace mindspore 66 #endif 67