Ai
8 Star 126 Fork 6

Ascend/cann-var-sequence-gemm
暂停

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
kernel_utils.h 1.91 KB
一键复制 编辑 原始数据 按行查看 历史
/*
Copyright (c) 2025 Huawei Technologies Co., Ltd.
This file is a part of the CANN Open Software.
Licensed under CANN Open Software License Agreement Version 1.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.
*/
#pragma once
#include "kernel_operator.h"
/**
算子内部用到的utils函数
*/
/**
* @brief val 向上按照 align 的倍数取整
* @param [in] T val:需要取整的数
* @param [in] align:需要向上取整的最小粒度
* @return T 向上对齐后的值
*/
template<typename T>
[aicore] inline __attribute__((always_inline)) T RoundUp (const T val, const T align) {
if ( align == 0 ) {
return 0;
} else {
return ( val + align - 1 ) / align * align ;
}
}
/**
* @brief val 向下按照 align 的倍数取整
* @param [in] T val:需要取整的数
* @param [in] T align:需要向下取整的最小粒度
* @return T 向下对齐后的数
*/
template<typename T>
[aicore] inline __attribute__((always_inline)) T RoundDown ( const T val, const T align ) {
if ( align == 0 ) {
return 0;
} else {
return val / align * align;
}
}
/**
* @brief val 除以 divisor 向上取整
* @param [in] T val:被除数
* @param [in] T divisor:除数
* @return T val除以divisor向上取整的结果
*/
template<typename T>
[aicore] inline __attribute__((always_inline)) T CeilDiv ( const T val, const T divisor ){
if ( divisor == 0 ) {
return 0;
} else {
return ( val + divisor - 1 ) / divisor;
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ascend/cann-var-sequence-gemm.git
git@gitee.com:ascend/cann-var-sequence-gemm.git
ascend
cann-var-sequence-gemm
cann-var-sequence-gemm
master

搜索帮助