* Copyright (c) 2025 Huawei Technologies Co., Ltd.
* This program is free software, you can redistribute it and/or modify it under the terms and conditions of
* CANN Open Software License Agreement Version 2.0 (the "License").
* Please refer to the License for details. You may not use this file except in compliance with the License.
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
* See LICENSE in the root of the software repository for the full text of the License.
*/
* \file mc2_moe_utils.h
* \brief
*/
#ifndef OPS_COMMON_INC_MC2_MOE_UTIL_H
#define OPS_COMMON_INC_MC2_MOE_UTIL_H
#include "mc2_log.h"
namespace Mc2Moe {
const size_t SUPPORT_DIM_NUM = 3;
const size_t BIAS_SUPPORT_DIM_NUM = 2;
const size_t DIM_E = 0;
const size_t X_DIM_C = 1;
const size_t X_DIM_H = 2;
const size_t X_DIM_M = 2;
const int64_t VALUE_E_MIN = 2;
const int64_t VALUE_E_MAX = 512;
const int64_t VALUE_H_MIN = 1;
const int64_t VALUE_H_MAX = 65535;
const int64_t VALUE_C_MIN = 1;
struct OutShapeInfo {
int64_t e;
int64_t c;
int64_t h;
};
bool EpTpSizeCheck(const int64_t epSize, const int64_t tpSize);
bool DimNumCheck(const char *nodeName, const gert::Shape *xShape, const gert::Shape *weightShape);
bool GroupCheck(const char *nodeName, const char *groupEp, const char *groupTp);
void DynamicShapeCheck(
const gert::Shape *xShape, const gert::Shape *weightShape, const size_t wDim, OutShapeInfo &outShapeInfo);
void EmptyShapeCheck(
const gert::Shape *xShape, const gert::Shape *weightShape, const size_t wDim, OutShapeInfo &outShapeInfo);
bool CheckBiasDtype(const char *nodeName, const ge::DataType xType, const ge::DataType biasType);
bool CheckTensorDtype(
const char *nodeName, const ge::DataType xType, const ge::DataType weightType, const ge::DataType biasType);
void SetShape(gert::Shape *shape, const OutShapeInfo &outShapeInfo);
void TransDimHMIdx(const bool isTransW, size_t &wDimH, size_t &wDimM);
void PrintTensorShape(const char *nodeName, const gert::Shape *shape, const char *shapeName);
}
#endif