-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
322 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
# must define SRC DST CLASS | ||
|
||
file(READ ${SRC} source_data) | ||
|
||
# replace | ||
string(TOUPPER ${CLASS} CLASS_UPPER) | ||
string(TOLOWER ${CLASS} CLASS_LOWER) | ||
|
||
string(REGEX REPLACE "LAYER_${CLASS_UPPER}_RISCV_H" "LAYER_${CLASS_UPPER}_RISCV_XTHEADVECTOR_H" source_data "${source_data}") | ||
string(REGEX REPLACE "${CLASS}_riscv" "${CLASS}_riscv_xtheadvector" source_data "${source_data}") | ||
string(REGEX REPLACE "#include \"${CLASS_LOWER}_riscv.h\"" "#include \"${CLASS_LOWER}_riscv_xtheadvector.h\"" source_data "${source_data}") | ||
|
||
file(WRITE ${DST} "${source_data}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Tencent is pleased to support the open source community by making ncnn available. | ||
// | ||
// Copyright (C) 2024 THL A29 Limited, a Tencent company. All rights reserved. | ||
// | ||
// Licensed under the BSD 3-Clause License (the "License"); you may not use this file except | ||
// in compliance with the License. You may obtain a copy of the License at | ||
// | ||
// https://opensource.org/licenses/BSD-3-Clause | ||
// | ||
// 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. | ||
|
||
|
||
#if NCNN_RUNTIME_CPU && NCNN_ZVFH && __riscv_vector && !__riscv_zvfh | ||
void absval_fp16_zvfh(Mat& bottom_top_blob, const Option& opt); | ||
#endif | ||
|
||
#if __riscv_zvfh | ||
static inline vfloat16m8_t __riscv_vfabs_v_f16m8_absval(vfloat16m8_t op1, size_t vl) | ||
{ | ||
return __riscv_vfsgnjx_vv_f16m8(op1, op1, vl); | ||
} | ||
#endif // __riscv_zvfh | ||
|
||
static void absval_fp16(Mat& bottom_top_blob, const Option& opt) | ||
{ | ||
#if NCNN_RUNTIME_CPU && NCNN_ZVFH && __riscv_vector && !__riscv_xtheadvector && !__riscv_zvfh | ||
if (ncnn::cpu_support_riscv_zvfh()) | ||
{ | ||
absval_fp16_zvfh(bottom_top_blob, opt); | ||
return; | ||
} | ||
#endif | ||
|
||
#if __riscv_zvfh | ||
const int w = bottom_top_blob.w; | ||
const int h = bottom_top_blob.h; | ||
const int d = bottom_top_blob.d; | ||
const int channels = bottom_top_blob.c; | ||
const int elempack = bottom_top_blob.elempack; | ||
const int size = w * h * d * elempack; | ||
|
||
#pragma omp parallel for num_threads(opt.num_threads) | ||
for (int q = 0; q < channels; q++) | ||
{ | ||
__fp16* ptr = bottom_top_blob.channel(q); | ||
|
||
int n = size; | ||
while (n > 0) | ||
{ | ||
size_t vl = __riscv_vsetvl_e16m8(n); | ||
|
||
vfloat16m8_t _p = __riscv_vle16_v_f16m8(ptr, vl); | ||
_p = __riscv_vfabs_v_f16m8_absval(_p, vl); | ||
__riscv_vse16_v_f16m8(ptr, _p, vl); | ||
|
||
ptr += vl; | ||
n -= vl; | ||
} | ||
} | ||
#else | ||
(void)bottom_top_blob; | ||
(void)opt; | ||
#endif // __riscv_zvfh | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ | |
|
||
#include "riscv_usability.h" | ||
|
||
#include "cpu.h" | ||
|
||
namespace ncnn { | ||
|
||
Packing_riscv::Packing_riscv() | ||
|
Oops, something went wrong.