From b23968868cf1d7cf2a2ad07af9f7768a181f5c77 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Thu, 5 Nov 2020 16:53:55 +0800 Subject: [PATCH] remove thirdparty register --- .../fwkacllib/inc/register/host_cpu_context.h | 39 ----- .../inc/register/op_kernel_registry.h | 49 ------- .../fwkacllib/inc/register/op_registry.h | 90 ------------ .../fwkacllib/inc/register/op_tiling.h | 135 ------------------ .../register/ops_kernel_builder_registry.h | 62 -------- third_party/fwkacllib/inc/register/register.h | 54 ------- .../inc/register/register_format_transfer.h | 79 ---------- 7 files changed, 508 deletions(-) delete mode 100644 third_party/fwkacllib/inc/register/host_cpu_context.h delete mode 100644 third_party/fwkacllib/inc/register/op_kernel_registry.h delete mode 100644 third_party/fwkacllib/inc/register/op_registry.h delete mode 100644 third_party/fwkacllib/inc/register/op_tiling.h delete mode 100644 third_party/fwkacllib/inc/register/ops_kernel_builder_registry.h delete mode 100644 third_party/fwkacllib/inc/register/register.h delete mode 100644 third_party/fwkacllib/inc/register/register_format_transfer.h diff --git a/third_party/fwkacllib/inc/register/host_cpu_context.h b/third_party/fwkacllib/inc/register/host_cpu_context.h deleted file mode 100644 index 4d6d5855..00000000 --- a/third_party/fwkacllib/inc/register/host_cpu_context.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2019-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 INC_REGISTER_HOST_CPU_CONTEXT_H_ -#define INC_REGISTER_HOST_CPU_CONTEXT_H_ - -#include "external/ge/ge_api_error_codes.h" -#include "register/register_types.h" - -namespace ge { -class HostCpuContext { - public: - HostCpuContext() = default; - ~HostCpuContext() = default; - private: - class Impl; - Impl *impl_; -}; -} // namespace ge - -extern "C" { -// Unified definition for registering host_cpu_kernel_wrapper when so is opened -FMK_FUNC_HOST_VISIBILITY ge::Status Initialize(const ge::HostCpuContext &ctx); -} - -#endif //INC_REGISTER_HOST_CPU_CONTEXT_H_ diff --git a/third_party/fwkacllib/inc/register/op_kernel_registry.h b/third_party/fwkacllib/inc/register/op_kernel_registry.h deleted file mode 100644 index 5fed8960..00000000 --- a/third_party/fwkacllib/inc/register/op_kernel_registry.h +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright 2019-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 INC_REGISTER_OP_KERNEL_REGISTRY_H_ -#define INC_REGISTER_OP_KERNEL_REGISTRY_H_ -#include -#include -#include "register/register_types.h" -#include "register.h" - -namespace ge { -class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpKernelRegistry { - public: - using CreateFn = HostCpuOp* (*)(); - ~OpKernelRegistry(); - - static OpKernelRegistry& GetInstance() { - static OpKernelRegistry instance; - return instance; - } - - bool IsRegistered(const std::string &op_type); - - void RegisterHostCpuOp(const std::string &op_type, CreateFn create_fn); - - std::unique_ptr CreateHostCpuOp(const std::string &op_type); - - private: - OpKernelRegistry(); - class OpKernelRegistryImpl; - /*lint -e148*/ - std::unique_ptr impl_; -}; -} // namespace ge - -#endif // INC_REGISTER_OP_KERNEL_REGISTRY_H_ diff --git a/third_party/fwkacllib/inc/register/op_registry.h b/third_party/fwkacllib/inc/register/op_registry.h deleted file mode 100644 index 3feea0df..00000000 --- a/third_party/fwkacllib/inc/register/op_registry.h +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright 2019-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 INC_REGISTER_OP_REGISTRY_H_ -#define INC_REGISTER_OP_REGISTRY_H_ - -#include -#include -#include -#include -#include - -#include "register/register.h" - -namespace domi { -enum RemoveInputType { - OMG_MOVE_TYPE_DTYPE = 0, - OMG_MOVE_TYPE_VALUE, - OMG_MOVE_TYPE_SHAPE, - OMG_MOVE_TYPE_FORMAT, - OMG_MOVE_TYPE_AXIS, - OMG_MOVE_TYPE_SCALAR_VALUE, - OMG_REMOVE_TYPE_WITH_COND = 1000, - OMG_REMOVE_INPUT_WITH_ORIGINAL_TYPE, - OMG_INPUT_REORDER, -}; - -struct RemoveInputConfigure { - int inputIdx = INT_MAX; - std::string attrName; - RemoveInputType moveType; - bool attrValue = false; - std::string originalType; - std::vector input_order; -}; - -class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpRegistry { - public: - static OpRegistry *Instance(); - - std::vector registrationDatas; - - bool Register(const OpRegistrationData ®_data); - - domi::ImplyType GetImplyType(const std::string &op_type); - - void GetOpTypeByImplyType(std::vector &vec_op_type, const domi::ImplyType &imply_type); - - domi::ParseParamFunc GetParseParamFunc(const std::string &op_type, const std::string &ori_type); - - domi::ParseParamByOpFunc GetParseParamByOperatorFunc(const std::string &ori_type); - - domi::FusionParseParamFunc GetFusionParseParamFunc(const std::string &op_type, const std::string &ori_type); - - domi::FusionParseParamByOpFunc GetFusionParseParamByOpFunc(const std::string &op_type, - const std::string &ori_type); - - domi::ParseSubgraphFunc GetParseSubgraphPostFunc(const std::string &op_type); - - domi::ImplyType GetImplyTypeByOriOpType(const std::string &ori_optype); - - const std::vector &GetRemoveInputConfigure(const std::string &ori_optype) const; - - bool GetOmTypeByOriOpType(const std::string &ori_optype, std::string &om_type); - - private: - std::unordered_map op_run_mode_map_; - std::unordered_map op_parse_params_fn_map_; - std::unordered_map parse_params_by_op_func_map_; - std::unordered_map fusion_op_parse_params_fn_map_; - std::unordered_map fusion_parse_params_by_op_fn_map_; - std::unordered_map op_types_to_parse_subgraph_post_func_; - std::unordered_map> remove_input_configure_map_; - std::unordered_map origin_type_to_om_type_; -}; -} // namespace domi -#endif // INC_REGISTER_OP_REGISTRY_H_ diff --git a/third_party/fwkacllib/inc/register/op_tiling.h b/third_party/fwkacllib/inc/register/op_tiling.h deleted file mode 100644 index bcd4cd5e..00000000 --- a/third_party/fwkacllib/inc/register/op_tiling.h +++ /dev/null @@ -1,135 +0,0 @@ -/** - * Copyright 2019-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 INC_OP_TILING_H_ -#define INC_OP_TILING_H_ - -#include "external/register/register_types.h" -#include "external/graph/tensor.h" -#include "graph/debug/ge_attr_define.h" -#include "graph/node.h" - -#include -#include -#include -#include -#include -#include -#include -#include "graph/node.h" - -#define REGISTER_OP_TILING_FUNC(optype, opfunc) \ - REGISTER_OP_TILING_FUNC_UNIQ_HELPER(optype, opfunc, __COUNTER__) - -#define REGISTER_OP_TILING_FUNC_UNIQ_HELPER(optype, opfunc, counter) \ - REGISTER_OP_TILING_FUNC_UNIQ(optype, opfunc, counter) - -#define REGISTER_OP_TILING_FUNC_UNIQ(optype, opfunc, counter) \ - static OpTilingInterf g_##optype##TilingInterf##counter(#optype, opfunc) - -namespace optiling { - -enum TensorArgType { - TA_NONE, - TA_SINGLE, - TA_LIST, -}; - - -using ByteBuffer = std::stringstream; - -struct TeOpTensor { - std::vector shape; - std::vector ori_shape; - std::string format; - std::string ori_format; - std::string dtype; - std::map attrs; -}; - - -struct TeOpTensorArg { - TensorArgType arg_type; - std::vector tensor; -}; - -struct OpRunInfo { - uint32_t block_dim; - std::vector workspaces; - ByteBuffer tiling_data; -}; - - -using TeOpAttrArgs = std::vector; -using TeConstTensorData = std::tuple; - -struct TeOpParas { - std::vector inputs; - std::vector outputs; - std::map const_inputs; - TeOpAttrArgs attrs; -}; - - -using OpTilingFunc = std::function; - -using OpTilingFuncPtr = bool(*)(const std::string&, const TeOpParas&, const nlohmann::json& , OpRunInfo&); - -class FMK_FUNC_HOST_VISIBILITY OpTilingInterf -{ -public: - OpTilingInterf(std::string op_type, OpTilingFunc func); - ~OpTilingInterf() = default; - static std::map &RegisteredOpInterf(); - static std::string OpTilingUuid; -}; - - -template -ByteBuffer& ByteBufferPut(ByteBuffer &buf, const T &value) -{ - buf.write(reinterpret_cast(&value), sizeof(value)); - buf.flush(); - return buf; -} - -template -ByteBuffer& ByteBufferGet(ByteBuffer &buf, T &value) -{ - buf.read(reinterpret_cast(&value), sizeof(value)); - return buf; -} - -inline size_t ByteBufferGetAll(ByteBuffer &buf, char *dest, size_t dest_len) -{ - size_t nread = 0; - size_t rn = 0; - do { - rn = buf.readsome(dest + nread, dest_len - nread); - nread += rn; - } while (rn > 0 && dest_len > nread); - - return nread; -} - - -extern "C" ge::graphStatus OpParaCalculate(const ge::Node &node, OpRunInfo &run_info); -extern "C" ge::graphStatus OpAtomicCalculate(const ge::Node &node, OpRunInfo &run_info); - -} - -#endif // INC_OP_TILING_H_ diff --git a/third_party/fwkacllib/inc/register/ops_kernel_builder_registry.h b/third_party/fwkacllib/inc/register/ops_kernel_builder_registry.h deleted file mode 100644 index 96ac931b..00000000 --- a/third_party/fwkacllib/inc/register/ops_kernel_builder_registry.h +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright 2019-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 INC_REGISTER_OPS_KERNEL_BUILDER_REGISTRY_H_ -#define INC_REGISTER_OPS_KERNEL_BUILDER_REGISTRY_H_ - -#include -#include "register/register_types.h" -#include "common/opskernel/ops_kernel_builder.h" - -namespace ge { -using OpsKernelBuilderPtr = std::shared_ptr; - -class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpsKernelBuilderRegistry { - public: - static OpsKernelBuilderRegistry &GetInstance(); - - void Register(const std::string &lib_name, const OpsKernelBuilderPtr &instance); - - void UnregisterAll(); - - const std::map &GetAll() const; - - private: - std::map kernel_builders_; -}; - -class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpsKernelBuilderRegistrar { - public: - using CreateFn = OpsKernelBuilder *(*)(); - OpsKernelBuilderRegistrar(const std::string &kernel_lib_name, CreateFn fn); - ~OpsKernelBuilderRegistrar() = default; -}; - -#define REGISTER_OPS_KERNEL_BUILDER(kernel_lib_name, builder) \ - REGISTER_OPS_KERNEL_BUILDER_UNIQ_HELPER(__COUNTER__, kernel_lib_name, builder) - -#define REGISTER_OPS_KERNEL_BUILDER_UNIQ_HELPER(ctr, kernel_lib_name, builder) \ - REGISTER_OPS_KERNEL_BUILDER_UNIQ(ctr, kernel_lib_name, builder) - -#define REGISTER_OPS_KERNEL_BUILDER_UNIQ(ctr, kernel_lib_name, builder) \ - static ::ge::OpsKernelBuilderRegistrar register_op_kernel_builder_##ctr \ - __attribute__((unused)) = \ - ::ge::OpsKernelBuilderRegistrar(kernel_lib_name, []()->::ge::OpsKernelBuilder* { \ - return new (std::nothrow) builder(); \ - }) -} // namespace ge - -#endif // INC_REGISTER_OPS_KERNEL_BUILDER_REGISTRY_H_ diff --git a/third_party/fwkacllib/inc/register/register.h b/third_party/fwkacllib/inc/register/register.h deleted file mode 100644 index d98edaa4..00000000 --- a/third_party/fwkacllib/inc/register/register.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright 2019-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 INC_REGISTER_REGISTRY_H_ -#define INC_REGISTER_REGISTRY_H_ - -#include "external/register/register.h" -#include "external/ge/ge_api_error_codes.h" - -namespace ge { -class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY HostCpuOp { - public: - HostCpuOp() = default; - virtual ~HostCpuOp() = default; - - virtual graphStatus Compute(Operator &op, - const std::map &inputs, - std::map &outputs) = 0; -}; - -class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY HostCpuOpRegistrar { - public: - HostCpuOpRegistrar(const char *op_type, HostCpuOp *(*create_fn)()); - ~HostCpuOpRegistrar() = default; -}; - -#define REGISTER_HOST_CPU_OP_BUILDER(name, op) \ - REGISTER_HOST_CPU_OP_BUILDER_UNIQ_HELPER(__COUNTER__, name, op) - -#define REGISTER_HOST_CPU_OP_BUILDER_UNIQ_HELPER(ctr, name, op) \ - REGISTER_HOST_CPU_OP_BUILDER_UNIQ(ctr, name, op) - -#define REGISTER_HOST_CPU_OP_BUILDER_UNIQ(ctr, name, op) \ - static ::ge::HostCpuOpRegistrar register_host_cpu_op##ctr \ - __attribute__((unused)) = \ - ::ge::HostCpuOpRegistrar(name, []()->::ge::HostCpuOp* { \ - return new (std::nothrow) op(); \ - }) -} // namespace ge - -#endif //INC_REGISTER_REGISTRY_H_ diff --git a/third_party/fwkacllib/inc/register/register_format_transfer.h b/third_party/fwkacllib/inc/register/register_format_transfer.h deleted file mode 100644 index 72da94fc..00000000 --- a/third_party/fwkacllib/inc/register/register_format_transfer.h +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright 2019-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 INC_REGISTER_REGISTER_FORMAT_TRANSFER_H_ -#define INC_REGISTER_REGISTER_FORMAT_TRANSFER_H_ - -#include -#include -#include - -#include "external/graph/types.h" -#include "ge/ge_api_error_codes.h" - -namespace ge { -namespace formats { -struct TransArgs { - const uint8_t *data; - Format src_format; - Format dst_format; - // For scenes that need to supplement the shape, for example, 5D to 4D - // It is not possible to convert the format normally if you only get the src_shape, - // and must get the shape before you mend the shape. - // So the parameters here need to be passed in both src_shape and dst_shape - std::vector src_shape; - std::vector dst_shape; - DataType src_data_type; -}; - -struct TransResult { - std::shared_ptr data; - // data length in bytes - size_t length; -}; - -class FormatTransfer { - public: - virtual ~FormatTransfer() = default; - virtual Status TransFormat(const TransArgs &args, TransResult &result) = 0; - virtual Status TransShape(Format src_format, const std::vector &src_shape, DataType data_type, - Format dst_format, std::vector &dst_shape) = 0; -}; - -using FormatTransferBuilder = std::function()>; - -class FormatTransferRegister { - public: - FormatTransferRegister(FormatTransferBuilder builder, Format src, Format dst); - ~FormatTransferRegister() = default; -}; - -#define REGISTER_FORMAT_TRANSFER(TransferClass, format1, format2) \ - namespace { \ - FormatTransferRegister format_transfer_register_##TransferClass##format1##format2( \ - []() { return std::make_shared(); }, format1, format2); \ - } - -/// Build a formattransfer according to 'args' -/// @param args -/// @param result -/// @return -std::shared_ptr BuildFormatTransfer(const TransArgs &args); - -bool FormatTransferExists(const TransArgs &args); -} // namespace formats -} // namespace ge -#endif // INC_REGISTER_REGISTER_FORMAT_TRANSFER_H_ \ No newline at end of file