From 6836213e68393abc74219c39423791d79c8a86dd Mon Sep 17 00:00:00 2001 From: yanghaoran Date: Fri, 29 Apr 2022 10:31:18 +0800 Subject: [PATCH] fix headers --- .../inc/aicpu/aicpu_schedule/aicpu_op_type_list.h | 50 ++++++++++ .../fwkacllib/inc/aicpu/common/aicpu_task_struct.h | 104 +++++++++++++++++++++ third_party/fwkacllib/inc/common/type_def.h | 48 ++++++++++ third_party/fwkacllib/inc/tsd/status.h | 29 ++++++ 4 files changed, 231 insertions(+) create mode 100644 third_party/fwkacllib/inc/aicpu/aicpu_schedule/aicpu_op_type_list.h create mode 100644 third_party/fwkacllib/inc/aicpu/common/aicpu_task_struct.h create mode 100644 third_party/fwkacllib/inc/common/type_def.h create mode 100644 third_party/fwkacllib/inc/tsd/status.h diff --git a/third_party/fwkacllib/inc/aicpu/aicpu_schedule/aicpu_op_type_list.h b/third_party/fwkacllib/inc/aicpu/aicpu_schedule/aicpu_op_type_list.h new file mode 100644 index 00000000..dbf94462 --- /dev/null +++ b/third_party/fwkacllib/inc/aicpu/aicpu_schedule/aicpu_op_type_list.h @@ -0,0 +1,50 @@ +/** + * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. + * + * 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 AICPU_OP_TYPE_LIST_H_ +#define AICPU_OP_TYPE_LIST_H_ + +extern "C" { +enum OpKernelType { TF_KERNEL, CPU_KERNEL }; + +enum ReturnCode { OP_TYPE_NOT_SUPPORT, FORMAT_NOT_SUPPORT, DTYPE_NOT_SUPPORT }; + +#pragma pack(push, 1) +// One byte alignment +struct SysOpInfo { + uint64_t opLen; + uint64_t opType; + OpKernelType kernelsType; +}; + +struct SysOpCheckInfo { + uint64_t opListNum; + uint64_t offSetLen; + uint64_t sysOpInfoList; + uint64_t opParamInfoList; +}; + +struct SysOpCheckResp { + uint64_t opListNum; + bool isWithoutJson; + uint64_t returnCodeList; + uint64_t sysOpInfoList; + uint64_t opParamInfoList; +}; +#pragma pack(pop) +} + +#endif // AICPU_OP_TYPE_LIST_H_ diff --git a/third_party/fwkacllib/inc/aicpu/common/aicpu_task_struct.h b/third_party/fwkacllib/inc/aicpu/common/aicpu_task_struct.h new file mode 100644 index 00000000..6dd83403 --- /dev/null +++ b/third_party/fwkacllib/inc/aicpu/common/aicpu_task_struct.h @@ -0,0 +1,104 @@ +/** + * 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 AICPU_TASK_STRUCT_H +#define AICPU_TASK_STRUCT_H + +#include + +namespace aicpu { + +using char_t = char; + +#pragma pack(push, 1) +struct AicpuParamHead { + uint32_t length; // Total length: include cunstom message + uint32_t ioAddrNum; // Input and output address number + uint32_t extInfoLength; // extInfo struct Length + uint64_t extInfoAddr; // extInfo address +}; + +enum class AicpuConfigMsgType { + AICPU_CONFIG_MSG_TYPE_BUF_FREE = 0, /* free buf */ + AICPU_CONFIG_MSG_TYPE_BUF_RESET = 1, /* reset buf */ + AICPU_CONFIG_MSG_TYPE_BUF_SET_ADDR = 2, /* set buf addr to aicpu */ +}; + +enum class AicpuErrMsgType { + ERR_MSG_TYPE_NULL = 0, + ERR_MSG_TYPE_AICORE = 1, + ERR_MSG_TYPE_AICPU = 2, +}; + +enum class AicpuExtInfoMsgType { + EXT_MODEL_ID_MSG_TYPE = 0, +}; + +struct AicpuConfigMsg { + uint8_t msgType; + uint8_t reserved1; + uint16_t bufLen; + uint32_t offset; + uint64_t bufAddr; + uint32_t tsId; + uint32_t reserved2; +}; + +struct AicpuModelIdInfo { + uint32_t modelId; + uint32_t extendModelId; + uint32_t extendInfo[13]; +}; + +// 64 bytes +struct AicpuExtendInfo { + uint8_t msgType; + uint8_t version; + uint8_t reserved[2]; + union { + AicpuModelIdInfo modelIdMap; + }; +}; + +struct AicoreErrMsgInfo { + uint8_t errType; + uint8_t version; + uint8_t reserved1[2]; /* reserved1, 4 byte alignment */ + uint32_t errorCode; + uint32_t modelId; + uint32_t taskId; + uint32_t streamId; + uint64_t transactionId; + uint8_t reserved2[228]; /* the total byte is 256, reserved2 len = 256 - other lens */ +}; + +struct AicpuErrMsgInfo { + uint8_t errType; + uint8_t version; + uint8_t reserved1[2]; /* reserved1, 4 byte alignment */ + uint32_t errorCode; + uint32_t modelId; + uint32_t streamId; + uint64_t transactionId; + char_t opName[64]; /* op name str */ + char_t errDesc[128]; /* err msg desc info */ + uint8_t reserved2[40]; /* the total byte is 256, reserved2 len = 256 - other lens */ +}; +#pragma pack(pop) + +} // namespace aicpu + +#endif // AICPU_TASK_STRUCT_H diff --git a/third_party/fwkacllib/inc/common/type_def.h b/third_party/fwkacllib/inc/common/type_def.h new file mode 100644 index 00000000..043b550d --- /dev/null +++ b/third_party/fwkacllib/inc/common/type_def.h @@ -0,0 +1,48 @@ +/** + * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Description:interface. + * Create: 2021-12-21 + */ +#ifndef AICPU_TYPE_DEF_H +#define AICPU_TYPE_DEF_H + +#include +#include +#ifndef char_t +typedef char char_t; +#endif + +#ifndef float32_t +typedef float float32_t; +#endif + +#ifndef float64_t +typedef double float64_t; +#endif + +inline uint64_t PtrToValue(const void *ptr) { + return static_cast(reinterpret_cast(ptr)); +} + +inline void *ValueToPtr(const uint64_t value) { + return reinterpret_cast(static_cast(value)); +} + +template +inline TO *PtrToPtr(TI *ptr) { + return reinterpret_cast(ptr); +} + +template +inline T *PtrAdd(T *const ptr, const size_t maxIdx, const size_t idx) { + if ((ptr != nullptr) && (idx < maxIdx)) { + return reinterpret_cast(ptr + idx); + } + return nullptr; +} +#endif // AICPU_TYPE_DEF_H diff --git a/third_party/fwkacllib/inc/tsd/status.h b/third_party/fwkacllib/inc/tsd/status.h new file mode 100644 index 00000000..1010aefb --- /dev/null +++ b/third_party/fwkacllib/inc/tsd/status.h @@ -0,0 +1,29 @@ +/** + * Copyright (c) Hisilicon Technologies Co., Ltd. 2019-2021. All rights reserved. + * + * 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_TDT_STATUS_H +#define INC_TDT_STATUS_H +#include "common/type_def.h" +namespace tsd { +#ifdef __cplusplus +using TSD_StatusT = uint32_t; +#else +typedef uint32_t TSD_StatusT; +#endif +// success code +constexpr TSD_StatusT TSD_OK = 0U; +} // namespace tsd +#endif // INC_TDT_STATUS_H