├── AppScope
├── app.json5
└── resources
│ └── base
│ ├── element
│ └── string.json
│ └── media
│ ├── ncnn_icon.png
│ └── ncnn_logo.png
├── README.md
├── Screenshots
├── benchmark.png
├── camera.png
├── config.png
├── inference.png
└── main.png
├── build-profile.json5
├── code-linter.json5
├── entry
├── build-profile.json5
├── hvigorfile.ts
├── obfuscation-rules.txt
├── oh-package-lock.json5
├── oh-package.json5
└── src
│ ├── main
│ ├── ets
│ │ ├── camera
│ │ │ ├── CameraView.ets
│ │ │ └── NNCameraViewController.ets
│ │ ├── entryability
│ │ │ └── EntryAbility.ets
│ │ ├── entrybackupability
│ │ │ └── EntryBackupAbility.ets
│ │ ├── jsexception
│ │ │ └── JSGlobalException.ets
│ │ ├── model
│ │ │ ├── BenchmarkNcnnType.ets
│ │ │ └── ModelList.ets
│ │ ├── pages
│ │ │ ├── CameraPage.ets
│ │ │ ├── Main.ets
│ │ │ └── PhotoPage.ets
│ │ ├── types
│ │ │ └── Types.ts
│ │ ├── utils
│ │ │ ├── ColorUtil.ts
│ │ │ ├── ConstantKey.ts
│ │ │ ├── DrawUtils.ets
│ │ │ └── FileUtils.ets
│ │ └── views
│ │ │ ├── MenuOption.ets
│ │ │ ├── NavBar.ets
│ │ │ └── OptionDialogContent.ets
│ ├── module.json5
│ └── resources
│ │ ├── base
│ │ ├── element
│ │ │ ├── color.json
│ │ │ ├── integer.json
│ │ │ └── string.json
│ │ ├── media
│ │ │ ├── background.png
│ │ │ ├── cpu.png
│ │ │ ├── cpu_white.png
│ │ │ ├── foreground.png
│ │ │ ├── gpu.png
│ │ │ ├── gpu_white.png
│ │ │ ├── icon_arrow_down.png
│ │ │ ├── icon_arrow_down_white.png
│ │ │ ├── icon_arrow_left_white.png
│ │ │ ├── layered_image.json
│ │ │ ├── ncnn_icon.png
│ │ │ ├── ncnn_logo.png
│ │ │ └── ohhh.png
│ │ └── profile
│ │ │ ├── backup_config.json
│ │ │ └── main_pages.json
│ │ ├── en_US
│ │ └── element
│ │ │ └── string.json
│ │ └── zh_CN
│ │ └── element
│ │ └── string.json
│ ├── mock
│ └── mock-config.json5
│ ├── ohosTest
│ ├── ets
│ │ └── test
│ │ │ ├── Ability.test.ets
│ │ │ └── List.test.ets
│ └── module.json5
│ └── test
│ ├── List.test.ets
│ └── LocalUnit.test.ets
├── hvigor
└── hvigor-config.json5
├── hvigorfile.ts
├── local.properties
├── oh-package-lock.json5
├── oh-package.json5
└── tncnn
├── build-profile.json5
├── hvigorfile.ts
├── libs
├── arm64-v8a
│ ├── include
│ │ ├── glslang
│ │ │ ├── Include
│ │ │ │ ├── BaseTypes.h
│ │ │ │ ├── Common.h
│ │ │ │ ├── ConstantUnion.h
│ │ │ │ ├── InfoSink.h
│ │ │ │ ├── InitializeGlobals.h
│ │ │ │ ├── PoolAlloc.h
│ │ │ │ ├── ResourceLimits.h
│ │ │ │ ├── ShHandle.h
│ │ │ │ ├── SpirvIntrinsics.h
│ │ │ │ ├── Types.h
│ │ │ │ ├── arrays.h
│ │ │ │ ├── glslang_c_interface.h
│ │ │ │ ├── glslang_c_shader_types.h
│ │ │ │ └── intermediate.h
│ │ │ ├── MachineIndependent
│ │ │ │ ├── Initialize.h
│ │ │ │ ├── LiveTraverser.h
│ │ │ │ ├── ParseHelper.h
│ │ │ │ ├── RemoveTree.h
│ │ │ │ ├── Scan.h
│ │ │ │ ├── ScanContext.h
│ │ │ │ ├── SymbolTable.h
│ │ │ │ ├── Versions.h
│ │ │ │ ├── attribute.h
│ │ │ │ ├── gl_types.h
│ │ │ │ ├── glslang_tab.cpp.h
│ │ │ │ ├── iomapper.h
│ │ │ │ ├── localintermediate.h
│ │ │ │ ├── parseVersions.h
│ │ │ │ ├── preprocessor
│ │ │ │ │ ├── PpContext.h
│ │ │ │ │ └── PpTokens.h
│ │ │ │ ├── propagateNoContraction.h
│ │ │ │ └── reflection.h
│ │ │ ├── Public
│ │ │ │ ├── ResourceLimits.h
│ │ │ │ ├── ShaderLang.h
│ │ │ │ └── resource_limits_c.h
│ │ │ ├── SPIRV
│ │ │ │ ├── GLSL.ext.AMD.h
│ │ │ │ ├── GLSL.ext.EXT.h
│ │ │ │ ├── GLSL.ext.KHR.h
│ │ │ │ ├── GLSL.ext.NV.h
│ │ │ │ ├── GLSL.std.450.h
│ │ │ │ ├── GlslangToSpv.h
│ │ │ │ ├── Logger.h
│ │ │ │ ├── NonSemanticDebugPrintf.h
│ │ │ │ ├── NonSemanticShaderDebugInfo100.h
│ │ │ │ ├── SPVRemapper.h
│ │ │ │ ├── SpvBuilder.h
│ │ │ │ ├── SpvTools.h
│ │ │ │ ├── bitutils.h
│ │ │ │ ├── disassemble.h
│ │ │ │ ├── doc.h
│ │ │ │ ├── hex_float.h
│ │ │ │ ├── spirv.hpp
│ │ │ │ └── spvIR.h
│ │ │ └── build_info.h
│ │ └── ncnn
│ │ │ ├── allocator.h
│ │ │ ├── benchmark.h
│ │ │ ├── blob.h
│ │ │ ├── c_api.h
│ │ │ ├── command.h
│ │ │ ├── cpu.h
│ │ │ ├── datareader.h
│ │ │ ├── gpu.h
│ │ │ ├── layer.h
│ │ │ ├── layer_shader_type.h
│ │ │ ├── layer_shader_type_enum.h
│ │ │ ├── layer_type.h
│ │ │ ├── layer_type_enum.h
│ │ │ ├── mat.h
│ │ │ ├── modelbin.h
│ │ │ ├── ncnn_export.h
│ │ │ ├── net.h
│ │ │ ├── option.h
│ │ │ ├── paramdict.h
│ │ │ ├── pipeline.h
│ │ │ ├── pipelinecache.h
│ │ │ ├── platform.h
│ │ │ ├── simplemath.h
│ │ │ ├── simpleocv.h
│ │ │ ├── simpleomp.h
│ │ │ ├── simplestl.h
│ │ │ ├── simplevk.h
│ │ │ └── vulkan_header_fix.h
│ └── lib
│ │ ├── cmake
│ │ ├── OGLCompilerTargets.cmake
│ │ ├── OSDependentTargets.cmake
│ │ ├── SPIRVTargets.cmake
│ │ ├── glslang
│ │ │ ├── glslang-config-version.cmake
│ │ │ ├── glslang-config.cmake
│ │ │ ├── glslang-targets-release.cmake
│ │ │ └── glslang-targets.cmake
│ │ ├── glslangTargets.cmake
│ │ └── ncnn
│ │ │ ├── ncnn-release.cmake
│ │ │ ├── ncnn.cmake
│ │ │ └── ncnnConfig.cmake
│ │ ├── libGenericCodeGen.a
│ │ ├── libMachineIndependent.a
│ │ ├── libOGLCompiler.a
│ │ ├── libOSDependent.a
│ │ ├── libSPIRV.a
│ │ ├── libglslang.a
│ │ ├── libncnn.a
│ │ └── pkgconfig
│ │ └── ncnn.pc
└── x86_64
│ ├── include
│ └── ncnn
│ │ ├── allocator.h
│ │ ├── benchmark.h
│ │ ├── blob.h
│ │ ├── c_api.h
│ │ ├── command.h
│ │ ├── cpu.h
│ │ ├── datareader.h
│ │ ├── gpu.h
│ │ ├── layer.h
│ │ ├── layer_shader_type.h
│ │ ├── layer_shader_type_enum.h
│ │ ├── layer_type.h
│ │ ├── layer_type_enum.h
│ │ ├── mat.h
│ │ ├── modelbin.h
│ │ ├── ncnn_export.h
│ │ ├── net.h
│ │ ├── option.h
│ │ ├── paramdict.h
│ │ ├── pipeline.h
│ │ ├── pipelinecache.h
│ │ ├── platform.h
│ │ ├── simplemath.h
│ │ ├── simpleocv.h
│ │ ├── simpleomp.h
│ │ ├── simplestl.h
│ │ ├── simplevk.h
│ │ └── vulkan_header_fix.h
│ └── lib
│ ├── cmake
│ └── ncnn
│ │ ├── ncnn-release.cmake
│ │ ├── ncnn.cmake
│ │ └── ncnnConfig.cmake
│ ├── libncnn.a
│ └── pkgconfig
│ └── ncnn.pc
├── obfuscation-rules.txt
├── oh-package-lock.json5
├── oh-package.json5
└── src
├── main
├── cpp
│ ├── CMakeLists.txt
│ ├── benchmark_ncnn.cpp
│ ├── benchmark_ncnn.h
│ ├── nanodet.cpp
│ ├── nanodet.h
│ ├── napi_init.cpp
│ ├── types
│ │ └── libtncnn
│ │ │ ├── Index.d.ts
│ │ │ └── oh-package.json5
│ ├── yolov4.cpp
│ └── yolov4.h
├── ets
│ ├── pages
│ │ └── Tncnn.ets
│ ├── tncnnability
│ │ └── TncnnAbility.ets
│ └── utils
│ │ └── ConstantKey.ts
├── module.json5
└── resources
│ ├── base
│ ├── element
│ │ ├── color.json
│ │ └── string.json
│ ├── media
│ │ ├── background.png
│ │ ├── foreground.png
│ │ ├── layered_image.json
│ │ ├── ncnn_icon.png
│ │ └── ncnn_logo.png
│ └── profile
│ │ └── main_pages.json
│ ├── en_US
│ └── element
│ │ └── string.json
│ ├── rawfile
│ └── models
│ │ ├── nanodet-m.bin
│ │ ├── nanodet-m.param
│ │ ├── yolov4-tiny.bin
│ │ └── yolov4-tiny.param
│ └── zh_CN
│ └── element
│ └── string.json
├── mock
├── Libtncnn.mock.ets
└── mock-config.json5
├── ohosTest
├── ets
│ └── test
│ │ ├── Ability.test.ets
│ │ └── List.test.ets
└── module.json5
└── test
├── List.test.ets
└── LocalUnit.test.ets
/AppScope/app.json5:
--------------------------------------------------------------------------------
1 | {
2 | "app": {
3 | "bundleName": "com.teng.ncnnharmony",
4 | "vendor": "example",
5 | "versionCode": 1000000,
6 | "versionName": "1.0.0",
7 | "icon": "$media:ncnn_icon",
8 | "label": "$string:app_name"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/AppScope/resources/base/element/string.json:
--------------------------------------------------------------------------------
1 | {
2 | "string": [
3 | {
4 | "name": "app_name",
5 | "value": "ncnn"
6 | }
7 | ]
8 | }
9 |
--------------------------------------------------------------------------------
/AppScope/resources/base/media/ncnn_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/AppScope/resources/base/media/ncnn_icon.png
--------------------------------------------------------------------------------
/AppScope/resources/base/media/ncnn_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/AppScope/resources/base/media/ncnn_logo.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## :rocket: 如果有帮助,点个star!:star: ##
2 |
3 | ### 鸿蒙 OS ncnn 部署,项目示例 YOLOv4-tiny、nanodet-m 模型。
4 |
5 | ## Harmony OS:
6 | - DevEco Studio 5.0.0
7 | - NEXT API12
8 |
9 | ```code
10 | 从界面中选择需要测试的模型。
11 | ```
12 | ### 模型
13 | | model | Harmony OS | from | other |
14 | |-------------------|:--------:|:--------:|:---------------------------------------------------------------------------------------------------------------------------------:|
15 | | YOLOv4-tiny | yes | [Github](https://github.com/ultralytics/yolov3) | [ncnn](https://github.com/cmdbug/YOLOv5_NCNN) |
16 | | NanoDet | yes | [Github](https://github.com/RangiLyu/nanodet) | [ncnn](https://github.com/cmdbug/YOLOv5_NCNN) [TNN](https://github.com/cmdbug/TNN_Demo) [MNN](https://github.com/cmdbug/MNN_Demo) |
17 |
18 |
19 | ### Harmony OS:
20 | - 模拟器运行的是非 vulkan 版本
21 | - 真机运行需要自己配置下签名证书(可以自动生成)
22 | - 示例可能存在bug,555
23 |
24 | 该项目是练习各种模型的使用与部署,在速度上没有过多处理。如果对速度有要求需要自行处理。项目模型放在 tncnn 模块下,使用时把 rawfile 里面的模型复制到沙盒中,再使用沙盒的路径完成模型加载,直接加载 rawfile 中的模型比较麻烦,有需要的自行处理。
25 |
26 | 懒人本地转换(不会上传模型): [xxxx -> ncnn](https://convertmodel.com/)
27 |
28 | 轻量级OpenCV:[opencv-mobile](https://github.com/nihui/opencv-mobile)
29 |
30 | :art: 截图
31 |
32 | > Harmony OS
33 |
34 | | 主页 | 示例 | 配置 |
35 | |--------------------------------------------------------------|-------------------------------------------------------------------|----------------------------------------------------------------|
36 | |
|
|
|
37 |
38 | | 基准测试 (模拟器结果仅供参考) | 相机 |
39 | |-------------------------------------------------------------------|----------------------------------------------------------------|
40 | |
|
|
41 |
42 |
43 | 感谢:
44 | - nihui, RangiLyu
45 | - https://github.com/Tencent/ncnn
46 |
47 |
--------------------------------------------------------------------------------
/Screenshots/benchmark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/Screenshots/benchmark.png
--------------------------------------------------------------------------------
/Screenshots/camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/Screenshots/camera.png
--------------------------------------------------------------------------------
/Screenshots/config.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/Screenshots/config.png
--------------------------------------------------------------------------------
/Screenshots/inference.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/Screenshots/inference.png
--------------------------------------------------------------------------------
/Screenshots/main.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/Screenshots/main.png
--------------------------------------------------------------------------------
/build-profile.json5:
--------------------------------------------------------------------------------
1 | {
2 | "app": {
3 | "signingConfigs": [
4 |
5 | ],
6 | "products": [
7 | {
8 | "name": "default",
9 | "signingConfig": "default",
10 | "compatibleSdkVersion": "5.0.0(12)",
11 | "runtimeOS": "HarmonyOS",
12 | "buildOption": {
13 | "strictMode": {
14 | "caseSensitiveCheck": true,
15 | "useNormalizedOHMUrl": true
16 | }
17 | }
18 | }
19 | ],
20 | "buildModeSet": [
21 | {
22 | "name": "debug",
23 | },
24 | {
25 | "name": "release"
26 | }
27 | ]
28 | },
29 | "modules": [
30 | {
31 | "name": "entry",
32 | "srcPath": "./entry",
33 | "targets": [
34 | {
35 | "name": "default",
36 | "applyToProducts": [
37 | "default"
38 | ]
39 | }
40 | ]
41 | },
42 | {
43 | "name": "tncnn",
44 | "srcPath": "./tncnn",
45 | "targets": [
46 | {
47 | "name": "default",
48 | "applyToProducts": [
49 | "default"
50 | ]
51 | }
52 | ]
53 | }
54 | ]
55 | }
--------------------------------------------------------------------------------
/code-linter.json5:
--------------------------------------------------------------------------------
1 | {
2 | "files": [
3 | "**/*.ets"
4 | ],
5 | "ignore": [
6 | "**/src/ohosTest/**/*",
7 | "**/src/test/**/*",
8 | "**/src/mock/**/*",
9 | "**/node_modules/**/*",
10 | "**/oh_modules/**/*",
11 | "**/build/**/*",
12 | "**/.preview/**/*"
13 | ],
14 | "ruleSet": [
15 | "plugin:@performance/recommended",
16 | "plugin:@typescript-eslint/recommended"
17 | ],
18 | "rules": {
19 | }
20 | }
--------------------------------------------------------------------------------
/entry/build-profile.json5:
--------------------------------------------------------------------------------
1 | {
2 | "apiType": "stageMode",
3 | "buildOption": {
4 | "externalNativeOptions": {
5 | "abiFilters": [
6 | "arm64-v8a",
7 | "x86_64"
8 | ]
9 | }
10 | },
11 | "buildOptionSet": [
12 | {
13 | "name": "release",
14 | "arkOptions": {
15 | "obfuscation": {
16 | "ruleOptions": {
17 | "enable": false,
18 | "files": [
19 | "./obfuscation-rules.txt"
20 | ]
21 | }
22 | }
23 | }
24 | },
25 | ],
26 | "targets": [
27 | {
28 | "name": "default"
29 | },
30 | {
31 | "name": "ohosTest",
32 | }
33 | ]
34 | }
--------------------------------------------------------------------------------
/entry/hvigorfile.ts:
--------------------------------------------------------------------------------
1 | import { hapTasks } from '@ohos/hvigor-ohos-plugin';
2 |
3 | export default {
4 | system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
5 | plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
6 | }
7 |
--------------------------------------------------------------------------------
/entry/obfuscation-rules.txt:
--------------------------------------------------------------------------------
1 | # Define project specific obfuscation rules here.
2 | # You can include the obfuscation configuration files in the current module's build-profile.json5.
3 | #
4 | # For more details, see
5 | # https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
6 |
7 | # Obfuscation options:
8 | # -disable-obfuscation: disable all obfuscations
9 | # -enable-property-obfuscation: obfuscate the property names
10 | # -enable-toplevel-obfuscation: obfuscate the names in the global scope
11 | # -compact: remove unnecessary blank spaces and all line feeds
12 | # -remove-log: remove all console.* statements
13 | # -print-namecache: print the name cache that contains the mapping from the old names to new names
14 | # -apply-namecache: reuse the given cache file
15 |
16 | # Keep options:
17 | # -keep-property-name: specifies property names that you want to keep
18 | # -keep-global-name: specifies names that you want to keep in the global scope
19 |
20 | -enable-property-obfuscation
21 | -enable-toplevel-obfuscation
22 | -enable-filename-obfuscation
23 | -enable-export-obfuscation
--------------------------------------------------------------------------------
/entry/oh-package-lock.json5:
--------------------------------------------------------------------------------
1 | {
2 | "meta": {
3 | "stableOrder": true
4 | },
5 | "lockfileVersion": 3,
6 | "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
7 | "specifiers": {
8 | "libtncnn.so@../tncnn/src/main/cpp/types/libtncnn": "libtncnn.so@../tncnn/src/main/cpp/types/libtncnn"
9 | },
10 | "packages": {
11 | "libtncnn.so@../tncnn/src/main/cpp/types/libtncnn": {
12 | "name": "libtncnn.so",
13 | "version": "1.0.0",
14 | "resolved": "../tncnn/src/main/cpp/types/libtncnn",
15 | "registryType": "local"
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/entry/oh-package.json5:
--------------------------------------------------------------------------------
1 | {
2 | "name": "entry",
3 | "version": "1.0.0",
4 | "description": "Please describe the basic information.",
5 | "main": "",
6 | "author": "",
7 | "license": "",
8 | "dependencies": {
9 | "libtncnn.so": "file:../tncnn/src/main/cpp/types/libtncnn"
10 | }
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/entry/src/main/ets/camera/NNCameraViewController.ets:
--------------------------------------------------------------------------------
1 | export class NNCameraViewController {
2 |
3 | onPageShow: () => void = () => {}
4 | onPageHide: () => void = () => {}
5 | initCamera: () => void = () => {}
6 | releaseCamera: () => void = () => {}
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/entry/src/main/ets/entryability/EntryAbility.ets:
--------------------------------------------------------------------------------
1 | import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
2 | import { hilog } from '@kit.PerformanceAnalysisKit';
3 | import { window } from '@kit.ArkUI';
4 | import { BOTTOM_HEIGHT, TOP_HEIGHT } from '../utils/ConstantKey';
5 | import { AppUtil } from '@pura/harmony-utils';
6 | import { globalCrashCatch } from '../jsexception/JSGlobalException';
7 |
8 | export default class EntryAbility extends UIAbility {
9 | onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
10 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
11 |
12 | globalCrashCatch()
13 | }
14 |
15 | onDestroy(): void {
16 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
17 | }
18 |
19 | onWindowStageCreate(windowStage: window.WindowStage): void {
20 | // Main window is created, set main page for this ability
21 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
22 |
23 | windowStage.loadContent('pages/Main', (err) => {
24 | if (err.code) {
25 | hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
26 | return;
27 | }
28 | hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
29 | });
30 |
31 | // 设置全屏
32 | let windowClass = windowStage.getMainWindowSync()
33 | try {
34 | windowClass.setWindowLayoutFullScreen(true)
35 | } catch (e) {
36 | }
37 | // 安全区域
38 | this.setOrCreateSafeAreaView(windowClass)
39 | // 状态栏为白色
40 | windowClass.setWindowSystemBarProperties({
41 | // 状态栏文字颜色
42 | statusBarContentColor: '#FFFFFF'
43 | })
44 |
45 | AppUtil.init(this.context)
46 | }
47 |
48 | onWindowStageDestroy(): void {
49 | // Main window is destroyed, release UI related resources
50 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
51 | }
52 |
53 | onForeground(): void {
54 | // Ability has brought to foreground
55 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
56 | }
57 |
58 | onBackground(): void {
59 | // Ability has back to background
60 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
61 | }
62 |
63 | /**
64 | * 设置或创建安全区域
65 | * @param windowClass
66 | */
67 | setOrCreateSafeAreaView(windowClass: window.Window) {
68 | // 安全区域
69 | let topHeight = px2vp(windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM)
70 | .topRect
71 | .height) // 获取状态栏height
72 | let bottomHeight = px2vp(windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR)
73 | .bottomRect
74 | .height) // 获取导航栏height
75 | // console.log("状态栏:" + topHeight, "底部:" + bottomHeight)
76 | AppStorage.setOrCreate(TOP_HEIGHT, topHeight)
77 | AppStorage.setOrCreate(BOTTOM_HEIGHT, bottomHeight)
78 | // 安全区域发生了变化
79 | windowClass.on('avoidAreaChange', (data) => {
80 | if (data.type === window.AvoidAreaType.TYPE_SYSTEM) {
81 | let topRectHeight = px2vp(data.area.topRect.height)
82 | AppStorage.setOrCreate(TOP_HEIGHT, topRectHeight)
83 | } else if (data.type == window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) {
84 | let bottomRectHeight = px2vp(data.area.bottomRect.height)
85 | AppStorage.setOrCreate(BOTTOM_HEIGHT, bottomRectHeight)
86 | }
87 | })
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets:
--------------------------------------------------------------------------------
1 | import { hilog } from '@kit.PerformanceAnalysisKit';
2 | import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
3 |
4 | export default class EntryBackupAbility extends BackupExtensionAbility {
5 | async onBackup() {
6 | hilog.info(0x0000, 'testTag', 'onBackup ok');
7 | }
8 |
9 | async onRestore(bundleVersion: BundleVersion) {
10 | hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
11 | }
12 | }
--------------------------------------------------------------------------------
/entry/src/main/ets/jsexception/JSGlobalException.ets:
--------------------------------------------------------------------------------
1 | import { errorManager } from "@kit.AbilityKit";
2 | import { promptAction } from "@kit.ArkUI";
3 | import { BusinessError } from "@kit.BasicServicesKit";
4 |
5 | /**
6 | * 全局 js 未处理异常捕获
7 | */
8 | export function globalCrashCatch() {
9 | let observer1: errorManager.ErrorObserver = {
10 | onUnhandledException(errorMsg) {
11 | console.log('onUnhandledException, errorMsg: ', errorMsg);
12 | },
13 | onException(errorObj) {
14 | console.log('onException, name: ', errorObj.name);
15 | console.log('onException, message: ', errorObj.message);
16 | if (typeof (errorObj.stack) === 'string') {
17 | console.log('onException, stack: ', errorObj.stack);
18 | }
19 | promptAction.showToast({
20 | message: "警告:应用出现了未知异常"
21 | })
22 | }
23 | };
24 | let observerId = -1;
25 | try {
26 | // 注册错误观测器。注册后可以捕获到应用产生的js crash,应用崩溃时进程不会退出。
27 | observerId = errorManager.on('error', observer1);
28 | } catch (paramError) {
29 | let code = (paramError as BusinessError).code;
30 | let message = (paramError as BusinessError).message;
31 | console.error(`error: ${code}, ${message}`);
32 | }
33 |
34 | let observer2: errorManager.UnhandledRejectionObserver = (reason: Error, promise: Promise) => {
35 | if (promise === promise1) {
36 | console.log("promise1 is rejected");
37 | }
38 | console.log("reason.name: ", reason.name);
39 | console.log("reason.message: ", reason.message);
40 | if (reason.stack) {
41 | console.log("reason.stack: ", reason.stack);
42 | }
43 | promptAction.showToast({
44 | message: "警告:应用出现了未知错误"
45 | })
46 | };
47 |
48 | // 注册被拒绝promise监听器。注册后可以捕获到当前线程中未被捕获到的promise rejection。
49 | errorManager.on("unhandledRejection", observer2);
50 |
51 | let promise1 = new Promise(() => {
52 | }).then(() => {
53 | throw new Error("uncaught error");
54 | });
55 | }
56 |
--------------------------------------------------------------------------------
/entry/src/main/ets/model/BenchmarkNcnnType.ets:
--------------------------------------------------------------------------------
1 | export interface IBenchmarkNcnnType {
2 | loop: number
3 | min: number
4 | max: number
5 | avg: number
6 | width: number
7 | height: number
8 | }
9 |
--------------------------------------------------------------------------------
/entry/src/main/ets/model/ModelList.ets:
--------------------------------------------------------------------------------
1 | export interface IModelType {
2 | name: string
3 | param: string
4 | bin: string
5 | }
6 |
7 | export const modelList: IModelType[] = [
8 | {
9 | name: 'YOLOv4-tiny',
10 | param: 'yolov4-tiny.param',
11 | bin: 'yolov4-tiny.bin'
12 | },
13 | {
14 | name: 'nanodet-m',
15 | param: 'nanodet-m.param',
16 | bin: 'nanodet-m.bin'
17 | }
18 |
19 | ]
20 |
--------------------------------------------------------------------------------
/entry/src/main/ets/pages/Main.ets:
--------------------------------------------------------------------------------
1 | import { BOTTOM_HEIGHT, TOP_HEIGHT } from "../utils/ConstantKey"
2 | import { promptAction, router } from "@kit.ArkUI"
3 | import tncnn from 'libtncnn.so'
4 | import resourceManager from '@ohos.resourceManager';
5 | import { PermissionUtil } from '@pura/harmony-utils';
6 |
7 |
8 | @Entry
9 | @ComponentV2
10 | struct Index {
11 | @Local topHeight: number = AppStorage.get(TOP_HEIGHT) || 0
12 | @Local bottomHeight: number = AppStorage.get(BOTTOM_HEIGHT) || 0
13 | @Local ncnnVersion: string = '1.0.00000000'
14 | resMgr: resourceManager.ResourceManager | undefined
15 |
16 | handlerClickPhoto() {
17 | router.pushUrl({
18 | url: 'pages/PhotoPage'
19 | })
20 | }
21 |
22 | handlerClickCamera() {
23 | PermissionUtil.checkRequestPermissions("ohos.permission.CAMERA")
24 | .then((fulfilled: boolean) => {
25 | if (fulfilled) {
26 | router.pushUrl({
27 | url: 'pages/CameraPage'
28 | })
29 | } else {
30 | promptAction.showToast({ message: $r('app.string.permission_camera') })
31 | }
32 | }, () => {
33 |
34 | })
35 | .catch(() => {
36 |
37 | })
38 | .finally(() => {
39 |
40 | })
41 |
42 | }
43 |
44 | aboutToAppear(): void {
45 | try {
46 | this.ncnnVersion = tncnn.ncnn_version()
47 | } catch (e) {
48 | console.log('获取版本异常:' + e.toString())
49 | }
50 | }
51 |
52 | build() {
53 | Column() {
54 | Image($r('app.media.ohhh'))
55 | .width('100%')
56 | .aspectRatio(1.67)
57 | .padding({ top: this.topHeight })
58 | .backgroundColor('#031829')
59 |
60 | List({ space: 7 }) {
61 | ListItem() {
62 | Button('图片')
63 | .width('100%')
64 | .fontColor($r('sys.color.white'))
65 | .backgroundColor($r('app.color.color_primary'))
66 | .onClick(() => {
67 | this.handlerClickPhoto()
68 | })
69 | }
70 |
71 | ListItem() {
72 | Button('摄像头')
73 | .width('100%')
74 | .fontColor($r('sys.color.white'))
75 | .backgroundColor($r('app.color.color_primary'))
76 | .onClick(() => {
77 | this.handlerClickCamera()
78 | })
79 | }
80 | }
81 | .width('100%')
82 | .height('100%')
83 | .layoutWeight(1)
84 | .padding({
85 | top: 7,
86 | left: 7,
87 | right: 7,
88 | bottom: this.bottomHeight
89 | })
90 |
91 | Column({ space: 5 }) {
92 | Image($r('app.media.ncnn_icon'))
93 | .width(45)
94 | .height(45)
95 | .opacity(0.5)
96 | Text(this.ncnnVersion)
97 | .fontSize(14)
98 | .fontColor('#999999')
99 | }
100 | .padding({ bottom: this.bottomHeight })
101 |
102 | }
103 | .height('100%')
104 | .width('100%')
105 | .backgroundColor($r('app.color.page_background_color'))
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/entry/src/main/ets/types/Types.ts:
--------------------------------------------------------------------------------
1 | export interface IOptionType {
2 | mempool: boolean
3 | winograd: boolean
4 | sgemm: boolean
5 | pack4: boolean
6 | bf16Storage: boolean
7 | fp16Packed: boolean
8 | fp16Storage: boolean
9 | fp16Arithmetic: boolean
10 | lightMode: boolean
11 | }
12 |
13 | export interface IConfigType {
14 | isGPU: boolean
15 | core: number // 0全部 1大核 2小核
16 | thread: number // 0自动 1...8线程数
17 | }
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/entry/src/main/ets/utils/ColorUtil.ts:
--------------------------------------------------------------------------------
1 | // 根据字符串生成颜色
2 | export function stringToColor(str: string): string {
3 | // 将输入字符串转换为哈希值
4 | let hash = 0;
5 | for (let i = 0; i < str.length; i++) {
6 | hash = (hash << 5) - hash + str.charCodeAt(i);
7 | hash |= 0; // 强制转换为 32 位整数
8 | }
9 |
10 | // 使用哈希值生成颜色,确保颜色为 HEX 格式
11 | const color = (hash & 0x00FFFFFF).toString(16).toUpperCase(); // 取哈希值的低 24 位
12 | return `#${'000000'.substring(0, 6 - color.length) + color}`; // 保证颜色是 6 位长,不足前面补零
13 | }
--------------------------------------------------------------------------------
/entry/src/main/ets/utils/ConstantKey.ts:
--------------------------------------------------------------------------------
1 | export const TOP_HEIGHT: string = 'topHeight' // 顶部安全区
2 | export const BOTTOM_HEIGHT: string = 'bottomHeight' // 底部安全区
3 |
--------------------------------------------------------------------------------
/entry/src/main/ets/utils/DrawUtils.ets:
--------------------------------------------------------------------------------
1 | import { image } from '@kit.ImageKit';
2 | import { display } from '@kit.ArkUI';
3 | import { stringToColor } from './ColorUtil';
4 |
5 | const labels = [
6 | "person", "bicycle", "car", "motorcycle", "airplane", "bus", "train", "truck", "boat", "traffic light",
7 | "fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow",
8 | "elephant", "bear", "zebra", "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee",
9 | "skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove", "skateboard", "surfboard",
10 | "tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple",
11 | "sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "couch",
12 | "potted plant", "bed", "dining table", "toilet", "tv", "laptop", "mouse", "remote", "keyboard", "cell phone",
13 | "microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase", "scissors", "teddy bear",
14 | "hair drier", "toothbrush"
15 | ]
16 |
17 | export interface IBoxInfo {
18 | x1: number
19 | y1: number
20 | x2: number
21 | y2: number
22 | score: number
23 | label: number
24 | }
25 |
26 | /**
27 | * 画框
28 | */
29 | export function drawBox(boxInfos: IBoxInfo[], imagePixelMap: image.PixelMap, width: number, height: number) {
30 | const offScreenCanvas = new OffscreenCanvas(width, height)
31 | const offScreenContext = offScreenCanvas.getContext('2d')
32 | offScreenContext.drawImage(imagePixelMap, 0, 0, width, height)
33 | const imageScale = width / px2vp(display.getDefaultDisplaySync().width)
34 | offScreenContext.textAlign = 'left'
35 | offScreenContext.font = 16 * imageScale + 'vp'
36 | offScreenContext.lineWidth = 3 * imageScale
37 |
38 | for (let i = 0; i < boxInfos.length; i++) {
39 | const boxInfo: IBoxInfo = boxInfos[i]
40 | offScreenContext.strokeStyle = stringToColor(labels[boxInfo.label])
41 | offScreenContext.strokeRect(boxInfo.x1, boxInfo.y1, boxInfo.x2 - boxInfo.x1, boxInfo.y2 - boxInfo.y1)
42 |
43 | const label = labels[boxInfo.label] + ' ' + boxInfo.score.toFixed(2)
44 | offScreenContext.fillStyle = '#222222' // 文字阴影
45 | offScreenContext.fillText(label, boxInfo.x1 + 2, Math.max(boxInfo.y1 - 5 + 2, 20)) // 文字阴影
46 | offScreenContext.fillStyle = stringToColor(labels[boxInfo.label])
47 | offScreenContext.fillText(label, boxInfo.x1, Math.max(boxInfo.y1 - 5, 20))
48 | }
49 | return offScreenContext.getPixelMap(0, 0, width, height)
50 | }
51 |
--------------------------------------------------------------------------------
/entry/src/main/ets/utils/FileUtils.ets:
--------------------------------------------------------------------------------
1 | import { Context } from "@ohos.arkui.UIContext"
2 | import { buffer, JSON } from "@kit.ArkTS"
3 | import { fileIo } from '@kit.CoreFileKit'
4 | import resourceManager from '@ohos.resourceManager';
5 | import { photoAccessHelper } from "@kit.MediaLibraryKit";
6 | import { dataSharePredicates } from "@kit.ArkData";
7 |
8 |
9 | /**
10 | * 复制 Rawfile 到沙盒中
11 | * @param context
12 | * @param dir 不以 / 开头结尾
13 | * @param fileName 不以 / 开头,包含扩展名
14 | */
15 | export function copyRawfileToSanbox(
16 | context: Context,
17 | resourceManager: resourceManager.ResourceManager,
18 | dir: string,
19 | fileName: string,
20 | success: () => void
21 | ) {
22 | let boxPath = context.getApplicationContext().filesDir
23 | let unzipPath = boxPath + "/" + dir
24 | let zipPath = boxPath + "/" + dir + '/' + fileName
25 |
26 | // 获取rawfile资源文件,转换数据
27 | let uint8Array: Uint8Array = resourceManager.getRawFileContentSync(dir + '/' + fileName)
28 | let bf = buffer.from(uint8Array).buffer
29 |
30 | // 创建沙箱目录
31 | try {
32 | if (!fileIo.accessSync(unzipPath)) {
33 | fileIo.mkdirSync(unzipPath)
34 | }
35 | } catch (e) {
36 | console.log("创建沙盒目录异常:" + e)
37 | }
38 |
39 | try {
40 | // 打开文件
41 | const fsOpen = fileIo.openSync(zipPath,
42 | fileIo.OpenMode.READ_WRITE
43 | | fileIo.OpenMode.READ_ONLY
44 | | fileIo.OpenMode.CREATE
45 | | fileIo.OpenMode.TRUNC)
46 |
47 | // 写入文件(同步会报异常)
48 | // let destFile = fileIo.writeSync(fsOpen.fd, bf)
49 | // 关闭文件
50 | // fileIo.close(destFile)
51 |
52 | // 写入文件
53 | fileIo.write(fsOpen.fd, bf)
54 | .then((writeLen: number) => {
55 | // 关闭文件
56 | fileIo.close(fsOpen)
57 | success && success()
58 | })
59 | } catch (e) {
60 | console.log("写入沙盒文件异常:" + e)
61 | success && success()
62 | }
63 | }
64 |
65 | /**
66 | * 获取 uri 文件的信息
67 | * @param path
68 | * @returns
69 | */
70 | export async function getUriInfo(path: string) {
71 | let asset: photoAccessHelper.PhotoAsset | undefined = undefined
72 | try {
73 | let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(getContext());
74 | let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
75 | // 配置查询条件,使用PhotoViewPicker选择图片返回的uri进行查询
76 | predicates.equalTo('uri', path);
77 | let fetchOption: photoAccessHelper.FetchOptions = {
78 | fetchColumns: [
79 | photoAccessHelper.PhotoKeys.WIDTH,
80 | photoAccessHelper.PhotoKeys.HEIGHT,
81 | photoAccessHelper.PhotoKeys.SIZE,
82 | photoAccessHelper.PhotoKeys.TITLE,
83 | photoAccessHelper.PhotoKeys.DURATION
84 | ],
85 | predicates: predicates
86 | };
87 | let fetchResult: photoAccessHelper.FetchResult =
88 | await phAccessHelper.getAssets(fetchOption);
89 | // 得到uri对应的PhotoAsset对象,读取文件的部分信息
90 | asset = await fetchResult.getFirstObject();
91 | // console.info('asset displayName: ', asset.displayName);
92 | // console.info('asset uri: ', asset.uri);
93 | // console.info('asset photoType: ', asset.photoType);
94 | console.info('asset width: ', asset.get(photoAccessHelper.PhotoKeys.WIDTH));
95 | console.info('asset height: ', asset.get(photoAccessHelper.PhotoKeys.HEIGHT));
96 | console.info('asset size: ', asset.get(photoAccessHelper.PhotoKeys.SIZE));
97 | // console.info('asset title: ' + asset.get(photoAccessHelper.PhotoKeys.TITLE));
98 | } catch (error) {
99 | console.error('uriGetAssets failed with err: ' + JSON.stringify(error));
100 | }
101 | return asset
102 | }
103 |
104 |
105 |
--------------------------------------------------------------------------------
/entry/src/main/ets/views/MenuOption.ets:
--------------------------------------------------------------------------------
1 | import { IModelType, modelList } from "../model/ModelList"
2 |
3 | @ComponentV2
4 | export struct MenuOption {
5 | @Consumer('currentModel') currentModel: IModelType = modelList[0]
6 | @Consumer('currentType') currentType: string = 'CPU'
7 | @Consumer('currentCore') currentCore: string = '全部'
8 | @Consumer('currentThread') currentThread: string = '自动'
9 |
10 | checkCurrentModel() {
11 | const menus: MenuElement[] = []
12 | for (let index = 0; index < modelList.length; index++) {
13 | const model = modelList[index]
14 | const menu: MenuElement = {
15 | value: model.name,
16 | action: () => {
17 | this.currentModel = model
18 | }
19 | }
20 | menus.push(menu)
21 | }
22 | return menus
23 | }
24 |
25 | checkCurrentType() {
26 | const menus: MenuElement[] = []
27 | const types: string[] = ['CPU', 'GPU']
28 | for (let index = 0; index < types.length; index++) {
29 | const temp = types[index]
30 | const menu: MenuElement = {
31 | value: temp,
32 | action: () => {
33 | this.currentType = temp
34 | }
35 | }
36 | menus.push(menu)
37 | }
38 | return menus
39 | }
40 |
41 | checkCurrentCore() {
42 | const menus: MenuElement[] = []
43 | const cores: string[] = ['全部', '大核', '小核']
44 | for (let index = 0; index < cores.length; index++) {
45 | const temp = cores[index]
46 | const menu: MenuElement = {
47 | value: temp,
48 | action: () => {
49 | this.currentCore = temp
50 | }
51 | }
52 | menus.push(menu)
53 | }
54 | return menus
55 | }
56 |
57 | checkCurrentThread() {
58 | const menus: MenuElement[] = []
59 | const threads: string[] = [
60 | '自动',
61 | '线程数: 1', '线程数: 2', '线程数: 3', '线程数: 4',
62 | '线程数: 5', '线程数: 6', '线程数: 7', '线程数: 8'
63 | ]
64 | for (let index = 0; index < threads.length; index++) {
65 | const temp = threads[index]
66 | const menu: MenuElement = {
67 | value: temp,
68 | action: () => {
69 | this.currentThread = temp
70 | }
71 | }
72 | menus.push(menu)
73 | }
74 | return menus
75 | }
76 |
77 | build() {
78 | Row({ space: 5 }) {
79 | Row() {
80 | Text(this.currentModel.name)
81 | .fontColor($r('sys.color.white'))
82 | .layoutWeight(1)
83 | .padding({ right: 5 })
84 | Image($r('app.media.icon_arrow_down'))
85 | .height(15)
86 | .aspectRatio(1)
87 | .objectFit(ImageFit.Contain)
88 | }
89 | .layoutWeight(2)
90 | .stylesItem()
91 | .bindMenu(this.checkCurrentModel())
92 |
93 | Row() {
94 | Text(this.currentType)
95 | .fontColor($r('sys.color.white'))
96 | .padding({ right: 5 })
97 | Image($r('app.media.icon_arrow_down'))
98 | .height(15)
99 | .aspectRatio(1)
100 | .objectFit(ImageFit.Contain)
101 | }
102 | .stylesItem()
103 | .bindMenu(this.checkCurrentType())
104 |
105 | Row() {
106 | Text(this.currentCore)
107 | .fontColor($r('sys.color.white'))
108 | .padding({ right: 5 })
109 | Image($r('app.media.icon_arrow_down'))
110 | .height(15)
111 | .aspectRatio(1)
112 | .objectFit(ImageFit.Contain)
113 | }
114 | .stylesItem()
115 | .bindMenu(this.checkCurrentCore())
116 |
117 | Row() {
118 | Text(this.currentThread)
119 | .fontColor($r('sys.color.white'))
120 | .padding({ right: 5 })
121 | Image($r('app.media.icon_arrow_down'))
122 | .height(15)
123 | .aspectRatio(1)
124 | .objectFit(ImageFit.Contain)
125 | }
126 | .stylesItem()
127 | .bindMenu(this.checkCurrentThread())
128 | }
129 | .width('100%')
130 | .padding({ left: 5, right: 5 })
131 | }
132 |
133 | @Styles
134 | stylesItem() {
135 | .padding({ left: 5, right: 5, top: 7, bottom: 7 })
136 | .backgroundColor($r('app.color.color_primary'))
137 | .borderRadius(7)
138 | }
139 |
140 | }
141 |
--------------------------------------------------------------------------------
/entry/src/main/ets/views/NavBar.ets:
--------------------------------------------------------------------------------
1 | import { TOP_HEIGHT } from "../utils/ConstantKey"
2 | import { router } from "@kit.ArkUI"
3 |
4 | @Component
5 | export struct NavBar {
6 | title: string | Resource = '标题'
7 | showBack: boolean = true
8 | // true:正常返回,false:阻止返回
9 | onClickBack: () => boolean = () => {
10 | return true
11 | }
12 | @StorageLink(TOP_HEIGHT) topHeight: number = AppStorage.get(TOP_HEIGHT) || 0
13 | @BuilderParam leftBuilder: () => void = this.defaultLeftBuilder
14 | @BuilderParam centerBuilder: () => void = this.defaultCenterBuilder
15 | @BuilderParam rightBuilder: () => void = this.defaultRightBuilder
16 |
17 | // 左侧
18 | @Builder
19 | defaultLeftBuilder() {
20 | Image($r("app.media.icon_arrow_left_white"))
21 | .width($r('app.integer.navbar_height'))
22 | .height($r('app.integer.navbar_height'))
23 | .padding(12)
24 | .objectFit(ImageFit.Contain)
25 | .onClick(() => {
26 | if (this.onClickBack) {
27 | if (this.onClickBack()) {
28 | router.back()
29 | }
30 | } else {
31 | router.back()
32 | }
33 | })
34 | }
35 |
36 | // 中间
37 | @Builder
38 | defaultCenterBuilder() {
39 | Text(this.title)
40 | .width('100%')
41 | .textAlign(TextAlign.Center)
42 | .fontColor($r("sys.color.white"))// 都用白色
43 | .fontSize(18)
44 | }
45 |
46 | // 右侧
47 | @Builder
48 | defaultRightBuilder() {
49 | // Text('右侧')
50 | // .fontColor($r("sys.color.white"))// 都用白色
51 | // .padding(12)
52 | }
53 |
54 | aboutToAppear(): void {
55 |
56 | }
57 |
58 | build() {
59 | Column() {
60 | Row() {
61 | Row() {
62 | if (this.showBack) {
63 | this.leftBuilder()
64 | }
65 | }
66 | .justifyContent(FlexAlign.Start)
67 | .layoutWeight(1)
68 |
69 | Row() {
70 | this.centerBuilder()
71 | }
72 | .justifyContent(FlexAlign.Center)
73 | .layoutWeight(2)
74 |
75 | Row() {
76 | this.rightBuilder()
77 | }
78 | .justifyContent(FlexAlign.End)
79 | .layoutWeight(1)
80 |
81 | }
82 | .width('100%')
83 | .height($r('app.integer.navbar_height'))
84 | }
85 | .backgroundColor($r("app.color.navbar_color"))
86 | .padding({ top: this.topHeight })
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/entry/src/main/module.json5:
--------------------------------------------------------------------------------
1 | {
2 | "module": {
3 | "name": "entry",
4 | "type": "entry",
5 | "description": "$string:module_desc",
6 | "mainElement": "EntryAbility",
7 | "deviceTypes": [
8 | "phone",
9 | "tablet",
10 | "2in1"
11 | ],
12 | "deliveryWithInstall": true,
13 | "installationFree": false,
14 | "pages": "$profile:main_pages",
15 | "abilities": [
16 | {
17 | "name": "EntryAbility",
18 | "srcEntry": "./ets/entryability/EntryAbility.ets",
19 | "description": "$string:EntryAbility_desc",
20 | "icon": "$media:layered_image",
21 | "label": "$string:EntryAbility_label",
22 | "startWindowIcon": "$media:ncnn_icon",
23 | "startWindowBackground": "$color:start_window_background",
24 | "exported": true,
25 | "skills": [
26 | {
27 | "entities": [
28 | "entity.system.home"
29 | ],
30 | "actions": [
31 | "action.system.home"
32 | ]
33 | }
34 | ]
35 | }
36 | ],
37 | "extensionAbilities": [
38 | {
39 | "name": "EntryBackupAbility",
40 | "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
41 | "type": "backup",
42 | "exported": false,
43 | "metadata": [
44 | {
45 | "name": "ohos.extension.backup",
46 | "resource": "$profile:backup_config"
47 | }
48 | ],
49 | }
50 | ],
51 | "requestPermissions": [
52 | {
53 | "name": "ohos.permission.CAMERA",
54 | "reason": "$string:permission_camera",
55 | "usedScene": {
56 | "abilities": [
57 | "EntryAbility"
58 | ],
59 | "when": "always"
60 | }
61 | }
62 | ]
63 | }
64 | }
--------------------------------------------------------------------------------
/entry/src/main/resources/base/element/color.json:
--------------------------------------------------------------------------------
1 | {
2 | "color": [
3 | {
4 | "name": "start_window_background",
5 | "value": "#E0E0E0"
6 | },
7 | {
8 | "name": "color_primary",
9 | "value": "#212121"
10 | },
11 | {
12 | "name": "page_background_color",
13 | "value": "#F5F5F5"
14 | },
15 | {
16 | "name": "navbar_color",
17 | "value": "#111111"
18 | }
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/entry/src/main/resources/base/element/integer.json:
--------------------------------------------------------------------------------
1 | {
2 | "integer": [
3 | {
4 | "name": "navbar_height",
5 | "value": 44
6 | }
7 | ]
8 | }
--------------------------------------------------------------------------------
/entry/src/main/resources/base/element/string.json:
--------------------------------------------------------------------------------
1 | {
2 | "string": [
3 | {
4 | "name": "module_desc",
5 | "value": "module description"
6 | },
7 | {
8 | "name": "EntryAbility_desc",
9 | "value": "description"
10 | },
11 | {
12 | "name": "EntryAbility_label",
13 | "value": "ncnn"
14 | },
15 | {
16 | "name": "permission_camera",
17 | "value": "不给权限不给玩哦~"
18 | }
19 | ]
20 | }
--------------------------------------------------------------------------------
/entry/src/main/resources/base/media/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/entry/src/main/resources/base/media/background.png
--------------------------------------------------------------------------------
/entry/src/main/resources/base/media/cpu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/entry/src/main/resources/base/media/cpu.png
--------------------------------------------------------------------------------
/entry/src/main/resources/base/media/cpu_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/entry/src/main/resources/base/media/cpu_white.png
--------------------------------------------------------------------------------
/entry/src/main/resources/base/media/foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/entry/src/main/resources/base/media/foreground.png
--------------------------------------------------------------------------------
/entry/src/main/resources/base/media/gpu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/entry/src/main/resources/base/media/gpu.png
--------------------------------------------------------------------------------
/entry/src/main/resources/base/media/gpu_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/entry/src/main/resources/base/media/gpu_white.png
--------------------------------------------------------------------------------
/entry/src/main/resources/base/media/icon_arrow_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/entry/src/main/resources/base/media/icon_arrow_down.png
--------------------------------------------------------------------------------
/entry/src/main/resources/base/media/icon_arrow_down_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/entry/src/main/resources/base/media/icon_arrow_down_white.png
--------------------------------------------------------------------------------
/entry/src/main/resources/base/media/icon_arrow_left_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/entry/src/main/resources/base/media/icon_arrow_left_white.png
--------------------------------------------------------------------------------
/entry/src/main/resources/base/media/layered_image.json:
--------------------------------------------------------------------------------
1 | {
2 | "layered-image":
3 | {
4 | "background" : "$media:background",
5 | "foreground" : "$media:foreground"
6 | }
7 | }
--------------------------------------------------------------------------------
/entry/src/main/resources/base/media/ncnn_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/entry/src/main/resources/base/media/ncnn_icon.png
--------------------------------------------------------------------------------
/entry/src/main/resources/base/media/ncnn_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/entry/src/main/resources/base/media/ncnn_logo.png
--------------------------------------------------------------------------------
/entry/src/main/resources/base/media/ohhh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/entry/src/main/resources/base/media/ohhh.png
--------------------------------------------------------------------------------
/entry/src/main/resources/base/profile/backup_config.json:
--------------------------------------------------------------------------------
1 | {
2 | "allowToBackupRestore": true
3 | }
--------------------------------------------------------------------------------
/entry/src/main/resources/base/profile/main_pages.json:
--------------------------------------------------------------------------------
1 | {
2 | "src": [
3 | "pages/Main",
4 | "pages/CameraPage",
5 | "pages/PhotoPage"
6 | ]
7 | }
--------------------------------------------------------------------------------
/entry/src/main/resources/en_US/element/string.json:
--------------------------------------------------------------------------------
1 | {
2 | "string": [
3 | {
4 | "name": "module_desc",
5 | "value": "module description"
6 | },
7 | {
8 | "name": "EntryAbility_desc",
9 | "value": "description"
10 | },
11 | {
12 | "name": "EntryAbility_label",
13 | "value": "ncnn"
14 | }
15 | ]
16 | }
--------------------------------------------------------------------------------
/entry/src/main/resources/zh_CN/element/string.json:
--------------------------------------------------------------------------------
1 | {
2 | "string": [
3 | {
4 | "name": "module_desc",
5 | "value": "模块描述"
6 | },
7 | {
8 | "name": "EntryAbility_desc",
9 | "value": "description"
10 | },
11 | {
12 | "name": "EntryAbility_label",
13 | "value": "ncnn"
14 | }
15 | ]
16 | }
--------------------------------------------------------------------------------
/entry/src/mock/mock-config.json5:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/entry/src/ohosTest/ets/test/Ability.test.ets:
--------------------------------------------------------------------------------
1 | import { hilog } from '@kit.PerformanceAnalysisKit';
2 | import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
3 |
4 | export default function abilityTest() {
5 | describe('ActsAbilityTest', () => {
6 | // Defines a test suite. Two parameters are supported: test suite name and test suite function.
7 | beforeAll(() => {
8 | // Presets an action, which is performed only once before all test cases of the test suite start.
9 | // This API supports only one parameter: preset action function.
10 | })
11 | beforeEach(() => {
12 | // Presets an action, which is performed before each unit test case starts.
13 | // The number of execution times is the same as the number of test cases defined by **it**.
14 | // This API supports only one parameter: preset action function.
15 | })
16 | afterEach(() => {
17 | // Presets a clear action, which is performed after each unit test case ends.
18 | // The number of execution times is the same as the number of test cases defined by **it**.
19 | // This API supports only one parameter: clear action function.
20 | })
21 | afterAll(() => {
22 | // Presets a clear action, which is performed after all test cases of the test suite end.
23 | // This API supports only one parameter: clear action function.
24 | })
25 | it('assertContain', 0, () => {
26 | // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
27 | hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
28 | let a = 'abc';
29 | let b = 'b';
30 | // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
31 | expect(a).assertContain(b);
32 | expect(a).assertEqual(a);
33 | })
34 | })
35 | }
--------------------------------------------------------------------------------
/entry/src/ohosTest/ets/test/List.test.ets:
--------------------------------------------------------------------------------
1 | import abilityTest from './Ability.test';
2 |
3 | export default function testsuite() {
4 | abilityTest();
5 | }
--------------------------------------------------------------------------------
/entry/src/ohosTest/module.json5:
--------------------------------------------------------------------------------
1 | {
2 | "module": {
3 | "name": "entry_test",
4 | "type": "feature",
5 | "deviceTypes": [
6 | "phone",
7 | "tablet",
8 | "2in1"
9 | ],
10 | "deliveryWithInstall": true,
11 | "installationFree": false
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/entry/src/test/List.test.ets:
--------------------------------------------------------------------------------
1 | import localUnitTest from './LocalUnit.test';
2 |
3 | export default function testsuite() {
4 | localUnitTest();
5 | }
--------------------------------------------------------------------------------
/entry/src/test/LocalUnit.test.ets:
--------------------------------------------------------------------------------
1 | import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
2 |
3 | export default function localUnitTest() {
4 | describe('localUnitTest', () => {
5 | // Defines a test suite. Two parameters are supported: test suite name and test suite function.
6 | beforeAll(() => {
7 | // Presets an action, which is performed only once before all test cases of the test suite start.
8 | // This API supports only one parameter: preset action function.
9 | });
10 | beforeEach(() => {
11 | // Presets an action, which is performed before each unit test case starts.
12 | // The number of execution times is the same as the number of test cases defined by **it**.
13 | // This API supports only one parameter: preset action function.
14 | });
15 | afterEach(() => {
16 | // Presets a clear action, which is performed after each unit test case ends.
17 | // The number of execution times is the same as the number of test cases defined by **it**.
18 | // This API supports only one parameter: clear action function.
19 | });
20 | afterAll(() => {
21 | // Presets a clear action, which is performed after all test cases of the test suite end.
22 | // This API supports only one parameter: clear action function.
23 | });
24 | it('assertContain', 0, () => {
25 | // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
26 | let a = 'abc';
27 | let b = 'b';
28 | // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
29 | expect(a).assertContain(b);
30 | expect(a).assertEqual(a);
31 | });
32 | });
33 | }
--------------------------------------------------------------------------------
/hvigor/hvigor-config.json5:
--------------------------------------------------------------------------------
1 | {
2 | "modelVersion": "5.0.0",
3 | "dependencies": {
4 | },
5 | "execution": {
6 | // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
7 | // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
8 | // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
9 | // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
10 | // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
11 | },
12 | "logging": {
13 | // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
14 | },
15 | "debugging": {
16 | // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
17 | },
18 | "nodeOptions": {
19 | // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
20 | // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/hvigorfile.ts:
--------------------------------------------------------------------------------
1 | import { appTasks } from '@ohos/hvigor-ohos-plugin';
2 |
3 | export default {
4 | system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
5 | plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
6 | }
7 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by DevEco Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file should *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # For customization when using a Version Control System, please read the header note.
8 |
9 |
10 |
--------------------------------------------------------------------------------
/oh-package-lock.json5:
--------------------------------------------------------------------------------
1 | {
2 | "meta": {
3 | "stableOrder": true
4 | },
5 | "lockfileVersion": 3,
6 | "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
7 | "specifiers": {
8 | "@lyb/loading-dialog@^2.1.5": "@lyb/loading-dialog@2.1.5",
9 | "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0",
10 | "@ohos/hypium@1.0.19": "@ohos/hypium@1.0.19",
11 | "@pura/harmony-utils@^1.2.4": "@pura/harmony-utils@1.2.5",
12 | "class-transformer@^0.5.1": "class-transformer@0.5.1"
13 | },
14 | "packages": {
15 | "@lyb/loading-dialog@2.1.5": {
16 | "name": "@lyb/loading-dialog",
17 | "version": "2.1.5",
18 | "integrity": "sha512-PkJwsG9nJ2+g/WcebHgeh53ziOS9dTLYC6s7xXDh6LF0M7eokX6L3juabSB+ZJmedtJAm8XsNKGzksmmhgf+7w==",
19 | "resolved": "https://repo.harmonyos.com/ohpm/@lyb/loading-dialog/-/loading-dialog-2.1.5.har",
20 | "registryType": "ohpm"
21 | },
22 | "@ohos/hamock@1.0.0": {
23 | "name": "@ohos/hamock",
24 | "version": "1.0.0",
25 | "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==",
26 | "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hamock/-/hamock-1.0.0.har",
27 | "registryType": "ohpm"
28 | },
29 | "@ohos/hypium@1.0.19": {
30 | "name": "@ohos/hypium",
31 | "version": "1.0.19",
32 | "integrity": "sha512-cEjDgLFCm3cWZDeRXk7agBUkPqjWxUo6AQeiu0gEkb3J8ESqlduQLSIXeo3cCsm8U/asL7iKjF85ZyOuufAGSQ==",
33 | "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.19.har",
34 | "registryType": "ohpm"
35 | },
36 | "@pura/harmony-utils@1.2.5": {
37 | "name": "@pura/harmony-utils",
38 | "version": "1.2.5",
39 | "integrity": "sha512-+FH/sbyxpkolg3HYaJOhbsj5T0au8ycLJqqRPPAZu2nnW/hPsLtjL6QOIZZvBjGJqWk0HVxvFMzWB0QJXP35GQ==",
40 | "resolved": "https://repo.harmonyos.com/ohpm/@pura/harmony-utils/-/harmony-utils-1.2.5.har",
41 | "registryType": "ohpm",
42 | "dependencies": {
43 | "class-transformer": "^0.5.1"
44 | }
45 | },
46 | "class-transformer@0.5.1": {
47 | "name": "class-transformer",
48 | "version": "0.5.1",
49 | "integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==",
50 | "resolved": "https://repo.harmonyos.com/ohpm/class-transformer/-/class-transformer-0.5.1.tgz",
51 | "shasum": "24147d5dffd2a6cea930a3250a677addf96ab336",
52 | "registryType": "ohpm"
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/oh-package.json5:
--------------------------------------------------------------------------------
1 | {
2 | "modelVersion": "5.0.0",
3 | "description": "Please describe the basic information.",
4 | "dependencies": {
5 | "@pura/harmony-utils": "^1.2.4",
6 | "@lyb/loading-dialog": "^2.1.5"
7 | },
8 | "devDependencies": {
9 | "@ohos/hypium": "1.0.19",
10 | "@ohos/hamock": "1.0.0"
11 | },
12 | "dynamicDependencies": {}
13 | }
--------------------------------------------------------------------------------
/tncnn/build-profile.json5:
--------------------------------------------------------------------------------
1 | {
2 | "apiType": "stageMode",
3 | "buildOption": {
4 | "externalNativeOptions": {
5 | "path": "./src/main/cpp/CMakeLists.txt",
6 | "arguments": "",
7 | "cppFlags": "",
8 | "abiFilters": [
9 | "arm64-v8a",
10 | "x86_64"
11 | ]
12 | }
13 | },
14 | "buildOptionSet": [
15 | {
16 | "name": "release",
17 | "arkOptions": {
18 | "obfuscation": {
19 | "ruleOptions": {
20 | "enable": false,
21 | "files": [
22 | "./obfuscation-rules.txt"
23 | ]
24 | }
25 | }
26 | },
27 | "nativeLib": {
28 | "debugSymbol": {
29 | "strip": true,
30 | "exclude": []
31 | }
32 | }
33 | },
34 | ],
35 | "targets": [
36 | {
37 | "name": "default"
38 | },
39 | {
40 | "name": "ohosTest",
41 | }
42 | ]
43 | }
--------------------------------------------------------------------------------
/tncnn/hvigorfile.ts:
--------------------------------------------------------------------------------
1 | import { hapTasks } from '@ohos/hvigor-ohos-plugin';
2 |
3 | export default {
4 | system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
5 | plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
6 | }
7 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/glslang/Include/InitializeGlobals.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
3 | // All rights reserved.
4 | //
5 | // Redistribution and use in source and binary forms, with or without
6 | // modification, are permitted provided that the following conditions
7 | // are met:
8 | //
9 | // Redistributions of source code must retain the above copyright
10 | // notice, this list of conditions and the following disclaimer.
11 | //
12 | // Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following
14 | // disclaimer in the documentation and/or other materials provided
15 | // with the distribution.
16 | //
17 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its
18 | // contributors may be used to endorse or promote products derived
19 | // from this software without specific prior written permission.
20 | //
21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 | // POSSIBILITY OF SUCH DAMAGE.
33 | //
34 |
35 | #ifndef __INITIALIZE_GLOBALS_INCLUDED_
36 | #define __INITIALIZE_GLOBALS_INCLUDED_
37 |
38 | namespace glslang {
39 |
40 | bool InitializePoolIndex();
41 |
42 | } // end namespace glslang
43 |
44 | #endif // __INITIALIZE_GLOBALS_INCLUDED_
45 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/glslang/Include/SpirvIntrinsics.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright(C) 2021 Advanced Micro Devices, Inc.
3 | //
4 | // All rights reserved.
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | //
13 | // Redistributions in binary form must reproduce the above
14 | // copyright notice, this list of conditions and the following
15 | // disclaimer in the documentation and/or other materials provided
16 | // with the distribution.
17 | //
18 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its
19 | // contributors may be used to endorse or promote products derived
20 | // from this software without specific prior written permission.
21 | //
22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 | // POSSIBILITY OF SUCH DAMAGE.
34 | //
35 |
36 | #pragma once
37 |
38 | #ifndef GLSLANG_WEB
39 |
40 | //
41 | // GL_EXT_spirv_intrinsics
42 | //
43 | #include "Common.h"
44 |
45 | namespace glslang {
46 |
47 | class TIntermTyped;
48 | class TIntermConstantUnion;
49 | class TType;
50 |
51 | // SPIR-V requirements
52 | struct TSpirvRequirement {
53 | POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
54 |
55 | // capability = [..]
56 | TSet extensions;
57 | // extension = [..]
58 | TSet capabilities;
59 | };
60 |
61 | // SPIR-V execution modes
62 | struct TSpirvExecutionMode {
63 | POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
64 |
65 | // spirv_execution_mode
66 | TMap> modes;
67 | // spirv_execution_mode_id
68 | TMap > modeIds;
69 | };
70 |
71 | // SPIR-V decorations
72 | struct TSpirvDecorate {
73 | POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
74 |
75 | // spirv_decorate
76 | TMap > decorates;
77 | // spirv_decorate_id
78 | TMap> decorateIds;
79 | // spirv_decorate_string
80 | TMap > decorateStrings;
81 | };
82 |
83 | // SPIR-V instruction
84 | struct TSpirvInstruction {
85 | POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
86 |
87 | TSpirvInstruction() { set = ""; id = -1; }
88 |
89 | bool operator==(const TSpirvInstruction& rhs) const { return set == rhs.set && id == rhs.id; }
90 | bool operator!=(const TSpirvInstruction& rhs) const { return !operator==(rhs); }
91 |
92 | // spirv_instruction
93 | TString set;
94 | int id;
95 | };
96 |
97 | // SPIR-V type parameter
98 | struct TSpirvTypeParameter {
99 | POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
100 |
101 | TSpirvTypeParameter(const TIntermConstantUnion* arg) { constant = arg; }
102 |
103 | bool operator==(const TSpirvTypeParameter& rhs) const { return constant == rhs.constant; }
104 | bool operator!=(const TSpirvTypeParameter& rhs) const { return !operator==(rhs); }
105 |
106 | const TIntermConstantUnion* constant;
107 | };
108 |
109 | typedef TVector TSpirvTypeParameters;
110 |
111 | // SPIR-V type
112 | struct TSpirvType {
113 | POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
114 |
115 | bool operator==(const TSpirvType& rhs) const
116 | {
117 | return spirvInst == rhs.spirvInst && typeParams == rhs.typeParams;
118 | }
119 | bool operator!=(const TSpirvType& rhs) const { return !operator==(rhs); }
120 |
121 | // spirv_type
122 | TSpirvInstruction spirvInst;
123 | TSpirvTypeParameters typeParams;
124 | };
125 |
126 | } // end namespace glslang
127 |
128 | #endif // GLSLANG_WEB
129 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/glslang/MachineIndependent/RemoveTree.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
3 | // All rights reserved.
4 | //
5 | // Redistribution and use in source and binary forms, with or without
6 | // modification, are permitted provided that the following conditions
7 | // are met:
8 | //
9 | // Redistributions of source code must retain the above copyright
10 | // notice, this list of conditions and the following disclaimer.
11 | //
12 | // Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following
14 | // disclaimer in the documentation and/or other materials provided
15 | // with the distribution.
16 | //
17 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its
18 | // contributors may be used to endorse or promote products derived
19 | // from this software without specific prior written permission.
20 | //
21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 | // POSSIBILITY OF SUCH DAMAGE.
33 | //
34 |
35 | #pragma once
36 |
37 | namespace glslang {
38 |
39 | void RemoveAllTreeNodes(TIntermNode*);
40 |
41 | } // end namespace glslang
42 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/glslang/MachineIndependent/ScanContext.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2013 LunarG, Inc.
3 | //
4 | // All rights reserved.
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | //
13 | // Redistributions in binary form must reproduce the above
14 | // copyright notice, this list of conditions and the following
15 | // disclaimer in the documentation and/or other materials provided
16 | // with the distribution.
17 | //
18 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its
19 | // contributors may be used to endorse or promote products derived
20 | // from this software without specific prior written permission.
21 | //
22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 | // POSSIBILITY OF SUCH DAMAGE.
34 | //
35 |
36 | //
37 | // This holds context specific to the GLSL scanner, which
38 | // sits between the preprocessor scanner and parser.
39 | //
40 |
41 | #pragma once
42 |
43 | #include "ParseHelper.h"
44 |
45 | namespace glslang {
46 |
47 | class TPpContext;
48 | class TPpToken;
49 | class TParserToken;
50 |
51 | class TScanContext {
52 | public:
53 | explicit TScanContext(TParseContextBase& pc) :
54 | parseContext(pc),
55 | afterType(false), afterStruct(false),
56 | field(false), afterBuffer(false) { }
57 | virtual ~TScanContext() { }
58 |
59 | static void fillInKeywordMap();
60 | static void deleteKeywordMap();
61 |
62 | int tokenize(TPpContext*, TParserToken&);
63 |
64 | protected:
65 | TScanContext(TScanContext&);
66 | TScanContext& operator=(TScanContext&);
67 |
68 | int tokenizeIdentifier();
69 | int identifierOrType();
70 | int reservedWord();
71 | int identifierOrReserved(bool reserved);
72 | int es30ReservedFromGLSL(int version);
73 | int nonreservedKeyword(int esVersion, int nonEsVersion);
74 | int precisionKeyword();
75 | int matNxM();
76 | int dMat();
77 | int firstGenerationImage(bool inEs310);
78 | int secondGenerationImage();
79 |
80 | TParseContextBase& parseContext;
81 | bool afterType; // true if we've recognized a type, so can only be looking for an identifier
82 | bool afterStruct; // true if we've recognized the STRUCT keyword, so can only be looking for an identifier
83 | bool field; // true if we're on a field, right after a '.'
84 | bool afterBuffer; // true if we've recognized the BUFFER keyword
85 | TSourceLoc loc;
86 | TParserToken* parserToken;
87 | TPpToken* ppToken;
88 |
89 | const char* tokenText;
90 | int keyword;
91 | };
92 |
93 | } // end namespace glslang
94 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/glslang/MachineIndependent/propagateNoContraction.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2015-2016 Google, Inc.
3 | //
4 | // All rights reserved.
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | //
13 | // Redistributions in binary form must reproduce the above
14 | // copyright notice, this list of conditions and the following
15 | // disclaimer in the documentation and/or other materials provided
16 | // with the distribution.
17 | //
18 | // Neither the name of Google Inc. nor the names of its
19 | // contributors may be used to endorse or promote products derived
20 | // from this software without specific prior written permission.
21 | //
22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 | // POSSIBILITY OF SUCH DAMAGE.
34 |
35 | //
36 | // Visit the nodes in the glslang intermediate tree representation to
37 | // propagate 'noContraction' qualifier.
38 | //
39 |
40 | #pragma once
41 |
42 | #include "../Include/intermediate.h"
43 |
44 | namespace glslang {
45 |
46 | // Propagates the 'precise' qualifier for objects (objects marked with
47 | // 'noContraction' qualifier) from the shader source specified 'precise'
48 | // variables to all the involved objects, and add 'noContraction' qualifier for
49 | // the involved arithmetic operations.
50 | // Note that the same qualifier: 'noContraction' is used in both object nodes
51 | // and arithmetic operation nodes, but has different meaning. For object nodes,
52 | // 'noContraction' means the object is 'precise'; and for arithmetic operation
53 | // nodes, it means the operation should not be contracted.
54 | void PropagateNoContraction(const glslang::TIntermediate& intermediate);
55 | };
56 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/glslang/Public/ResourceLimits.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2016 Google, Inc.
3 | //
4 | // All rights reserved.
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | //
13 | // Redistributions in binary form must reproduce the above
14 | // copyright notice, this list of conditions and the following
15 | // disclaimer in the documentation and/or other materials provided
16 | // with the distribution.
17 | //
18 | // Neither the name of Google Inc. nor the names of its
19 | // contributors may be used to endorse or promote products derived
20 | // from this software without specific prior written permission.
21 | //
22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 | // POSSIBILITY OF SUCH DAMAGE.
34 |
35 | #ifndef _STAND_ALONE_RESOURCE_LIMITS_INCLUDED_
36 | #define _STAND_ALONE_RESOURCE_LIMITS_INCLUDED_
37 |
38 | #include
39 |
40 | #include "../Include/ResourceLimits.h"
41 |
42 | // Return pointer to user-writable Resource to pass through API in
43 | // future-proof way.
44 | extern TBuiltInResource* GetResources();
45 |
46 | // These are the default resources for TBuiltInResources, used for both
47 | // - parsing this string for the case where the user didn't supply one,
48 | // - dumping out a template for user construction of a config file.
49 | extern const TBuiltInResource* GetDefaultResources();
50 |
51 | // Returns the DefaultTBuiltInResource as a human-readable string.
52 | std::string GetDefaultTBuiltInResourceString();
53 |
54 | // Decodes the resource limits from |config| to |resources|.
55 | void DecodeResourceLimits(TBuiltInResource* resources, char* config);
56 |
57 | #endif // _STAND_ALONE_RESOURCE_LIMITS_INCLUDED_
58 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/glslang/Public/resource_limits_c.h:
--------------------------------------------------------------------------------
1 | /**
2 | BSD 2-Clause License
3 |
4 | Copyright (c) 2020, Travis Fort
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions are met:
9 |
10 | 1. Redistributions of source code must retain the above copyright notice, this
11 | list of conditions and the following disclaimer.
12 |
13 | 2. Redistributions in binary form must reproduce the above copyright notice,
14 | this list of conditions and the following disclaimer in the documentation
15 | and/or other materials provided with the distribution.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | **/
28 |
29 | #ifndef _STAND_ALONE_RESOURCE_LIMITS_C_INCLUDED_
30 | #define _STAND_ALONE_RESOURCE_LIMITS_C_INCLUDED_
31 |
32 | #include "../Include/glslang_c_interface.h"
33 |
34 | #ifdef __cplusplus
35 | extern "C" {
36 | #endif
37 |
38 | // Returns a struct that can be use to create custom resource values.
39 | glslang_resource_t* glslang_resource(void);
40 |
41 | // These are the default resources for TBuiltInResources, used for both
42 | // - parsing this string for the case where the user didn't supply one,
43 | // - dumping out a template for user construction of a config file.
44 | const glslang_resource_t* glslang_default_resource(void);
45 |
46 | // Returns the DefaultTBuiltInResource as a human-readable string.
47 | // NOTE: User is responsible for freeing this string.
48 | const char* glslang_default_resource_string();
49 |
50 | // Decodes the resource limits from |config| to |resources|.
51 | void glslang_decode_resource_limits(glslang_resource_t* resources, char* config);
52 |
53 | #ifdef __cplusplus
54 | }
55 | #endif
56 |
57 | #endif // _STAND_ALONE_RESOURCE_LIMITS_C_INCLUDED_
58 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/glslang/SPIRV/GLSL.ext.AMD.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2014-2016 The Khronos Group Inc.
3 | **
4 | ** Permission is hereby granted, free of charge, to any person obtaining a copy
5 | ** of this software and/or associated documentation files (the "Materials"),
6 | ** to deal in the Materials without restriction, including without limitation
7 | ** the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | ** and/or sell copies of the Materials, and to permit persons to whom the
9 | ** Materials are furnished to do so, subject to the following conditions:
10 | **
11 | ** The above copyright notice and this permission notice shall be included in
12 | ** all copies or substantial portions of the Materials.
13 | **
14 | ** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
15 | ** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
16 | ** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
17 | **
18 | ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 | ** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 | ** THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | ** FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS
24 | ** IN THE MATERIALS.
25 | */
26 |
27 | #ifndef GLSLextAMD_H
28 | #define GLSLextAMD_H
29 |
30 | static const int GLSLextAMDVersion = 100;
31 | static const int GLSLextAMDRevision = 7;
32 |
33 | // SPV_AMD_shader_ballot
34 | static const char* const E_SPV_AMD_shader_ballot = "SPV_AMD_shader_ballot";
35 |
36 | enum ShaderBallotAMD {
37 | ShaderBallotBadAMD = 0, // Don't use
38 |
39 | SwizzleInvocationsAMD = 1,
40 | SwizzleInvocationsMaskedAMD = 2,
41 | WriteInvocationAMD = 3,
42 | MbcntAMD = 4,
43 |
44 | ShaderBallotCountAMD
45 | };
46 |
47 | // SPV_AMD_shader_trinary_minmax
48 | static const char* const E_SPV_AMD_shader_trinary_minmax = "SPV_AMD_shader_trinary_minmax";
49 |
50 | enum ShaderTrinaryMinMaxAMD {
51 | ShaderTrinaryMinMaxBadAMD = 0, // Don't use
52 |
53 | FMin3AMD = 1,
54 | UMin3AMD = 2,
55 | SMin3AMD = 3,
56 | FMax3AMD = 4,
57 | UMax3AMD = 5,
58 | SMax3AMD = 6,
59 | FMid3AMD = 7,
60 | UMid3AMD = 8,
61 | SMid3AMD = 9,
62 |
63 | ShaderTrinaryMinMaxCountAMD
64 | };
65 |
66 | // SPV_AMD_shader_explicit_vertex_parameter
67 | static const char* const E_SPV_AMD_shader_explicit_vertex_parameter = "SPV_AMD_shader_explicit_vertex_parameter";
68 |
69 | enum ShaderExplicitVertexParameterAMD {
70 | ShaderExplicitVertexParameterBadAMD = 0, // Don't use
71 |
72 | InterpolateAtVertexAMD = 1,
73 |
74 | ShaderExplicitVertexParameterCountAMD
75 | };
76 |
77 | // SPV_AMD_gcn_shader
78 | static const char* const E_SPV_AMD_gcn_shader = "SPV_AMD_gcn_shader";
79 |
80 | enum GcnShaderAMD {
81 | GcnShaderBadAMD = 0, // Don't use
82 |
83 | CubeFaceIndexAMD = 1,
84 | CubeFaceCoordAMD = 2,
85 | TimeAMD = 3,
86 |
87 | GcnShaderCountAMD
88 | };
89 |
90 | // SPV_AMD_gpu_shader_half_float
91 | static const char* const E_SPV_AMD_gpu_shader_half_float = "SPV_AMD_gpu_shader_half_float";
92 |
93 | // SPV_AMD_texture_gather_bias_lod
94 | static const char* const E_SPV_AMD_texture_gather_bias_lod = "SPV_AMD_texture_gather_bias_lod";
95 |
96 | // SPV_AMD_gpu_shader_int16
97 | static const char* const E_SPV_AMD_gpu_shader_int16 = "SPV_AMD_gpu_shader_int16";
98 |
99 | // SPV_AMD_shader_image_load_store_lod
100 | static const char* const E_SPV_AMD_shader_image_load_store_lod = "SPV_AMD_shader_image_load_store_lod";
101 |
102 | // SPV_AMD_shader_fragment_mask
103 | static const char* const E_SPV_AMD_shader_fragment_mask = "SPV_AMD_shader_fragment_mask";
104 |
105 | // SPV_AMD_gpu_shader_half_float_fetch
106 | static const char* const E_SPV_AMD_gpu_shader_half_float_fetch = "SPV_AMD_gpu_shader_half_float_fetch";
107 |
108 | #endif // #ifndef GLSLextAMD_H
109 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/glslang/SPIRV/GLSL.ext.EXT.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2014-2016 The Khronos Group Inc.
3 | **
4 | ** Permission is hereby granted, free of charge, to any person obtaining a copy
5 | ** of this software and/or associated documentation files (the "Materials"),
6 | ** to deal in the Materials without restriction, including without limitation
7 | ** the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | ** and/or sell copies of the Materials, and to permit persons to whom the
9 | ** Materials are furnished to do so, subject to the following conditions:
10 | **
11 | ** The above copyright notice and this permission notice shall be included in
12 | ** all copies or substantial portions of the Materials.
13 | **
14 | ** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
15 | ** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
16 | ** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
17 | **
18 | ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 | ** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 | ** THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | ** FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS
24 | ** IN THE MATERIALS.
25 | */
26 |
27 | #ifndef GLSLextEXT_H
28 | #define GLSLextEXT_H
29 |
30 | static const int GLSLextEXTVersion = 100;
31 | static const int GLSLextEXTRevision = 2;
32 |
33 | static const char* const E_SPV_EXT_shader_stencil_export = "SPV_EXT_shader_stencil_export";
34 | static const char* const E_SPV_EXT_shader_viewport_index_layer = "SPV_EXT_shader_viewport_index_layer";
35 | static const char* const E_SPV_EXT_fragment_fully_covered = "SPV_EXT_fragment_fully_covered";
36 | static const char* const E_SPV_EXT_fragment_invocation_density = "SPV_EXT_fragment_invocation_density";
37 | static const char* const E_SPV_EXT_demote_to_helper_invocation = "SPV_EXT_demote_to_helper_invocation";
38 | static const char* const E_SPV_EXT_shader_atomic_float_add = "SPV_EXT_shader_atomic_float_add";
39 | static const char* const E_SPV_EXT_shader_atomic_float16_add = "SPV_EXT_shader_atomic_float16_add";
40 | static const char* const E_SPV_EXT_shader_atomic_float_min_max = "SPV_EXT_shader_atomic_float_min_max";
41 | static const char* const E_SPV_EXT_shader_image_int64 = "SPV_EXT_shader_image_int64";
42 | static const char* const E_SPV_EXT_mesh_shader = "SPV_EXT_mesh_shader";
43 |
44 | #endif // #ifndef GLSLextEXT_H
45 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/glslang/SPIRV/GLSL.ext.KHR.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2014-2020 The Khronos Group Inc.
3 | ** Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
4 | **
5 | ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 | ** of this software and/or associated documentation files (the "Materials"),
7 | ** to deal in the Materials without restriction, including without limitation
8 | ** the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 | ** and/or sell copies of the Materials, and to permit persons to whom the
10 | ** Materials are furnished to do so, subject to the following conditions:
11 | **
12 | ** The above copyright notice and this permission notice shall be included in
13 | ** all copies or substantial portions of the Materials.
14 | **
15 | ** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
16 | ** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
17 | ** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
18 | **
19 | ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 | ** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 | ** THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 | ** FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS
25 | ** IN THE MATERIALS.
26 | */
27 |
28 | #ifndef GLSLextKHR_H
29 | #define GLSLextKHR_H
30 |
31 | static const int GLSLextKHRVersion = 100;
32 | static const int GLSLextKHRRevision = 3;
33 |
34 | static const char* const E_SPV_KHR_shader_ballot = "SPV_KHR_shader_ballot";
35 | static const char* const E_SPV_KHR_subgroup_vote = "SPV_KHR_subgroup_vote";
36 | static const char* const E_SPV_KHR_device_group = "SPV_KHR_device_group";
37 | static const char* const E_SPV_KHR_multiview = "SPV_KHR_multiview";
38 | static const char* const E_SPV_KHR_shader_draw_parameters = "SPV_KHR_shader_draw_parameters";
39 | static const char* const E_SPV_KHR_16bit_storage = "SPV_KHR_16bit_storage";
40 | static const char* const E_SPV_KHR_8bit_storage = "SPV_KHR_8bit_storage";
41 | static const char* const E_SPV_KHR_storage_buffer_storage_class = "SPV_KHR_storage_buffer_storage_class";
42 | static const char* const E_SPV_KHR_post_depth_coverage = "SPV_KHR_post_depth_coverage";
43 | static const char* const E_SPV_KHR_vulkan_memory_model = "SPV_KHR_vulkan_memory_model";
44 | static const char* const E_SPV_EXT_physical_storage_buffer = "SPV_EXT_physical_storage_buffer";
45 | static const char* const E_SPV_KHR_physical_storage_buffer = "SPV_KHR_physical_storage_buffer";
46 | static const char* const E_SPV_EXT_fragment_shader_interlock = "SPV_EXT_fragment_shader_interlock";
47 | static const char* const E_SPV_KHR_shader_clock = "SPV_KHR_shader_clock";
48 | static const char* const E_SPV_KHR_non_semantic_info = "SPV_KHR_non_semantic_info";
49 | static const char* const E_SPV_KHR_ray_tracing = "SPV_KHR_ray_tracing";
50 | static const char* const E_SPV_KHR_ray_query = "SPV_KHR_ray_query";
51 | static const char* const E_SPV_KHR_fragment_shading_rate = "SPV_KHR_fragment_shading_rate";
52 | static const char* const E_SPV_KHR_terminate_invocation = "SPV_KHR_terminate_invocation";
53 | static const char* const E_SPV_KHR_workgroup_memory_explicit_layout = "SPV_KHR_workgroup_memory_explicit_layout";
54 | static const char* const E_SPV_KHR_subgroup_uniform_control_flow = "SPV_KHR_subgroup_uniform_control_flow";
55 | static const char* const E_SPV_KHR_fragment_shader_barycentric = "SPV_KHR_fragment_shader_barycentric";
56 | static const char* const E_SPV_AMD_shader_early_and_late_fragment_tests = "SPV_AMD_shader_early_and_late_fragment_tests";
57 |
58 | #endif // #ifndef GLSLextKHR_H
59 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/glslang/SPIRV/GLSL.ext.NV.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2014-2017 The Khronos Group Inc.
3 | **
4 | ** Permission is hereby granted, free of charge, to any person obtaining a copy
5 | ** of this software and/or associated documentation files (the "Materials"),
6 | ** to deal in the Materials without restriction, including without limitation
7 | ** the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | ** and/or sell copies of the Materials, and to permit persons to whom the
9 | ** Materials are furnished to do so, subject to the following conditions:
10 | **
11 | ** The above copyright notice and this permission notice shall be included in
12 | ** all copies or substantial portions of the Materials.
13 | **
14 | ** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
15 | ** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
16 | ** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
17 | **
18 | ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 | ** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 | ** THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | ** FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS
24 | ** IN THE MATERIALS.
25 | */
26 |
27 | #ifndef GLSLextNV_H
28 | #define GLSLextNV_H
29 |
30 | enum BuiltIn;
31 | enum Decoration;
32 | enum Op;
33 | enum Capability;
34 |
35 | static const int GLSLextNVVersion = 100;
36 | static const int GLSLextNVRevision = 11;
37 |
38 | //SPV_NV_sample_mask_override_coverage
39 | const char* const E_SPV_NV_sample_mask_override_coverage = "SPV_NV_sample_mask_override_coverage";
40 |
41 | //SPV_NV_geometry_shader_passthrough
42 | const char* const E_SPV_NV_geometry_shader_passthrough = "SPV_NV_geometry_shader_passthrough";
43 |
44 | //SPV_NV_viewport_array2
45 | const char* const E_SPV_NV_viewport_array2 = "SPV_NV_viewport_array2";
46 | const char* const E_ARB_shader_viewport_layer_array = "SPV_ARB_shader_viewport_layer_array";
47 |
48 | //SPV_NV_stereo_view_rendering
49 | const char* const E_SPV_NV_stereo_view_rendering = "SPV_NV_stereo_view_rendering";
50 |
51 | //SPV_NVX_multiview_per_view_attributes
52 | const char* const E_SPV_NVX_multiview_per_view_attributes = "SPV_NVX_multiview_per_view_attributes";
53 |
54 | //SPV_NV_shader_subgroup_partitioned
55 | const char* const E_SPV_NV_shader_subgroup_partitioned = "SPV_NV_shader_subgroup_partitioned";
56 |
57 | //SPV_NV_fragment_shader_barycentric
58 | const char* const E_SPV_NV_fragment_shader_barycentric = "SPV_NV_fragment_shader_barycentric";
59 |
60 | //SPV_NV_compute_shader_derivatives
61 | const char* const E_SPV_NV_compute_shader_derivatives = "SPV_NV_compute_shader_derivatives";
62 |
63 | //SPV_NV_shader_image_footprint
64 | const char* const E_SPV_NV_shader_image_footprint = "SPV_NV_shader_image_footprint";
65 |
66 | //SPV_NV_mesh_shader
67 | const char* const E_SPV_NV_mesh_shader = "SPV_NV_mesh_shader";
68 |
69 | //SPV_NV_raytracing
70 | const char* const E_SPV_NV_ray_tracing = "SPV_NV_ray_tracing";
71 |
72 | //SPV_NV_ray_tracing_motion_blur
73 | const char* const E_SPV_NV_ray_tracing_motion_blur = "SPV_NV_ray_tracing_motion_blur";
74 |
75 | //SPV_NV_shading_rate
76 | const char* const E_SPV_NV_shading_rate = "SPV_NV_shading_rate";
77 |
78 | //SPV_NV_cooperative_matrix
79 | const char* const E_SPV_NV_cooperative_matrix = "SPV_NV_cooperative_matrix";
80 |
81 | //SPV_NV_shader_sm_builtins
82 | const char* const E_SPV_NV_shader_sm_builtins = "SPV_NV_shader_sm_builtins";
83 |
84 | #endif // #ifndef GLSLextNV_H
85 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/glslang/SPIRV/GlslangToSpv.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2014 LunarG, Inc.
3 | // Copyright (C) 2015-2018 Google, Inc.
4 | //
5 | // All rights reserved.
6 | //
7 | // Redistribution and use in source and binary forms, with or without
8 | // modification, are permitted provided that the following conditions
9 | // are met:
10 | //
11 | // Redistributions of source code must retain the above copyright
12 | // notice, this list of conditions and the following disclaimer.
13 | //
14 | // Redistributions in binary form must reproduce the above
15 | // copyright notice, this list of conditions and the following
16 | // disclaimer in the documentation and/or other materials provided
17 | // with the distribution.
18 | //
19 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its
20 | // contributors may be used to endorse or promote products derived
21 | // from this software without specific prior written permission.
22 | //
23 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 | // POSSIBILITY OF SUCH DAMAGE.
35 |
36 | #pragma once
37 |
38 | #if defined(_MSC_VER) && _MSC_VER >= 1900
39 | #pragma warning(disable : 4464) // relative include path contains '..'
40 | #endif
41 |
42 | #include "SpvTools.h"
43 | #include "glslang/Include/intermediate.h"
44 |
45 | #include
46 | #include
47 |
48 | #include "Logger.h"
49 |
50 | namespace glslang {
51 |
52 | void GetSpirvVersion(std::string&);
53 | int GetSpirvGeneratorVersion();
54 | void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector& spirv,
55 | SpvOptions* options = nullptr);
56 | void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector& spirv,
57 | spv::SpvBuildLogger* logger, SpvOptions* options = nullptr);
58 | void OutputSpvBin(const std::vector& spirv, const char* baseName);
59 | void OutputSpvHex(const std::vector& spirv, const char* baseName, const char* varName);
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/glslang/SPIRV/Logger.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2016 Google, Inc.
3 | //
4 | // All rights reserved.
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | //
13 | // Redistributions in binary form must reproduce the above
14 | // copyright notice, this list of conditions and the following
15 | // disclaimer in the documentation and/or other materials provided
16 | // with the distribution.
17 | //
18 | // Neither the name of Google Inc. nor the names of its
19 | // contributors may be used to endorse or promote products derived
20 | // from this software without specific prior written permission.
21 | //
22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 | // POSSIBILITY OF SUCH DAMAGE.
34 |
35 | #ifndef GLSLANG_SPIRV_LOGGER_H
36 | #define GLSLANG_SPIRV_LOGGER_H
37 |
38 | #include
39 | #include
40 |
41 | namespace spv {
42 |
43 | // A class for holding all SPIR-V build status messages, including
44 | // missing/TBD functionalities, warnings, and errors.
45 | class SpvBuildLogger {
46 | public:
47 | SpvBuildLogger() {}
48 |
49 | #ifdef GLSLANG_WEB
50 | void tbdFunctionality(const std::string& f) { }
51 | void missingFunctionality(const std::string& f) { }
52 | void warning(const std::string& w) { }
53 | void error(const std::string& e) { errors.push_back(e); }
54 | std::string getAllMessages() { return ""; }
55 | #else
56 |
57 | // Registers a TBD functionality.
58 | void tbdFunctionality(const std::string& f);
59 | // Registers a missing functionality.
60 | void missingFunctionality(const std::string& f);
61 |
62 | // Logs a warning.
63 | void warning(const std::string& w) { warnings.push_back(w); }
64 | // Logs an error.
65 | void error(const std::string& e) { errors.push_back(e); }
66 |
67 | // Returns all messages accumulated in the order of:
68 | // TBD functionalities, missing functionalities, warnings, errors.
69 | std::string getAllMessages() const;
70 | #endif
71 |
72 | private:
73 | SpvBuildLogger(const SpvBuildLogger&);
74 |
75 | std::vector tbdFeatures;
76 | std::vector missingFeatures;
77 | std::vector warnings;
78 | std::vector errors;
79 | };
80 |
81 | } // end spv namespace
82 |
83 | #endif // GLSLANG_SPIRV_LOGGER_H
84 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/glslang/SPIRV/NonSemanticDebugPrintf.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020 The Khronos Group Inc.
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a
4 | // copy of this software and/or associated documentation files (the
5 | // "Materials"), to deal in the Materials without restriction, including
6 | // without limitation the rights to use, copy, modify, merge, publish,
7 | // distribute, sublicense, and/or sell copies of the Materials, and to
8 | // permit persons to whom the Materials are furnished to do so, subject to
9 | // the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included
12 | // in all copies or substantial portions of the Materials.
13 | //
14 | // MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
15 | // KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
16 | // SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
17 | // https://www.khronos.org/registry/
18 | //
19 | // THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 | // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 | // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 | // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 | // MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
26 | //
27 |
28 | #ifndef SPIRV_UNIFIED1_NonSemanticDebugPrintf_H_
29 | #define SPIRV_UNIFIED1_NonSemanticDebugPrintf_H_
30 |
31 | #ifdef __cplusplus
32 | extern "C" {
33 | #endif
34 |
35 | enum {
36 | NonSemanticDebugPrintfRevision = 1,
37 | NonSemanticDebugPrintfRevision_BitWidthPadding = 0x7fffffff
38 | };
39 |
40 | enum NonSemanticDebugPrintfInstructions {
41 | NonSemanticDebugPrintfDebugPrintf = 1,
42 | NonSemanticDebugPrintfInstructionsMax = 0x7fffffff
43 | };
44 |
45 |
46 | #ifdef __cplusplus
47 | }
48 | #endif
49 |
50 | #endif // SPIRV_UNIFIED1_NonSemanticDebugPrintf_H_
51 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/glslang/SPIRV/SpvTools.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2014-2016 LunarG, Inc.
3 | // Copyright (C) 2018 Google, Inc.
4 | //
5 | // All rights reserved.
6 | //
7 | // Redistribution and use in source and binary forms, with or without
8 | // modification, are permitted provided that the following conditions
9 | // are met:
10 | //
11 | // Redistributions of source code must retain the above copyright
12 | // notice, this list of conditions and the following disclaimer.
13 | //
14 | // Redistributions in binary form must reproduce the above
15 | // copyright notice, this list of conditions and the following
16 | // disclaimer in the documentation and/or other materials provided
17 | // with the distribution.
18 | //
19 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its
20 | // contributors may be used to endorse or promote products derived
21 | // from this software without specific prior written permission.
22 | //
23 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 | // POSSIBILITY OF SUCH DAMAGE.
35 |
36 | //
37 | // Call into SPIRV-Tools to disassemble, validate, and optimize.
38 | //
39 |
40 | #pragma once
41 | #ifndef GLSLANG_SPV_TOOLS_H
42 | #define GLSLANG_SPV_TOOLS_H
43 |
44 | #if ENABLE_OPT
45 | #include
46 | #include
47 | #include "spirv-tools/libspirv.h"
48 | #endif
49 |
50 | #include "glslang/MachineIndependent/localintermediate.h"
51 | #include "Logger.h"
52 |
53 | namespace glslang {
54 |
55 | struct SpvOptions {
56 | bool generateDebugInfo {false};
57 | bool stripDebugInfo {false};
58 | bool disableOptimizer {true};
59 | bool optimizeSize {false};
60 | bool disassemble {false};
61 | bool validate {false};
62 | bool emitNonSemanticShaderDebugInfo {false};
63 | bool emitNonSemanticShaderDebugSource{ false };
64 | };
65 |
66 | #if ENABLE_OPT
67 |
68 | // Use the SPIRV-Tools disassembler to print SPIR-V using a SPV_ENV_UNIVERSAL_1_3 environment.
69 | void SpirvToolsDisassemble(std::ostream& out, const std::vector& spirv);
70 |
71 | // Use the SPIRV-Tools disassembler to print SPIR-V with a provided SPIR-V environment.
72 | void SpirvToolsDisassemble(std::ostream& out, const std::vector& spirv,
73 | spv_target_env requested_context);
74 |
75 | // Apply the SPIRV-Tools validator to generated SPIR-V.
76 | void SpirvToolsValidate(const glslang::TIntermediate& intermediate, std::vector& spirv,
77 | spv::SpvBuildLogger*, bool prelegalization);
78 |
79 | // Apply the SPIRV-Tools optimizer to generated SPIR-V. HLSL SPIR-V is legalized in the process.
80 | void SpirvToolsTransform(const glslang::TIntermediate& intermediate, std::vector& spirv,
81 | spv::SpvBuildLogger*, const SpvOptions*);
82 |
83 | // Apply the SPIRV-Tools optimizer to strip debug info from SPIR-V. This is implicitly done by
84 | // SpirvToolsTransform if spvOptions->stripDebugInfo is set, but can be called separately if
85 | // optimization is disabled.
86 | void SpirvToolsStripDebugInfo(const glslang::TIntermediate& intermediate,
87 | std::vector& spirv, spv::SpvBuildLogger*);
88 |
89 | #endif
90 |
91 | } // end namespace glslang
92 |
93 | #endif // GLSLANG_SPV_TOOLS_H
94 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/glslang/SPIRV/bitutils.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015-2016 The Khronos Group Inc.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef LIBSPIRV_UTIL_BITUTILS_H_
16 | #define LIBSPIRV_UTIL_BITUTILS_H_
17 |
18 | #include
19 | #include
20 |
21 | namespace spvutils {
22 |
23 | // Performs a bitwise copy of source to the destination type Dest.
24 | template
25 | Dest BitwiseCast(Src source) {
26 | Dest dest;
27 | static_assert(sizeof(source) == sizeof(dest),
28 | "BitwiseCast: Source and destination must have the same size");
29 | std::memcpy(static_cast(&dest), &source, sizeof(dest));
30 | return dest;
31 | }
32 |
33 | // SetBits returns an integer of type with bits set
34 | // for position through , counting from the least
35 | // significant bit. In particular when Num == 0, no positions are set to 1.
36 | // A static assert will be triggered if First + Num > sizeof(T) * 8, that is,
37 | // a bit that will not fit in the underlying type is set.
38 | template
39 | struct SetBits {
40 | static_assert(First < sizeof(T) * 8,
41 | "Tried to set a bit that is shifted too far.");
42 | const static T get = (T(1) << First) | SetBits::get;
43 | };
44 |
45 | template
46 | struct SetBits {
47 | const static T get = T(0);
48 | };
49 |
50 | // This is all compile-time so we can put our tests right here.
51 | static_assert(SetBits::get == uint32_t(0x00000000),
52 | "SetBits failed");
53 | static_assert(SetBits::get == uint32_t(0x00000001),
54 | "SetBits failed");
55 | static_assert(SetBits::get == uint32_t(0x80000000),
56 | "SetBits failed");
57 | static_assert(SetBits::get == uint32_t(0x00000006),
58 | "SetBits failed");
59 | static_assert(SetBits::get == uint32_t(0xc0000000),
60 | "SetBits failed");
61 | static_assert(SetBits::get == uint32_t(0x7FFFFFFF),
62 | "SetBits failed");
63 | static_assert(SetBits::get == uint32_t(0xFFFFFFFF),
64 | "SetBits failed");
65 | static_assert(SetBits::get == uint32_t(0xFFFF0000),
66 | "SetBits failed");
67 |
68 | static_assert(SetBits::get == uint64_t(0x0000000000000001LL),
69 | "SetBits failed");
70 | static_assert(SetBits::get == uint64_t(0x8000000000000000LL),
71 | "SetBits failed");
72 | static_assert(SetBits::get == uint64_t(0xc000000000000000LL),
73 | "SetBits failed");
74 | static_assert(SetBits::get == uint64_t(0x0000000080000000LL),
75 | "SetBits failed");
76 | static_assert(SetBits::get == uint64_t(0x00000000FFFF0000LL),
77 | "SetBits failed");
78 |
79 | } // namespace spvutils
80 |
81 | #endif // LIBSPIRV_UTIL_BITUTILS_H_
82 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/glslang/SPIRV/disassemble.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (C) 2014-2015 LunarG, Inc.
3 | //
4 | // All rights reserved.
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | //
13 | // Redistributions in binary form must reproduce the above
14 | // copyright notice, this list of conditions and the following
15 | // disclaimer in the documentation and/or other materials provided
16 | // with the distribution.
17 | //
18 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its
19 | // contributors may be used to endorse or promote products derived
20 | // from this software without specific prior written permission.
21 | //
22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 | // POSSIBILITY OF SUCH DAMAGE.
34 |
35 | //
36 | // Disassembler for SPIR-V.
37 | //
38 |
39 | #pragma once
40 | #ifndef disassembler_H
41 | #define disassembler_H
42 |
43 | #include
44 | #include
45 |
46 | namespace spv {
47 |
48 | // disassemble with glslang custom disassembler
49 | void Disassemble(std::ostream& out, const std::vector&);
50 |
51 | } // end namespace spv
52 |
53 | #endif // disassembler_H
54 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/glslang/build_info.h:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2020 The Khronos Group Inc.
2 | //
3 | // All rights reserved.
4 | //
5 | // Redistribution and use in source and binary forms, with or without
6 | // modification, are permitted provided that the following conditions
7 | // are met:
8 | //
9 | // Redistributions of source code must retain the above copyright
10 | // notice, this list of conditions and the following disclaimer.
11 | //
12 | // Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following
14 | // disclaimer in the documentation and/or other materials provided
15 | // with the distribution.
16 | //
17 | // Neither the name of The Khronos Group Inc. nor the names of its
18 | // contributors may be used to endorse or promote products derived
19 | // from this software without specific prior written permission.
20 | //
21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 | // POSSIBILITY OF SUCH DAMAGE.
33 |
34 | #ifndef GLSLANG_BUILD_INFO
35 | #define GLSLANG_BUILD_INFO
36 |
37 | #define GLSLANG_VERSION_MAJOR 11
38 | #define GLSLANG_VERSION_MINOR 12
39 | #define GLSLANG_VERSION_PATCH 0
40 | #define GLSLANG_VERSION_FLAVOR ""
41 |
42 | #define GLSLANG_VERSION_GREATER_THAN(major, minor, patch) \
43 | ((GLSLANG_VERSION_MAJOR) > (major) || ((major) == GLSLANG_VERSION_MAJOR && \
44 | ((GLSLANG_VERSION_MINOR) > (minor) || ((minor) == GLSLANG_VERSION_MINOR && \
45 | (GLSLANG_VERSION_PATCH) > (patch)))))
46 |
47 | #define GLSLANG_VERSION_GREATER_OR_EQUAL_TO(major, minor, patch) \
48 | ((GLSLANG_VERSION_MAJOR) > (major) || ((major) == GLSLANG_VERSION_MAJOR && \
49 | ((GLSLANG_VERSION_MINOR) > (minor) || ((minor) == GLSLANG_VERSION_MINOR && \
50 | (GLSLANG_VERSION_PATCH >= (patch))))))
51 |
52 | #define GLSLANG_VERSION_LESS_THAN(major, minor, patch) \
53 | ((GLSLANG_VERSION_MAJOR) < (major) || ((major) == GLSLANG_VERSION_MAJOR && \
54 | ((GLSLANG_VERSION_MINOR) < (minor) || ((minor) == GLSLANG_VERSION_MINOR && \
55 | (GLSLANG_VERSION_PATCH) < (patch)))))
56 |
57 | #define GLSLANG_VERSION_LESS_OR_EQUAL_TO(major, minor, patch) \
58 | ((GLSLANG_VERSION_MAJOR) < (major) || ((major) == GLSLANG_VERSION_MAJOR && \
59 | ((GLSLANG_VERSION_MINOR) < (minor) || ((minor) == GLSLANG_VERSION_MINOR && \
60 | (GLSLANG_VERSION_PATCH <= (patch))))))
61 |
62 | #endif // GLSLANG_BUILD_INFO
63 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/ncnn/benchmark.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making ncnn available.
2 | //
3 | // Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
4 | //
5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // https://opensource.org/licenses/BSD-3-Clause
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef NCNN_BENCHMARK_H
16 | #define NCNN_BENCHMARK_H
17 |
18 | #include "layer.h"
19 | #include "mat.h"
20 | #include "platform.h"
21 |
22 | namespace ncnn {
23 |
24 | // get now timestamp in ms
25 | NCNN_EXPORT double get_current_time();
26 |
27 | // sleep milliseconds
28 | NCNN_EXPORT void sleep(unsigned long long int milliseconds = 1000);
29 |
30 | #if NCNN_BENCHMARK
31 |
32 | NCNN_EXPORT void benchmark(const Layer* layer, double start, double end);
33 | NCNN_EXPORT void benchmark(const Layer* layer, const Mat& bottom_blob, Mat& top_blob, double start, double end);
34 |
35 | #endif // NCNN_BENCHMARK
36 |
37 | } // namespace ncnn
38 |
39 | #endif // NCNN_BENCHMARK_H
40 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/ncnn/blob.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making ncnn available.
2 | //
3 | // Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
4 | //
5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // https://opensource.org/licenses/BSD-3-Clause
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef NCNN_BLOB_H
16 | #define NCNN_BLOB_H
17 |
18 | #include "mat.h"
19 | #include "platform.h"
20 |
21 | namespace ncnn {
22 |
23 | class NCNN_EXPORT Blob
24 | {
25 | public:
26 | // empty
27 | Blob();
28 |
29 | public:
30 | #if NCNN_STRING
31 | // blob name
32 | std::string name;
33 | #endif // NCNN_STRING
34 | // layer index which produce this blob as output
35 | int producer;
36 | // layer index which need this blob as input
37 | int consumer;
38 | // shape hint
39 | Mat shape;
40 | };
41 |
42 | } // namespace ncnn
43 |
44 | #endif // NCNN_BLOB_H
45 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/ncnn/datareader.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making ncnn available.
2 | //
3 | // Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
4 | //
5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // https://opensource.org/licenses/BSD-3-Clause
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef NCNN_DATAREADER_H
16 | #define NCNN_DATAREADER_H
17 |
18 | #include "platform.h"
19 | #if NCNN_STDIO
20 | #include
21 | #endif
22 |
23 | #if NCNN_PLATFORM_API
24 | #if __ANDROID_API__ >= 9
25 | #include
26 | #endif
27 | #endif // NCNN_PLATFORM_API
28 |
29 | namespace ncnn {
30 |
31 | // data read wrapper
32 | class NCNN_EXPORT DataReader
33 | {
34 | public:
35 | DataReader();
36 | virtual ~DataReader();
37 |
38 | #if NCNN_STRING
39 | // parse plain param text
40 | // return 1 if scan success
41 | virtual int scan(const char* format, void* p) const;
42 | #endif // NCNN_STRING
43 |
44 | // read binary param and model data
45 | // return bytes read
46 | virtual size_t read(void* buf, size_t size) const;
47 |
48 | // get model data reference
49 | // return bytes referenced
50 | virtual size_t reference(size_t size, const void** buf) const;
51 | };
52 |
53 | #if NCNN_STDIO
54 | class DataReaderFromStdioPrivate;
55 | class NCNN_EXPORT DataReaderFromStdio : public DataReader
56 | {
57 | public:
58 | explicit DataReaderFromStdio(FILE* fp);
59 | virtual ~DataReaderFromStdio();
60 |
61 | #if NCNN_STRING
62 | virtual int scan(const char* format, void* p) const;
63 | #endif // NCNN_STRING
64 | virtual size_t read(void* buf, size_t size) const;
65 |
66 | private:
67 | DataReaderFromStdio(const DataReaderFromStdio&);
68 | DataReaderFromStdio& operator=(const DataReaderFromStdio&);
69 |
70 | private:
71 | DataReaderFromStdioPrivate* const d;
72 | };
73 | #endif // NCNN_STDIO
74 |
75 | class DataReaderFromMemoryPrivate;
76 | class NCNN_EXPORT DataReaderFromMemory : public DataReader
77 | {
78 | public:
79 | explicit DataReaderFromMemory(const unsigned char*& mem);
80 | virtual ~DataReaderFromMemory();
81 |
82 | #if NCNN_STRING
83 | virtual int scan(const char* format, void* p) const;
84 | #endif // NCNN_STRING
85 | virtual size_t read(void* buf, size_t size) const;
86 | virtual size_t reference(size_t size, const void** buf) const;
87 |
88 | private:
89 | DataReaderFromMemory(const DataReaderFromMemory&);
90 | DataReaderFromMemory& operator=(const DataReaderFromMemory&);
91 |
92 | private:
93 | DataReaderFromMemoryPrivate* const d;
94 | };
95 |
96 | #if NCNN_PLATFORM_API
97 | #if __ANDROID_API__ >= 9
98 | class DataReaderFromAndroidAssetPrivate;
99 | class NCNN_EXPORT DataReaderFromAndroidAsset : public DataReader
100 | {
101 | public:
102 | explicit DataReaderFromAndroidAsset(AAsset* asset);
103 | virtual ~DataReaderFromAndroidAsset();
104 |
105 | #if NCNN_STRING
106 | virtual int scan(const char* format, void* p) const;
107 | #endif // NCNN_STRING
108 | virtual size_t read(void* buf, size_t size) const;
109 |
110 | private:
111 | DataReaderFromAndroidAsset(const DataReaderFromAndroidAsset&);
112 | DataReaderFromAndroidAsset& operator=(const DataReaderFromAndroidAsset&);
113 |
114 | private:
115 | DataReaderFromAndroidAssetPrivate* const d;
116 | };
117 | #endif // __ANDROID_API__ >= 9
118 | #endif // NCNN_PLATFORM_API
119 |
120 | } // namespace ncnn
121 |
122 | #endif // NCNN_DATAREADER_H
123 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/ncnn/layer_shader_type.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making ncnn available.
2 | //
3 | // Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
4 | //
5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // https://opensource.org/licenses/BSD-3-Clause
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef NCNN_LAYER_SHADER_TYPE_H
16 | #define NCNN_LAYER_SHADER_TYPE_H
17 |
18 | namespace ncnn {
19 |
20 | namespace LayerShaderType {
21 | enum LayerShaderType
22 | {
23 | #include "layer_shader_type_enum.h"
24 | };
25 | } // namespace LayerShaderType
26 |
27 | } // namespace ncnn
28 |
29 | #endif // NCNN_LAYER_SHADER_TYPE_H
30 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/ncnn/layer_type.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making ncnn available.
2 | //
3 | // Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
4 | //
5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // https://opensource.org/licenses/BSD-3-Clause
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef NCNN_LAYER_TYPE_H
16 | #define NCNN_LAYER_TYPE_H
17 |
18 | namespace ncnn {
19 |
20 | namespace LayerType {
21 | enum LayerType
22 | {
23 | #include "layer_type_enum.h"
24 | CustomBit = (1 << 8),
25 | };
26 | } // namespace LayerType
27 |
28 | } // namespace ncnn
29 |
30 | #endif // NCNN_LAYER_TYPE_H
31 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/ncnn/layer_type_enum.h:
--------------------------------------------------------------------------------
1 | // Layer Type Enum header
2 | //
3 | // This file is auto-generated by cmake, don't edit it.
4 |
5 | AbsVal = 0,
6 | ArgMax = 1,
7 | BatchNorm = 2,
8 | Bias = 3,
9 | BNLL = 4,
10 | Concat = 5,
11 | Convolution = 6,
12 | Crop = 7,
13 | Deconvolution = 8,
14 | Dropout = 9,
15 | Eltwise = 10,
16 | ELU = 11,
17 | Embed = 12,
18 | Exp = 13,
19 | Flatten = 14,
20 | InnerProduct = 15,
21 | Input = 16,
22 | Log = 17,
23 | LRN = 18,
24 | MemoryData = 19,
25 | MVN = 20,
26 | Pooling = 21,
27 | Power = 22,
28 | PReLU = 23,
29 | Proposal = 24,
30 | Reduction = 25,
31 | ReLU = 26,
32 | Reshape = 27,
33 | ROIPooling = 28,
34 | Scale = 29,
35 | Sigmoid = 30,
36 | Slice = 31,
37 | Softmax = 32,
38 | Split = 33,
39 | SPP = 34,
40 | TanH = 35,
41 | Threshold = 36,
42 | Tile = 37,
43 | RNN = 38,
44 | LSTM = 39,
45 | BinaryOp = 40,
46 | UnaryOp = 41,
47 | ConvolutionDepthWise = 42,
48 | Padding = 43,
49 | Squeeze = 44,
50 | ExpandDims = 45,
51 | Normalize = 46,
52 | Permute = 47,
53 | PriorBox = 48,
54 | DetectionOutput = 49,
55 | Interp = 50,
56 | DeconvolutionDepthWise = 51,
57 | ShuffleChannel = 52,
58 | InstanceNorm = 53,
59 | Clip = 54,
60 | Reorg = 55,
61 | YoloDetectionOutput = 56,
62 | Quantize = 57,
63 | Dequantize = 58,
64 | Yolov3DetectionOutput = 59,
65 | PSROIPooling = 60,
66 | ROIAlign = 61,
67 | Packing = 62,
68 | Requantize = 63,
69 | Cast = 64,
70 | HardSigmoid = 65,
71 | SELU = 66,
72 | HardSwish = 67,
73 | Noop = 68,
74 | PixelShuffle = 69,
75 | DeepCopy = 70,
76 | Mish = 71,
77 | StatisticsPooling = 72,
78 | Swish = 73,
79 | Gemm = 74,
80 | GroupNorm = 75,
81 | LayerNorm = 76,
82 | Softplus = 77,
83 | GRU = 78,
84 | MultiHeadAttention = 79,
85 | GELU = 80,
86 | Convolution1D = 81,
87 | Pooling1D = 82,
88 | ConvolutionDepthWise1D = 83,
89 | Convolution3D = 84,
90 | ConvolutionDepthWise3D = 85,
91 | Pooling3D = 86,
92 | MatMul = 87,
93 | Deconvolution1D = 88,
94 | DeconvolutionDepthWise1D = 89,
95 | Deconvolution3D = 90,
96 | DeconvolutionDepthWise3D = 91,
97 | Einsum = 92,
98 | DeformableConv2D = 93,
99 | GLU = 94,
100 | Fold = 95,
101 | Unfold = 96,
102 | GridSample = 97,
103 | CumulativeSum = 98,
104 | CopyTo = 99,
105 | Erf = 100,
106 | Diag = 101,
107 | CELU = 102,
108 | Shrink = 103,
109 | RMSNorm = 104,
110 | Spectrogram = 105,
111 | InverseSpectrogram = 106,
112 |
113 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/ncnn/modelbin.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making ncnn available.
2 | //
3 | // Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
4 | //
5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // https://opensource.org/licenses/BSD-3-Clause
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef NCNN_MODELBIN_H
16 | #define NCNN_MODELBIN_H
17 |
18 | #include "mat.h"
19 |
20 | namespace ncnn {
21 |
22 | class DataReader;
23 | class NCNN_EXPORT ModelBin
24 | {
25 | public:
26 | ModelBin();
27 | virtual ~ModelBin();
28 | // element type
29 | // 0 = auto
30 | // 1 = float32
31 | // 2 = float16
32 | // 3 = int8
33 | // load vec
34 | virtual Mat load(int w, int type) const;
35 | // load image
36 | virtual Mat load(int w, int h, int type) const;
37 | // load dim
38 | virtual Mat load(int w, int h, int c, int type) const;
39 | // load cube
40 | virtual Mat load(int w, int h, int d, int c, int type) const;
41 | };
42 |
43 | class ModelBinFromDataReaderPrivate;
44 | class NCNN_EXPORT ModelBinFromDataReader : public ModelBin
45 | {
46 | public:
47 | explicit ModelBinFromDataReader(const DataReader& dr);
48 | virtual ~ModelBinFromDataReader();
49 |
50 | virtual Mat load(int w, int type) const;
51 |
52 | private:
53 | ModelBinFromDataReader(const ModelBinFromDataReader&);
54 | ModelBinFromDataReader& operator=(const ModelBinFromDataReader&);
55 |
56 | private:
57 | ModelBinFromDataReaderPrivate* const d;
58 | };
59 |
60 | class ModelBinFromMatArrayPrivate;
61 | class NCNN_EXPORT ModelBinFromMatArray : public ModelBin
62 | {
63 | public:
64 | // construct from weight blob array
65 | explicit ModelBinFromMatArray(const Mat* weights);
66 | virtual ~ModelBinFromMatArray();
67 |
68 | virtual Mat load(int w, int type) const;
69 |
70 | private:
71 | ModelBinFromMatArray(const ModelBinFromMatArray&);
72 | ModelBinFromMatArray& operator=(const ModelBinFromMatArray&);
73 |
74 | private:
75 | ModelBinFromMatArrayPrivate* const d;
76 | };
77 |
78 | } // namespace ncnn
79 |
80 | #endif // NCNN_MODELBIN_H
81 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/ncnn/ncnn_export.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef NCNN_EXPORT_H
3 | #define NCNN_EXPORT_H
4 |
5 | #ifdef NCNN_STATIC_DEFINE
6 | # define NCNN_EXPORT
7 | # define NCNN_NO_EXPORT
8 | #else
9 | # ifndef NCNN_EXPORT
10 | # ifdef ncnn_EXPORTS
11 | /* We are building this library */
12 | # define NCNN_EXPORT
13 | # else
14 | /* We are using this library */
15 | # define NCNN_EXPORT
16 | # endif
17 | # endif
18 |
19 | # ifndef NCNN_NO_EXPORT
20 | # define NCNN_NO_EXPORT
21 | # endif
22 | #endif
23 |
24 | #ifndef NCNN_DEPRECATED
25 | # define NCNN_DEPRECATED __attribute__ ((__deprecated__))
26 | #endif
27 |
28 | #ifndef NCNN_DEPRECATED_EXPORT
29 | # define NCNN_DEPRECATED_EXPORT NCNN_EXPORT NCNN_DEPRECATED
30 | #endif
31 |
32 | #ifndef NCNN_DEPRECATED_NO_EXPORT
33 | # define NCNN_DEPRECATED_NO_EXPORT NCNN_NO_EXPORT NCNN_DEPRECATED
34 | #endif
35 |
36 | #if 0 /* DEFINE_NO_DEPRECATED */
37 | # ifndef NCNN_NO_DEPRECATED
38 | # define NCNN_NO_DEPRECATED
39 | # endif
40 | #endif
41 |
42 | #endif /* NCNN_EXPORT_H */
43 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/ncnn/paramdict.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making ncnn available.
2 | //
3 | // Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
4 | //
5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // https://opensource.org/licenses/BSD-3-Clause
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef NCNN_PARAMDICT_H
16 | #define NCNN_PARAMDICT_H
17 |
18 | #include "mat.h"
19 |
20 | // at most 32 parameters
21 | #define NCNN_MAX_PARAM_COUNT 32
22 |
23 | namespace ncnn {
24 |
25 | class DataReader;
26 | class Net;
27 | class ParamDictPrivate;
28 | class NCNN_EXPORT ParamDict
29 | {
30 | public:
31 | // empty
32 | ParamDict();
33 |
34 | virtual ~ParamDict();
35 |
36 | // copy
37 | ParamDict(const ParamDict&);
38 |
39 | // assign
40 | ParamDict& operator=(const ParamDict&);
41 |
42 | // get type
43 | int type(int id) const;
44 |
45 | // get int
46 | int get(int id, int def) const;
47 | // get float
48 | float get(int id, float def) const;
49 | // get array
50 | Mat get(int id, const Mat& def) const;
51 |
52 | // set int
53 | void set(int id, int i);
54 | // set float
55 | void set(int id, float f);
56 | // set array
57 | void set(int id, const Mat& v);
58 |
59 | protected:
60 | friend class Net;
61 |
62 | void clear();
63 |
64 | int load_param(const DataReader& dr);
65 | int load_param_bin(const DataReader& dr);
66 |
67 | private:
68 | ParamDictPrivate* const d;
69 | };
70 |
71 | } // namespace ncnn
72 |
73 | #endif // NCNN_PARAMDICT_H
74 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/ncnn/pipeline.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making ncnn available.
2 | //
3 | // Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
4 | //
5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // https://opensource.org/licenses/BSD-3-Clause
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef NCNN_PIPELINE_H
16 | #define NCNN_PIPELINE_H
17 |
18 | #include "mat.h"
19 | #include "platform.h"
20 | #if NCNN_VULKAN
21 | #include "gpu.h"
22 | #endif // NCNN_VULKAN
23 |
24 | namespace ncnn {
25 |
26 | #if NCNN_VULKAN
27 | class Option;
28 | class PipelinePrivate;
29 | class NCNN_EXPORT Pipeline
30 | {
31 | public:
32 | explicit Pipeline(const VulkanDevice* vkdev);
33 | virtual ~Pipeline();
34 |
35 | public:
36 | void set_optimal_local_size_xyz(int w = 4, int h = 4, int c = 4);
37 | void set_optimal_local_size_xyz(const Mat& local_size_xyz);
38 | void set_local_size_xyz(int w, int h, int c);
39 |
40 | int create(const uint32_t* spv_data, size_t spv_data_size, const std::vector& specializations);
41 |
42 | int create(int shader_type_index, const Option& opt, const std::vector& specializations);
43 |
44 | public:
45 | VkShaderModule shader_module() const;
46 | VkDescriptorSetLayout descriptorset_layout() const;
47 | VkPipelineLayout pipeline_layout() const;
48 | VkPipeline pipeline() const;
49 | VkDescriptorUpdateTemplateKHR descriptor_update_template() const;
50 |
51 | const ShaderInfo& shader_info() const;
52 |
53 | uint32_t local_size_x() const;
54 | uint32_t local_size_y() const;
55 | uint32_t local_size_z() const;
56 |
57 | protected:
58 | void set_shader_module(VkShaderModule shader_module);
59 | void set_descriptorset_layout(VkDescriptorSetLayout descriptorset_layout);
60 | void set_pipeline_layout(VkPipelineLayout pipeline_layout);
61 | void set_pipeline(VkPipeline pipeline);
62 | void set_descriptor_update_template(VkDescriptorUpdateTemplateKHR descriptor_update_template);
63 |
64 | void set_shader_info(const ShaderInfo& shader_info);
65 |
66 | public:
67 | const VulkanDevice* vkdev;
68 |
69 | private:
70 | Pipeline(const Pipeline&);
71 | Pipeline& operator=(const Pipeline&);
72 |
73 | private:
74 | PipelinePrivate* const d;
75 | };
76 |
77 | #if NCNN_PLATFORM_API
78 | #if __ANDROID_API__ >= 26
79 | class VkCompute;
80 | class NCNN_EXPORT ImportAndroidHardwareBufferPipeline : private Pipeline
81 | {
82 | public:
83 | explicit ImportAndroidHardwareBufferPipeline(const VulkanDevice* vkdev);
84 | virtual ~ImportAndroidHardwareBufferPipeline();
85 |
86 | int create(VkAndroidHardwareBufferImageAllocator* ahb_im_allocator, int type_to, int rotate_from, const Option& opt);
87 | int create(VkAndroidHardwareBufferImageAllocator* ahb_im_allocator, int type_to, int rotate_from, int target_width, int target_height, const Option& opt);
88 | void destroy();
89 |
90 | friend class VkCompute;
91 |
92 | protected:
93 | int create_shader_module(const Option& opt);
94 | int create_sampler(VkAndroidHardwareBufferImageAllocator* ahb_im_allocator);
95 | int create_descriptorset_layout();
96 |
97 | public:
98 | int type_to;
99 | int rotate_from;
100 | bool need_resize;
101 |
102 | VkSampler sampler;
103 | };
104 | #endif // __ANDROID_API__ >= 26
105 | #endif // NCNN_PLATFORM_API
106 |
107 | #endif // NCNN_VULKAN
108 |
109 | } // namespace ncnn
110 |
111 | #endif // NCNN_PIPELINE_H
112 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/ncnn/pipelinecache.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making ncnn available.
2 | //
3 | // Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
4 | //
5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // https://opensource.org/licenses/BSD-3-Clause
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef NCNN_PIPELINECACHE_H
16 | #define NCNN_PIPELINECACHE_H
17 |
18 | #include "platform.h"
19 |
20 | #include "mat.h"
21 | #include "gpu.h"
22 |
23 | namespace ncnn {
24 |
25 | #if NCNN_VULKAN
26 |
27 | class VulkanDevice;
28 | class PipelineCachePrivate;
29 | class NCNN_EXPORT PipelineCache
30 | {
31 | public:
32 | explicit PipelineCache(const VulkanDevice* _vkdev);
33 |
34 | virtual ~PipelineCache();
35 |
36 | void clear();
37 |
38 | int get_pipeline(const uint32_t* spv_data, size_t spv_data_size, const std::vector& specializations,
39 | uint32_t local_size_x, uint32_t local_size_y, uint32_t local_size_z,
40 | VkShaderModule* shader_module,
41 | VkDescriptorSetLayout* descriptorset_layout,
42 | VkPipelineLayout* pipeline_layout,
43 | VkPipeline* pipeline,
44 | VkDescriptorUpdateTemplateKHR* descriptor_update_template,
45 | ShaderInfo& shader_info) const;
46 |
47 | int get_pipeline(int shader_type_index, const Option& opt, const std::vector& specializations,
48 | uint32_t local_size_x, uint32_t local_size_y, uint32_t local_size_z,
49 | VkShaderModule* shader_module,
50 | VkDescriptorSetLayout* descriptorset_layout,
51 | VkPipelineLayout* pipeline_layout,
52 | VkPipeline* pipeline,
53 | VkDescriptorUpdateTemplateKHR* descriptor_update_template,
54 | ShaderInfo& shader_info) const;
55 |
56 | protected:
57 | int create_shader_module(int shader_type_index, const Option& opt, uint32_t local_size_x, uint32_t local_size_y, uint32_t local_size_z,
58 | VkShaderModule* _shader_module, ShaderInfo& si) const;
59 |
60 | int new_pipeline(VkShaderModule shader_module, const ShaderInfo& shader_info, const std::vector& specializations,
61 | VkDescriptorSetLayout* descriptorset_layout,
62 | VkPipelineLayout* pipeline_layout,
63 | VkPipeline* pipeline,
64 | VkDescriptorUpdateTemplateKHR* descriptor_update_template) const;
65 |
66 | protected:
67 | const VulkanDevice* vkdev;
68 |
69 | private:
70 | PipelineCache(const PipelineCache&);
71 | PipelineCache& operator=(const PipelineCache&);
72 |
73 | private:
74 | PipelineCachePrivate* const d;
75 | };
76 |
77 | #endif // NCNN_VULKAN
78 |
79 | } // namespace ncnn
80 |
81 | #endif // NCNN_PIPELINECACHE_H
82 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/ncnn/simplemath.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making ncnn available.
2 | //
3 | // Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
4 | //
5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // https://opensource.org/licenses/BSD-3-Clause
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef NCNN_SIMPLEMATH_H
16 | #define NCNN_SIMPLEMATH_H
17 |
18 | #include "platform.h"
19 |
20 | #if NCNN_SIMPLEMATH
21 |
22 | #ifdef __cplusplus
23 | extern "C" {
24 | #endif
25 | /*
26 | * ====================================================
27 | * discrete functions
28 | * ====================================================
29 | */
30 | NCNN_EXPORT float fabs(float);
31 | NCNN_EXPORT float fabsf(float);
32 | NCNN_EXPORT float fmod(float, float);
33 | NCNN_EXPORT float floor(float);
34 | NCNN_EXPORT float floorf(float);
35 | NCNN_EXPORT float round(float);
36 | NCNN_EXPORT float roundf(float);
37 | NCNN_EXPORT float ceil(float);
38 | NCNN_EXPORT float ceilf(float);
39 | NCNN_EXPORT float fmaxf(float, float);
40 | NCNN_EXPORT float truncf(float);
41 | NCNN_EXPORT float frac(float);
42 | /*
43 | * ====================================================
44 | * trigonometric functions
45 | * ====================================================
46 | */
47 | NCNN_EXPORT float sinf(float);
48 | NCNN_EXPORT float cosf(float);
49 | NCNN_EXPORT float tanf(float);
50 | NCNN_EXPORT float asinf(float);
51 | NCNN_EXPORT float acosf(float);
52 | NCNN_EXPORT float atanf(float);
53 | NCNN_EXPORT float atan2f(float, float);
54 | NCNN_EXPORT float tanhf(float);
55 |
56 | /*
57 | * ====================================================
58 | * power functions
59 | * ====================================================
60 | */
61 | NCNN_EXPORT float sqrtf(float);
62 | NCNN_EXPORT float sqrt(float);
63 | NCNN_EXPORT float powf(float, float);
64 |
65 | /*
66 | * ====================================================
67 | * exponential and logarithm functions
68 | * ====================================================
69 | */
70 | NCNN_EXPORT float expf(float);
71 | NCNN_EXPORT float frexp(float, int*);
72 | NCNN_EXPORT float logf(float);
73 | NCNN_EXPORT float log(float);
74 | NCNN_EXPORT float log10f(float);
75 |
76 | /*
77 | * ====================================================
78 | * probability functions
79 | * ====================================================
80 | */
81 | NCNN_EXPORT float erf(float);
82 | NCNN_EXPORT float erff(float);
83 | NCNN_EXPORT float erfcf(float);
84 |
85 | /*
86 | * ====================================================
87 | * other functions
88 | * ====================================================
89 | */
90 | NCNN_EXPORT int msb(unsigned int);
91 | NCNN_EXPORT float fmaf(float, float, float);
92 | NCNN_EXPORT float copysignf(float, float);
93 | NCNN_EXPORT void fesetround(int);
94 | NCNN_EXPORT int fegetround();
95 | NCNN_EXPORT float nearbyintf(float);
96 |
97 | #ifdef __cplusplus
98 | } // extern "C"
99 | #endif
100 |
101 | #endif // NCNN_SIMPLEMATH
102 |
103 | #endif // NCNN_SIMPLEMATH_H
104 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/include/ncnn/simpleomp.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making ncnn available.
2 | //
3 | // Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
4 | //
5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // https://opensource.org/licenses/BSD-3-Clause
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef NCNN_SIMPLEOMP_H
16 | #define NCNN_SIMPLEOMP_H
17 |
18 | #include "platform.h"
19 |
20 | #if NCNN_SIMPLEOMP
21 |
22 | #include
23 |
24 | // This minimal openmp runtime implementation only supports the llvm openmp abi
25 | // and only supports #pragma omp parallel for num_threads(X)
26 |
27 | #ifdef __cplusplus
28 | extern "C" {
29 | #endif
30 |
31 | NCNN_EXPORT int omp_get_max_threads();
32 |
33 | NCNN_EXPORT void omp_set_num_threads(int num_threads);
34 |
35 | NCNN_EXPORT int omp_get_dynamic();
36 |
37 | NCNN_EXPORT void omp_set_dynamic(int dynamic);
38 |
39 | NCNN_EXPORT int omp_get_num_threads();
40 |
41 | NCNN_EXPORT int omp_get_thread_num();
42 |
43 | NCNN_EXPORT int kmp_get_blocktime();
44 |
45 | NCNN_EXPORT void kmp_set_blocktime(int blocktime);
46 |
47 | #ifdef __cplusplus
48 | }
49 | #endif
50 |
51 | #endif // NCNN_SIMPLEOMP
52 |
53 | #endif // NCNN_SIMPLEOMP_H
54 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/lib/cmake/OGLCompilerTargets.cmake:
--------------------------------------------------------------------------------
1 |
2 | message(WARNING "Using `OGLCompilerTargets.cmake` is deprecated: use `find_package(glslang)` to find glslang CMake targets.")
3 |
4 | if (NOT TARGET glslang::OGLCompiler)
5 | include("${CMAKE_CURRENT_LIST_DIR}/../../lib/cmake/glslang/glslang-targets.cmake")
6 | endif()
7 |
8 | add_library(OGLCompiler ALIAS glslang::OGLCompiler)
9 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/lib/cmake/OSDependentTargets.cmake:
--------------------------------------------------------------------------------
1 |
2 | message(WARNING "Using `OSDependentTargets.cmake` is deprecated: use `find_package(glslang)` to find glslang CMake targets.")
3 |
4 | if (NOT TARGET glslang::OSDependent)
5 | include("${CMAKE_CURRENT_LIST_DIR}/../../lib/cmake/glslang/glslang-targets.cmake")
6 | endif()
7 |
8 | add_library(OSDependent ALIAS glslang::OSDependent)
9 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/lib/cmake/SPIRVTargets.cmake:
--------------------------------------------------------------------------------
1 |
2 | message(WARNING "Using `SPIRVTargets.cmake` is deprecated: use `find_package(glslang)` to find glslang CMake targets.")
3 |
4 | if (NOT TARGET glslang::SPIRV)
5 | include("${CMAKE_CURRENT_LIST_DIR}/../../lib/cmake/glslang/glslang-targets.cmake")
6 | endif()
7 |
8 | add_library(SPIRV ALIAS glslang::SPIRV)
9 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/lib/cmake/glslang/glslang-config-version.cmake:
--------------------------------------------------------------------------------
1 | # This is a basic version file for the Config-mode of find_package().
2 | # It is used by write_basic_package_version_file() as input file for configure_file()
3 | # to create a version-file which can be installed along a config.cmake file.
4 | #
5 | # The created file sets PACKAGE_VERSION_EXACT if the current version string and
6 | # the requested version string are exactly the same and it sets
7 | # PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version,
8 | # but only if the requested major version is the same as the current one.
9 | # The variable CVF_VERSION must be set before calling configure_file().
10 |
11 |
12 | set(PACKAGE_VERSION "11.12.0")
13 |
14 | if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
15 | set(PACKAGE_VERSION_COMPATIBLE FALSE)
16 | else()
17 |
18 | if("11.12.0" MATCHES "^([0-9]+)\\.")
19 | set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
20 | else()
21 | set(CVF_VERSION_MAJOR "11.12.0")
22 | endif()
23 |
24 | if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR)
25 | set(PACKAGE_VERSION_COMPATIBLE TRUE)
26 | else()
27 | set(PACKAGE_VERSION_COMPATIBLE FALSE)
28 | endif()
29 |
30 | if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
31 | set(PACKAGE_VERSION_EXACT TRUE)
32 | endif()
33 | endif()
34 |
35 |
36 | # if the installed project requested no architecture check, don't perform the check
37 | if("FALSE")
38 | return()
39 | endif()
40 |
41 | # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
42 | if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "" STREQUAL "")
43 | return()
44 | endif()
45 |
46 | # check that the installed version has the same 32/64bit-ness as the one which is currently searching:
47 | if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "")
48 | math(EXPR installedBits " * 8")
49 | set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
50 | set(PACKAGE_VERSION_UNSUITABLE TRUE)
51 | endif()
52 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/lib/cmake/glslang/glslang-config.cmake:
--------------------------------------------------------------------------------
1 |
2 | ####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
3 | ####### Any changes to this file will be overwritten by the next CMake run ####
4 | ####### The input file was glslang-config.cmake.in ########
5 |
6 | get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
7 |
8 | macro(set_and_check _var _file)
9 | set(${_var} "${_file}")
10 | if(NOT EXISTS "${_file}")
11 | message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
12 | endif()
13 | endmacro()
14 |
15 | macro(check_required_components _NAME)
16 | foreach(comp ${${_NAME}_FIND_COMPONENTS})
17 | if(NOT ${_NAME}_${comp}_FOUND)
18 | if(${_NAME}_FIND_REQUIRED_${comp})
19 | set(${_NAME}_FOUND FALSE)
20 | endif()
21 | endif()
22 | endforeach()
23 | endmacro()
24 |
25 | ####################################################################################
26 | include("${PACKAGE_PREFIX_DIR}/lib/cmake/glslang/glslang-targets.cmake")
27 |
28 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/lib/cmake/glslang/glslang-targets-release.cmake:
--------------------------------------------------------------------------------
1 | #----------------------------------------------------------------
2 | # Generated CMake target import file for configuration "release".
3 | #----------------------------------------------------------------
4 |
5 | # Commands may need to know the format version.
6 | set(CMAKE_IMPORT_FILE_VERSION 1)
7 |
8 | # Import target "glslang::OSDependent" for configuration "release"
9 | set_property(TARGET glslang::OSDependent APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
10 | set_target_properties(glslang::OSDependent PROPERTIES
11 | IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
12 | IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libOSDependent.a"
13 | )
14 |
15 | list(APPEND _IMPORT_CHECK_TARGETS glslang::OSDependent )
16 | list(APPEND _IMPORT_CHECK_FILES_FOR_glslang::OSDependent "${_IMPORT_PREFIX}/lib/libOSDependent.a" )
17 |
18 | # Import target "glslang::glslang" for configuration "release"
19 | set_property(TARGET glslang::glslang APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
20 | set_target_properties(glslang::glslang PROPERTIES
21 | IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
22 | IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libglslang.a"
23 | )
24 |
25 | list(APPEND _IMPORT_CHECK_TARGETS glslang::glslang )
26 | list(APPEND _IMPORT_CHECK_FILES_FOR_glslang::glslang "${_IMPORT_PREFIX}/lib/libglslang.a" )
27 |
28 | # Import target "glslang::MachineIndependent" for configuration "release"
29 | set_property(TARGET glslang::MachineIndependent APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
30 | set_target_properties(glslang::MachineIndependent PROPERTIES
31 | IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
32 | IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libMachineIndependent.a"
33 | )
34 |
35 | list(APPEND _IMPORT_CHECK_TARGETS glslang::MachineIndependent )
36 | list(APPEND _IMPORT_CHECK_FILES_FOR_glslang::MachineIndependent "${_IMPORT_PREFIX}/lib/libMachineIndependent.a" )
37 |
38 | # Import target "glslang::GenericCodeGen" for configuration "release"
39 | set_property(TARGET glslang::GenericCodeGen APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
40 | set_target_properties(glslang::GenericCodeGen PROPERTIES
41 | IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
42 | IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libGenericCodeGen.a"
43 | )
44 |
45 | list(APPEND _IMPORT_CHECK_TARGETS glslang::GenericCodeGen )
46 | list(APPEND _IMPORT_CHECK_FILES_FOR_glslang::GenericCodeGen "${_IMPORT_PREFIX}/lib/libGenericCodeGen.a" )
47 |
48 | # Import target "glslang::OGLCompiler" for configuration "release"
49 | set_property(TARGET glslang::OGLCompiler APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
50 | set_target_properties(glslang::OGLCompiler PROPERTIES
51 | IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
52 | IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libOGLCompiler.a"
53 | )
54 |
55 | list(APPEND _IMPORT_CHECK_TARGETS glslang::OGLCompiler )
56 | list(APPEND _IMPORT_CHECK_FILES_FOR_glslang::OGLCompiler "${_IMPORT_PREFIX}/lib/libOGLCompiler.a" )
57 |
58 | # Import target "glslang::SPIRV" for configuration "release"
59 | set_property(TARGET glslang::SPIRV APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
60 | set_target_properties(glslang::SPIRV PROPERTIES
61 | IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
62 | IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libSPIRV.a"
63 | )
64 |
65 | list(APPEND _IMPORT_CHECK_TARGETS glslang::SPIRV )
66 | list(APPEND _IMPORT_CHECK_FILES_FOR_glslang::SPIRV "${_IMPORT_PREFIX}/lib/libSPIRV.a" )
67 |
68 | # Commands beyond this point should not need to know the version.
69 | set(CMAKE_IMPORT_FILE_VERSION)
70 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/lib/cmake/glslangTargets.cmake:
--------------------------------------------------------------------------------
1 |
2 | message(WARNING "Using `glslangTargets.cmake` is deprecated: use `find_package(glslang)` to find glslang CMake targets.")
3 |
4 | if (NOT TARGET glslang::glslang)
5 | include("${CMAKE_CURRENT_LIST_DIR}/../../lib/cmake/glslang/glslang-targets.cmake")
6 | endif()
7 |
8 | if(OFF)
9 | add_library(glslang ALIAS glslang::glslang)
10 | else()
11 | add_library(glslang ALIAS glslang::glslang)
12 | add_library(MachineIndependent ALIAS glslang::MachineIndependent)
13 | add_library(GenericCodeGen ALIAS glslang::GenericCodeGen)
14 | endif()
15 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/lib/cmake/ncnn/ncnn-release.cmake:
--------------------------------------------------------------------------------
1 | #----------------------------------------------------------------
2 | # Generated CMake target import file for configuration "release".
3 | #----------------------------------------------------------------
4 |
5 | # Commands may need to know the format version.
6 | set(CMAKE_IMPORT_FILE_VERSION 1)
7 |
8 | # Import target "ncnn" for configuration "release"
9 | set_property(TARGET ncnn APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
10 | set_target_properties(ncnn PROPERTIES
11 | IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
12 | IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libncnn.a"
13 | )
14 |
15 | list(APPEND _IMPORT_CHECK_TARGETS ncnn )
16 | list(APPEND _IMPORT_CHECK_FILES_FOR_ncnn "${_IMPORT_PREFIX}/lib/libncnn.a" )
17 |
18 | # Commands beyond this point should not need to know the version.
19 | set(CMAKE_IMPORT_FILE_VERSION)
20 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/lib/cmake/ncnn/ncnnConfig.cmake:
--------------------------------------------------------------------------------
1 | set(NCNN_OPENMP ON)
2 | set(NCNN_THREADS ON)
3 | set(NCNN_VULKAN ON)
4 | set(NCNN_SHARED_LIB OFF)
5 | set(NCNN_SYSTEM_GLSLANG OFF)
6 | set(NCNN_SIMPLEVK ON)
7 |
8 | if(NCNN_OPENMP)
9 | find_package(OpenMP)
10 | endif()
11 |
12 | if(NCNN_THREADS)
13 | set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
14 | set(THREADS_PREFER_PTHREAD_FLAG TRUE)
15 | find_package(Threads REQUIRED)
16 | endif()
17 |
18 | if(NCNN_VULKAN)
19 | if(NOT NCNN_SIMPLEVK)
20 | find_package(Vulkan REQUIRED)
21 | endif()
22 |
23 | if(NOT NCNN_SHARED_LIB)
24 | if(NCNN_SYSTEM_GLSLANG)
25 | find_package(glslang QUIET)
26 | if(NOT glslang_FOUND)
27 | set(GLSLANG_TARGET_DIR "")
28 | include(${GLSLANG_TARGET_DIR}/OSDependentTargets.cmake)
29 | include(${GLSLANG_TARGET_DIR}/OGLCompilerTargets.cmake)
30 | if(EXISTS "${GLSLANG_TARGET_DIR}/HLSLTargets.cmake")
31 | # hlsl support can be optional
32 | include("${GLSLANG_TARGET_DIR}/HLSLTargets.cmake")
33 | endif()
34 | include(${GLSLANG_TARGET_DIR}/glslangTargets.cmake)
35 | include(${GLSLANG_TARGET_DIR}/SPIRVTargets.cmake)
36 | endif()
37 | else()
38 | set(glslang_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../lib/cmake/glslang")
39 | find_package(glslang QUIET)
40 | endif()
41 | endif()
42 | endif()
43 |
44 | include(${CMAKE_CURRENT_LIST_DIR}/ncnn.cmake)
45 |
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/lib/libGenericCodeGen.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/tncnn/libs/arm64-v8a/lib/libGenericCodeGen.a
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/lib/libMachineIndependent.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/tncnn/libs/arm64-v8a/lib/libMachineIndependent.a
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/lib/libOGLCompiler.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/tncnn/libs/arm64-v8a/lib/libOGLCompiler.a
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/lib/libOSDependent.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/tncnn/libs/arm64-v8a/lib/libOSDependent.a
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/lib/libSPIRV.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/tncnn/libs/arm64-v8a/lib/libSPIRV.a
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/lib/libglslang.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/tncnn/libs/arm64-v8a/lib/libglslang.a
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/lib/libncnn.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/tncnn/libs/arm64-v8a/lib/libncnn.a
--------------------------------------------------------------------------------
/tncnn/libs/arm64-v8a/lib/pkgconfig/ncnn.pc:
--------------------------------------------------------------------------------
1 | prefix=${pcfiledir}/../..
2 | librarydir=${prefix}/lib
3 | includedir=${prefix}/include
4 |
5 | Name: ncnn
6 | Description: high-performance neural network inference framework optimized for the mobile platform
7 | Version: 1.0.20250108
8 | URL: https://github.com/Tencent/ncnn
9 | Libs: -L"${librarydir}" -lncnn
10 | Cflags: -I"${includedir}"
11 |
12 |
--------------------------------------------------------------------------------
/tncnn/libs/x86_64/include/ncnn/benchmark.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making ncnn available.
2 | //
3 | // Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
4 | //
5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // https://opensource.org/licenses/BSD-3-Clause
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef NCNN_BENCHMARK_H
16 | #define NCNN_BENCHMARK_H
17 |
18 | #include "layer.h"
19 | #include "mat.h"
20 | #include "platform.h"
21 |
22 | namespace ncnn {
23 |
24 | // get now timestamp in ms
25 | NCNN_EXPORT double get_current_time();
26 |
27 | // sleep milliseconds
28 | NCNN_EXPORT void sleep(unsigned long long int milliseconds = 1000);
29 |
30 | #if NCNN_BENCHMARK
31 |
32 | NCNN_EXPORT void benchmark(const Layer* layer, double start, double end);
33 | NCNN_EXPORT void benchmark(const Layer* layer, const Mat& bottom_blob, Mat& top_blob, double start, double end);
34 |
35 | #endif // NCNN_BENCHMARK
36 |
37 | } // namespace ncnn
38 |
39 | #endif // NCNN_BENCHMARK_H
40 |
--------------------------------------------------------------------------------
/tncnn/libs/x86_64/include/ncnn/blob.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making ncnn available.
2 | //
3 | // Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
4 | //
5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // https://opensource.org/licenses/BSD-3-Clause
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef NCNN_BLOB_H
16 | #define NCNN_BLOB_H
17 |
18 | #include "mat.h"
19 | #include "platform.h"
20 |
21 | namespace ncnn {
22 |
23 | class NCNN_EXPORT Blob
24 | {
25 | public:
26 | // empty
27 | Blob();
28 |
29 | public:
30 | #if NCNN_STRING
31 | // blob name
32 | std::string name;
33 | #endif // NCNN_STRING
34 | // layer index which produce this blob as output
35 | int producer;
36 | // layer index which need this blob as input
37 | int consumer;
38 | // shape hint
39 | Mat shape;
40 | };
41 |
42 | } // namespace ncnn
43 |
44 | #endif // NCNN_BLOB_H
45 |
--------------------------------------------------------------------------------
/tncnn/libs/x86_64/include/ncnn/datareader.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making ncnn available.
2 | //
3 | // Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
4 | //
5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // https://opensource.org/licenses/BSD-3-Clause
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef NCNN_DATAREADER_H
16 | #define NCNN_DATAREADER_H
17 |
18 | #include "platform.h"
19 | #if NCNN_STDIO
20 | #include
21 | #endif
22 |
23 | #if NCNN_PLATFORM_API
24 | #if __ANDROID_API__ >= 9
25 | #include
26 | #endif
27 | #endif // NCNN_PLATFORM_API
28 |
29 | namespace ncnn {
30 |
31 | // data read wrapper
32 | class NCNN_EXPORT DataReader
33 | {
34 | public:
35 | DataReader();
36 | virtual ~DataReader();
37 |
38 | #if NCNN_STRING
39 | // parse plain param text
40 | // return 1 if scan success
41 | virtual int scan(const char* format, void* p) const;
42 | #endif // NCNN_STRING
43 |
44 | // read binary param and model data
45 | // return bytes read
46 | virtual size_t read(void* buf, size_t size) const;
47 |
48 | // get model data reference
49 | // return bytes referenced
50 | virtual size_t reference(size_t size, const void** buf) const;
51 | };
52 |
53 | #if NCNN_STDIO
54 | class DataReaderFromStdioPrivate;
55 | class NCNN_EXPORT DataReaderFromStdio : public DataReader
56 | {
57 | public:
58 | explicit DataReaderFromStdio(FILE* fp);
59 | virtual ~DataReaderFromStdio();
60 |
61 | #if NCNN_STRING
62 | virtual int scan(const char* format, void* p) const;
63 | #endif // NCNN_STRING
64 | virtual size_t read(void* buf, size_t size) const;
65 |
66 | private:
67 | DataReaderFromStdio(const DataReaderFromStdio&);
68 | DataReaderFromStdio& operator=(const DataReaderFromStdio&);
69 |
70 | private:
71 | DataReaderFromStdioPrivate* const d;
72 | };
73 | #endif // NCNN_STDIO
74 |
75 | class DataReaderFromMemoryPrivate;
76 | class NCNN_EXPORT DataReaderFromMemory : public DataReader
77 | {
78 | public:
79 | explicit DataReaderFromMemory(const unsigned char*& mem);
80 | virtual ~DataReaderFromMemory();
81 |
82 | #if NCNN_STRING
83 | virtual int scan(const char* format, void* p) const;
84 | #endif // NCNN_STRING
85 | virtual size_t read(void* buf, size_t size) const;
86 | virtual size_t reference(size_t size, const void** buf) const;
87 |
88 | private:
89 | DataReaderFromMemory(const DataReaderFromMemory&);
90 | DataReaderFromMemory& operator=(const DataReaderFromMemory&);
91 |
92 | private:
93 | DataReaderFromMemoryPrivate* const d;
94 | };
95 |
96 | #if NCNN_PLATFORM_API
97 | #if __ANDROID_API__ >= 9
98 | class DataReaderFromAndroidAssetPrivate;
99 | class NCNN_EXPORT DataReaderFromAndroidAsset : public DataReader
100 | {
101 | public:
102 | explicit DataReaderFromAndroidAsset(AAsset* asset);
103 | virtual ~DataReaderFromAndroidAsset();
104 |
105 | #if NCNN_STRING
106 | virtual int scan(const char* format, void* p) const;
107 | #endif // NCNN_STRING
108 | virtual size_t read(void* buf, size_t size) const;
109 |
110 | private:
111 | DataReaderFromAndroidAsset(const DataReaderFromAndroidAsset&);
112 | DataReaderFromAndroidAsset& operator=(const DataReaderFromAndroidAsset&);
113 |
114 | private:
115 | DataReaderFromAndroidAssetPrivate* const d;
116 | };
117 | #endif // __ANDROID_API__ >= 9
118 | #endif // NCNN_PLATFORM_API
119 |
120 | } // namespace ncnn
121 |
122 | #endif // NCNN_DATAREADER_H
123 |
--------------------------------------------------------------------------------
/tncnn/libs/x86_64/include/ncnn/layer_shader_type.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making ncnn available.
2 | //
3 | // Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
4 | //
5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // https://opensource.org/licenses/BSD-3-Clause
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef NCNN_LAYER_SHADER_TYPE_H
16 | #define NCNN_LAYER_SHADER_TYPE_H
17 |
18 | namespace ncnn {
19 |
20 | namespace LayerShaderType {
21 | enum LayerShaderType
22 | {
23 | #include "layer_shader_type_enum.h"
24 | };
25 | } // namespace LayerShaderType
26 |
27 | } // namespace ncnn
28 |
29 | #endif // NCNN_LAYER_SHADER_TYPE_H
30 |
--------------------------------------------------------------------------------
/tncnn/libs/x86_64/include/ncnn/layer_shader_type_enum.h:
--------------------------------------------------------------------------------
1 | // Layer Shader Enum header
2 | //
3 | // This file is auto-generated by cmake, don't edit it.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/tncnn/libs/x86_64/include/ncnn/layer_type.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making ncnn available.
2 | //
3 | // Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
4 | //
5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // https://opensource.org/licenses/BSD-3-Clause
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef NCNN_LAYER_TYPE_H
16 | #define NCNN_LAYER_TYPE_H
17 |
18 | namespace ncnn {
19 |
20 | namespace LayerType {
21 | enum LayerType
22 | {
23 | #include "layer_type_enum.h"
24 | CustomBit = (1 << 8),
25 | };
26 | } // namespace LayerType
27 |
28 | } // namespace ncnn
29 |
30 | #endif // NCNN_LAYER_TYPE_H
31 |
--------------------------------------------------------------------------------
/tncnn/libs/x86_64/include/ncnn/layer_type_enum.h:
--------------------------------------------------------------------------------
1 | // Layer Type Enum header
2 | //
3 | // This file is auto-generated by cmake, don't edit it.
4 |
5 | AbsVal = 0,
6 | ArgMax = 1,
7 | BatchNorm = 2,
8 | Bias = 3,
9 | BNLL = 4,
10 | Concat = 5,
11 | Convolution = 6,
12 | Crop = 7,
13 | Deconvolution = 8,
14 | Dropout = 9,
15 | Eltwise = 10,
16 | ELU = 11,
17 | Embed = 12,
18 | Exp = 13,
19 | Flatten = 14,
20 | InnerProduct = 15,
21 | Input = 16,
22 | Log = 17,
23 | LRN = 18,
24 | MemoryData = 19,
25 | MVN = 20,
26 | Pooling = 21,
27 | Power = 22,
28 | PReLU = 23,
29 | Proposal = 24,
30 | Reduction = 25,
31 | ReLU = 26,
32 | Reshape = 27,
33 | ROIPooling = 28,
34 | Scale = 29,
35 | Sigmoid = 30,
36 | Slice = 31,
37 | Softmax = 32,
38 | Split = 33,
39 | SPP = 34,
40 | TanH = 35,
41 | Threshold = 36,
42 | Tile = 37,
43 | RNN = 38,
44 | LSTM = 39,
45 | BinaryOp = 40,
46 | UnaryOp = 41,
47 | ConvolutionDepthWise = 42,
48 | Padding = 43,
49 | Squeeze = 44,
50 | ExpandDims = 45,
51 | Normalize = 46,
52 | Permute = 47,
53 | PriorBox = 48,
54 | DetectionOutput = 49,
55 | Interp = 50,
56 | DeconvolutionDepthWise = 51,
57 | ShuffleChannel = 52,
58 | InstanceNorm = 53,
59 | Clip = 54,
60 | Reorg = 55,
61 | YoloDetectionOutput = 56,
62 | Quantize = 57,
63 | Dequantize = 58,
64 | Yolov3DetectionOutput = 59,
65 | PSROIPooling = 60,
66 | ROIAlign = 61,
67 | Packing = 62,
68 | Requantize = 63,
69 | Cast = 64,
70 | HardSigmoid = 65,
71 | SELU = 66,
72 | HardSwish = 67,
73 | Noop = 68,
74 | PixelShuffle = 69,
75 | DeepCopy = 70,
76 | Mish = 71,
77 | StatisticsPooling = 72,
78 | Swish = 73,
79 | Gemm = 74,
80 | GroupNorm = 75,
81 | LayerNorm = 76,
82 | Softplus = 77,
83 | GRU = 78,
84 | MultiHeadAttention = 79,
85 | GELU = 80,
86 | Convolution1D = 81,
87 | Pooling1D = 82,
88 | ConvolutionDepthWise1D = 83,
89 | Convolution3D = 84,
90 | ConvolutionDepthWise3D = 85,
91 | Pooling3D = 86,
92 | MatMul = 87,
93 | Deconvolution1D = 88,
94 | DeconvolutionDepthWise1D = 89,
95 | Deconvolution3D = 90,
96 | DeconvolutionDepthWise3D = 91,
97 | Einsum = 92,
98 | DeformableConv2D = 93,
99 | GLU = 94,
100 | Fold = 95,
101 | Unfold = 96,
102 | GridSample = 97,
103 | CumulativeSum = 98,
104 | CopyTo = 99,
105 | Erf = 100,
106 | Diag = 101,
107 | CELU = 102,
108 | Shrink = 103,
109 | RMSNorm = 104,
110 | Spectrogram = 105,
111 | InverseSpectrogram = 106,
112 |
113 |
--------------------------------------------------------------------------------
/tncnn/libs/x86_64/include/ncnn/modelbin.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making ncnn available.
2 | //
3 | // Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
4 | //
5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // https://opensource.org/licenses/BSD-3-Clause
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef NCNN_MODELBIN_H
16 | #define NCNN_MODELBIN_H
17 |
18 | #include "mat.h"
19 |
20 | namespace ncnn {
21 |
22 | class DataReader;
23 | class NCNN_EXPORT ModelBin
24 | {
25 | public:
26 | ModelBin();
27 | virtual ~ModelBin();
28 | // element type
29 | // 0 = auto
30 | // 1 = float32
31 | // 2 = float16
32 | // 3 = int8
33 | // load vec
34 | virtual Mat load(int w, int type) const;
35 | // load image
36 | virtual Mat load(int w, int h, int type) const;
37 | // load dim
38 | virtual Mat load(int w, int h, int c, int type) const;
39 | // load cube
40 | virtual Mat load(int w, int h, int d, int c, int type) const;
41 | };
42 |
43 | class ModelBinFromDataReaderPrivate;
44 | class NCNN_EXPORT ModelBinFromDataReader : public ModelBin
45 | {
46 | public:
47 | explicit ModelBinFromDataReader(const DataReader& dr);
48 | virtual ~ModelBinFromDataReader();
49 |
50 | virtual Mat load(int w, int type) const;
51 |
52 | private:
53 | ModelBinFromDataReader(const ModelBinFromDataReader&);
54 | ModelBinFromDataReader& operator=(const ModelBinFromDataReader&);
55 |
56 | private:
57 | ModelBinFromDataReaderPrivate* const d;
58 | };
59 |
60 | class ModelBinFromMatArrayPrivate;
61 | class NCNN_EXPORT ModelBinFromMatArray : public ModelBin
62 | {
63 | public:
64 | // construct from weight blob array
65 | explicit ModelBinFromMatArray(const Mat* weights);
66 | virtual ~ModelBinFromMatArray();
67 |
68 | virtual Mat load(int w, int type) const;
69 |
70 | private:
71 | ModelBinFromMatArray(const ModelBinFromMatArray&);
72 | ModelBinFromMatArray& operator=(const ModelBinFromMatArray&);
73 |
74 | private:
75 | ModelBinFromMatArrayPrivate* const d;
76 | };
77 |
78 | } // namespace ncnn
79 |
80 | #endif // NCNN_MODELBIN_H
81 |
--------------------------------------------------------------------------------
/tncnn/libs/x86_64/include/ncnn/ncnn_export.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef NCNN_EXPORT_H
3 | #define NCNN_EXPORT_H
4 |
5 | #ifdef NCNN_STATIC_DEFINE
6 | # define NCNN_EXPORT
7 | # define NCNN_NO_EXPORT
8 | #else
9 | # ifndef NCNN_EXPORT
10 | # ifdef ncnn_EXPORTS
11 | /* We are building this library */
12 | # define NCNN_EXPORT
13 | # else
14 | /* We are using this library */
15 | # define NCNN_EXPORT
16 | # endif
17 | # endif
18 |
19 | # ifndef NCNN_NO_EXPORT
20 | # define NCNN_NO_EXPORT
21 | # endif
22 | #endif
23 |
24 | #ifndef NCNN_DEPRECATED
25 | # define NCNN_DEPRECATED
26 | #endif
27 |
28 | #ifndef NCNN_DEPRECATED_EXPORT
29 | # define NCNN_DEPRECATED_EXPORT NCNN_EXPORT NCNN_DEPRECATED
30 | #endif
31 |
32 | #ifndef NCNN_DEPRECATED_NO_EXPORT
33 | # define NCNN_DEPRECATED_NO_EXPORT NCNN_NO_EXPORT NCNN_DEPRECATED
34 | #endif
35 |
36 | #if 0 /* DEFINE_NO_DEPRECATED */
37 | # ifndef NCNN_NO_DEPRECATED
38 | # define NCNN_NO_DEPRECATED
39 | # endif
40 | #endif
41 |
42 | #endif /* NCNN_EXPORT_H */
43 |
--------------------------------------------------------------------------------
/tncnn/libs/x86_64/include/ncnn/paramdict.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making ncnn available.
2 | //
3 | // Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
4 | //
5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // https://opensource.org/licenses/BSD-3-Clause
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef NCNN_PARAMDICT_H
16 | #define NCNN_PARAMDICT_H
17 |
18 | #include "mat.h"
19 |
20 | // at most 32 parameters
21 | #define NCNN_MAX_PARAM_COUNT 32
22 |
23 | namespace ncnn {
24 |
25 | class DataReader;
26 | class Net;
27 | class ParamDictPrivate;
28 | class NCNN_EXPORT ParamDict
29 | {
30 | public:
31 | // empty
32 | ParamDict();
33 |
34 | virtual ~ParamDict();
35 |
36 | // copy
37 | ParamDict(const ParamDict&);
38 |
39 | // assign
40 | ParamDict& operator=(const ParamDict&);
41 |
42 | // get type
43 | int type(int id) const;
44 |
45 | // get int
46 | int get(int id, int def) const;
47 | // get float
48 | float get(int id, float def) const;
49 | // get array
50 | Mat get(int id, const Mat& def) const;
51 |
52 | // set int
53 | void set(int id, int i);
54 | // set float
55 | void set(int id, float f);
56 | // set array
57 | void set(int id, const Mat& v);
58 |
59 | protected:
60 | friend class Net;
61 |
62 | void clear();
63 |
64 | int load_param(const DataReader& dr);
65 | int load_param_bin(const DataReader& dr);
66 |
67 | private:
68 | ParamDictPrivate* const d;
69 | };
70 |
71 | } // namespace ncnn
72 |
73 | #endif // NCNN_PARAMDICT_H
74 |
--------------------------------------------------------------------------------
/tncnn/libs/x86_64/include/ncnn/pipeline.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making ncnn available.
2 | //
3 | // Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
4 | //
5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // https://opensource.org/licenses/BSD-3-Clause
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef NCNN_PIPELINE_H
16 | #define NCNN_PIPELINE_H
17 |
18 | #include "mat.h"
19 | #include "platform.h"
20 | #if NCNN_VULKAN
21 | #include "gpu.h"
22 | #endif // NCNN_VULKAN
23 |
24 | namespace ncnn {
25 |
26 | #if NCNN_VULKAN
27 | class Option;
28 | class PipelinePrivate;
29 | class NCNN_EXPORT Pipeline
30 | {
31 | public:
32 | explicit Pipeline(const VulkanDevice* vkdev);
33 | virtual ~Pipeline();
34 |
35 | public:
36 | void set_optimal_local_size_xyz(int w = 4, int h = 4, int c = 4);
37 | void set_optimal_local_size_xyz(const Mat& local_size_xyz);
38 | void set_local_size_xyz(int w, int h, int c);
39 |
40 | int create(const uint32_t* spv_data, size_t spv_data_size, const std::vector& specializations);
41 |
42 | int create(int shader_type_index, const Option& opt, const std::vector& specializations);
43 |
44 | public:
45 | VkShaderModule shader_module() const;
46 | VkDescriptorSetLayout descriptorset_layout() const;
47 | VkPipelineLayout pipeline_layout() const;
48 | VkPipeline pipeline() const;
49 | VkDescriptorUpdateTemplateKHR descriptor_update_template() const;
50 |
51 | const ShaderInfo& shader_info() const;
52 |
53 | uint32_t local_size_x() const;
54 | uint32_t local_size_y() const;
55 | uint32_t local_size_z() const;
56 |
57 | protected:
58 | void set_shader_module(VkShaderModule shader_module);
59 | void set_descriptorset_layout(VkDescriptorSetLayout descriptorset_layout);
60 | void set_pipeline_layout(VkPipelineLayout pipeline_layout);
61 | void set_pipeline(VkPipeline pipeline);
62 | void set_descriptor_update_template(VkDescriptorUpdateTemplateKHR descriptor_update_template);
63 |
64 | void set_shader_info(const ShaderInfo& shader_info);
65 |
66 | public:
67 | const VulkanDevice* vkdev;
68 |
69 | private:
70 | Pipeline(const Pipeline&);
71 | Pipeline& operator=(const Pipeline&);
72 |
73 | private:
74 | PipelinePrivate* const d;
75 | };
76 |
77 | #if NCNN_PLATFORM_API
78 | #if __ANDROID_API__ >= 26
79 | class VkCompute;
80 | class NCNN_EXPORT ImportAndroidHardwareBufferPipeline : private Pipeline
81 | {
82 | public:
83 | explicit ImportAndroidHardwareBufferPipeline(const VulkanDevice* vkdev);
84 | virtual ~ImportAndroidHardwareBufferPipeline();
85 |
86 | int create(VkAndroidHardwareBufferImageAllocator* ahb_im_allocator, int type_to, int rotate_from, const Option& opt);
87 | int create(VkAndroidHardwareBufferImageAllocator* ahb_im_allocator, int type_to, int rotate_from, int target_width, int target_height, const Option& opt);
88 | void destroy();
89 |
90 | friend class VkCompute;
91 |
92 | protected:
93 | int create_shader_module(const Option& opt);
94 | int create_sampler(VkAndroidHardwareBufferImageAllocator* ahb_im_allocator);
95 | int create_descriptorset_layout();
96 |
97 | public:
98 | int type_to;
99 | int rotate_from;
100 | bool need_resize;
101 |
102 | VkSampler sampler;
103 | };
104 | #endif // __ANDROID_API__ >= 26
105 | #endif // NCNN_PLATFORM_API
106 |
107 | #endif // NCNN_VULKAN
108 |
109 | } // namespace ncnn
110 |
111 | #endif // NCNN_PIPELINE_H
112 |
--------------------------------------------------------------------------------
/tncnn/libs/x86_64/include/ncnn/pipelinecache.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making ncnn available.
2 | //
3 | // Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
4 | //
5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // https://opensource.org/licenses/BSD-3-Clause
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef NCNN_PIPELINECACHE_H
16 | #define NCNN_PIPELINECACHE_H
17 |
18 | #include "platform.h"
19 |
20 | #include "mat.h"
21 | #include "gpu.h"
22 |
23 | namespace ncnn {
24 |
25 | #if NCNN_VULKAN
26 |
27 | class VulkanDevice;
28 | class PipelineCachePrivate;
29 | class NCNN_EXPORT PipelineCache
30 | {
31 | public:
32 | explicit PipelineCache(const VulkanDevice* _vkdev);
33 |
34 | virtual ~PipelineCache();
35 |
36 | void clear();
37 |
38 | int get_pipeline(const uint32_t* spv_data, size_t spv_data_size, const std::vector& specializations,
39 | uint32_t local_size_x, uint32_t local_size_y, uint32_t local_size_z,
40 | VkShaderModule* shader_module,
41 | VkDescriptorSetLayout* descriptorset_layout,
42 | VkPipelineLayout* pipeline_layout,
43 | VkPipeline* pipeline,
44 | VkDescriptorUpdateTemplateKHR* descriptor_update_template,
45 | ShaderInfo& shader_info) const;
46 |
47 | int get_pipeline(int shader_type_index, const Option& opt, const std::vector& specializations,
48 | uint32_t local_size_x, uint32_t local_size_y, uint32_t local_size_z,
49 | VkShaderModule* shader_module,
50 | VkDescriptorSetLayout* descriptorset_layout,
51 | VkPipelineLayout* pipeline_layout,
52 | VkPipeline* pipeline,
53 | VkDescriptorUpdateTemplateKHR* descriptor_update_template,
54 | ShaderInfo& shader_info) const;
55 |
56 | protected:
57 | int create_shader_module(int shader_type_index, const Option& opt, uint32_t local_size_x, uint32_t local_size_y, uint32_t local_size_z,
58 | VkShaderModule* _shader_module, ShaderInfo& si) const;
59 |
60 | int new_pipeline(VkShaderModule shader_module, const ShaderInfo& shader_info, const std::vector& specializations,
61 | VkDescriptorSetLayout* descriptorset_layout,
62 | VkPipelineLayout* pipeline_layout,
63 | VkPipeline* pipeline,
64 | VkDescriptorUpdateTemplateKHR* descriptor_update_template) const;
65 |
66 | protected:
67 | const VulkanDevice* vkdev;
68 |
69 | private:
70 | PipelineCache(const PipelineCache&);
71 | PipelineCache& operator=(const PipelineCache&);
72 |
73 | private:
74 | PipelineCachePrivate* const d;
75 | };
76 |
77 | #endif // NCNN_VULKAN
78 |
79 | } // namespace ncnn
80 |
81 | #endif // NCNN_PIPELINECACHE_H
82 |
--------------------------------------------------------------------------------
/tncnn/libs/x86_64/include/ncnn/simplemath.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making ncnn available.
2 | //
3 | // Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
4 | //
5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // https://opensource.org/licenses/BSD-3-Clause
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef NCNN_SIMPLEMATH_H
16 | #define NCNN_SIMPLEMATH_H
17 |
18 | #include "platform.h"
19 |
20 | #if NCNN_SIMPLEMATH
21 |
22 | #ifdef __cplusplus
23 | extern "C" {
24 | #endif
25 | /*
26 | * ====================================================
27 | * discrete functions
28 | * ====================================================
29 | */
30 | NCNN_EXPORT float fabs(float);
31 | NCNN_EXPORT float fabsf(float);
32 | NCNN_EXPORT float fmod(float, float);
33 | NCNN_EXPORT float floor(float);
34 | NCNN_EXPORT float floorf(float);
35 | NCNN_EXPORT float round(float);
36 | NCNN_EXPORT float roundf(float);
37 | NCNN_EXPORT float ceil(float);
38 | NCNN_EXPORT float ceilf(float);
39 | NCNN_EXPORT float fmaxf(float, float);
40 | NCNN_EXPORT float truncf(float);
41 | NCNN_EXPORT float frac(float);
42 | /*
43 | * ====================================================
44 | * trigonometric functions
45 | * ====================================================
46 | */
47 | NCNN_EXPORT float sinf(float);
48 | NCNN_EXPORT float cosf(float);
49 | NCNN_EXPORT float tanf(float);
50 | NCNN_EXPORT float asinf(float);
51 | NCNN_EXPORT float acosf(float);
52 | NCNN_EXPORT float atanf(float);
53 | NCNN_EXPORT float atan2f(float, float);
54 | NCNN_EXPORT float tanhf(float);
55 |
56 | /*
57 | * ====================================================
58 | * power functions
59 | * ====================================================
60 | */
61 | NCNN_EXPORT float sqrtf(float);
62 | NCNN_EXPORT float sqrt(float);
63 | NCNN_EXPORT float powf(float, float);
64 |
65 | /*
66 | * ====================================================
67 | * exponential and logarithm functions
68 | * ====================================================
69 | */
70 | NCNN_EXPORT float expf(float);
71 | NCNN_EXPORT float frexp(float, int*);
72 | NCNN_EXPORT float logf(float);
73 | NCNN_EXPORT float log(float);
74 | NCNN_EXPORT float log10f(float);
75 |
76 | /*
77 | * ====================================================
78 | * probability functions
79 | * ====================================================
80 | */
81 | NCNN_EXPORT float erf(float);
82 | NCNN_EXPORT float erff(float);
83 | NCNN_EXPORT float erfcf(float);
84 |
85 | /*
86 | * ====================================================
87 | * other functions
88 | * ====================================================
89 | */
90 | NCNN_EXPORT int msb(unsigned int);
91 | NCNN_EXPORT float fmaf(float, float, float);
92 | NCNN_EXPORT float copysignf(float, float);
93 | NCNN_EXPORT void fesetround(int);
94 | NCNN_EXPORT int fegetround();
95 | NCNN_EXPORT float nearbyintf(float);
96 |
97 | #ifdef __cplusplus
98 | } // extern "C"
99 | #endif
100 |
101 | #endif // NCNN_SIMPLEMATH
102 |
103 | #endif // NCNN_SIMPLEMATH_H
104 |
--------------------------------------------------------------------------------
/tncnn/libs/x86_64/include/ncnn/simpleomp.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making ncnn available.
2 | //
3 | // Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
4 | //
5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // https://opensource.org/licenses/BSD-3-Clause
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef NCNN_SIMPLEOMP_H
16 | #define NCNN_SIMPLEOMP_H
17 |
18 | #include "platform.h"
19 |
20 | #if NCNN_SIMPLEOMP
21 |
22 | #include
23 |
24 | // This minimal openmp runtime implementation only supports the llvm openmp abi
25 | // and only supports #pragma omp parallel for num_threads(X)
26 |
27 | #ifdef __cplusplus
28 | extern "C" {
29 | #endif
30 |
31 | NCNN_EXPORT int omp_get_max_threads();
32 |
33 | NCNN_EXPORT void omp_set_num_threads(int num_threads);
34 |
35 | NCNN_EXPORT int omp_get_dynamic();
36 |
37 | NCNN_EXPORT void omp_set_dynamic(int dynamic);
38 |
39 | NCNN_EXPORT int omp_get_num_threads();
40 |
41 | NCNN_EXPORT int omp_get_thread_num();
42 |
43 | NCNN_EXPORT int kmp_get_blocktime();
44 |
45 | NCNN_EXPORT void kmp_set_blocktime(int blocktime);
46 |
47 | #ifdef __cplusplus
48 | }
49 | #endif
50 |
51 | #endif // NCNN_SIMPLEOMP
52 |
53 | #endif // NCNN_SIMPLEOMP_H
54 |
--------------------------------------------------------------------------------
/tncnn/libs/x86_64/lib/cmake/ncnn/ncnn-release.cmake:
--------------------------------------------------------------------------------
1 | #----------------------------------------------------------------
2 | # Generated CMake target import file for configuration "release".
3 | #----------------------------------------------------------------
4 |
5 | # Commands may need to know the format version.
6 | set(CMAKE_IMPORT_FILE_VERSION 1)
7 |
8 | # Import target "ncnn" for configuration "release"
9 | set_property(TARGET ncnn APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
10 | set_target_properties(ncnn PROPERTIES
11 | IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
12 | IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libncnn.a"
13 | )
14 |
15 | list(APPEND _IMPORT_CHECK_TARGETS ncnn )
16 | list(APPEND _IMPORT_CHECK_FILES_FOR_ncnn "${_IMPORT_PREFIX}/lib/libncnn.a" )
17 |
18 | # Commands beyond this point should not need to know the version.
19 | set(CMAKE_IMPORT_FILE_VERSION)
20 |
--------------------------------------------------------------------------------
/tncnn/libs/x86_64/lib/cmake/ncnn/ncnn.cmake:
--------------------------------------------------------------------------------
1 | # Generated by CMake
2 |
3 | if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5)
4 | message(FATAL_ERROR "CMake >= 2.6.0 required")
5 | endif()
6 | cmake_policy(PUSH)
7 | cmake_policy(VERSION 2.6)
8 | #----------------------------------------------------------------
9 | # Generated CMake target import file.
10 | #----------------------------------------------------------------
11 |
12 | # Commands may need to know the format version.
13 | set(CMAKE_IMPORT_FILE_VERSION 1)
14 |
15 | # Protect against multiple inclusion, which would fail when already imported targets are added once more.
16 | set(_targetsDefined)
17 | set(_targetsNotDefined)
18 | set(_expectedTargets)
19 | foreach(_expectedTarget ncnn)
20 | list(APPEND _expectedTargets ${_expectedTarget})
21 | if(NOT TARGET ${_expectedTarget})
22 | list(APPEND _targetsNotDefined ${_expectedTarget})
23 | endif()
24 | if(TARGET ${_expectedTarget})
25 | list(APPEND _targetsDefined ${_expectedTarget})
26 | endif()
27 | endforeach()
28 | if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
29 | unset(_targetsDefined)
30 | unset(_targetsNotDefined)
31 | unset(_expectedTargets)
32 | set(CMAKE_IMPORT_FILE_VERSION)
33 | cmake_policy(POP)
34 | return()
35 | endif()
36 | if(NOT "${_targetsDefined}" STREQUAL "")
37 | message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
38 | endif()
39 | unset(_targetsDefined)
40 | unset(_targetsNotDefined)
41 | unset(_expectedTargets)
42 |
43 |
44 | # Compute the installation prefix relative to this file.
45 | get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
46 | get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
47 | get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
48 | get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
49 | if(_IMPORT_PREFIX STREQUAL "/")
50 | set(_IMPORT_PREFIX "")
51 | endif()
52 |
53 | # Create imported target ncnn
54 | add_library(ncnn STATIC IMPORTED)
55 |
56 | set_target_properties(ncnn PROPERTIES
57 | INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/ncnn"
58 | INTERFACE_LINK_LIBRARIES "Threads::Threads;pthread"
59 | INTERFACE_POSITION_INDEPENDENT_CODE "ON"
60 | )
61 |
62 | if(CMAKE_VERSION VERSION_LESS 2.8.12)
63 | message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.")
64 | endif()
65 |
66 | # Load information for each installed configuration.
67 | get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
68 | file(GLOB CONFIG_FILES "${_DIR}/ncnn-*.cmake")
69 | foreach(f ${CONFIG_FILES})
70 | include(${f})
71 | endforeach()
72 |
73 | # Cleanup temporary variables.
74 | set(_IMPORT_PREFIX)
75 |
76 | # Loop over all imported files and verify that they actually exist
77 | foreach(target ${_IMPORT_CHECK_TARGETS} )
78 | foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
79 | if(NOT EXISTS "${file}" )
80 | message(FATAL_ERROR "The imported target \"${target}\" references the file
81 | \"${file}\"
82 | but this file does not exist. Possible reasons include:
83 | * The file was deleted, renamed, or moved to another location.
84 | * An install or uninstall procedure did not complete successfully.
85 | * The installation package was faulty and contained
86 | \"${CMAKE_CURRENT_LIST_FILE}\"
87 | but not all the files it references.
88 | ")
89 | endif()
90 | endforeach()
91 | unset(_IMPORT_CHECK_FILES_FOR_${target})
92 | endforeach()
93 | unset(_IMPORT_CHECK_TARGETS)
94 |
95 | # This file does not depend on other imported targets which have
96 | # been exported from the same project but in a separate export set.
97 |
98 | # Commands beyond this point should not need to know the version.
99 | set(CMAKE_IMPORT_FILE_VERSION)
100 | cmake_policy(POP)
101 |
--------------------------------------------------------------------------------
/tncnn/libs/x86_64/lib/cmake/ncnn/ncnnConfig.cmake:
--------------------------------------------------------------------------------
1 | set(NCNN_OPENMP ON)
2 | set(NCNN_THREADS ON)
3 | set(NCNN_VULKAN OFF)
4 | set(NCNN_SHARED_LIB OFF)
5 | set(NCNN_SYSTEM_GLSLANG OFF)
6 | set(NCNN_SIMPLEVK ON)
7 |
8 | if(NCNN_OPENMP)
9 | find_package(OpenMP)
10 | endif()
11 |
12 | if(NCNN_THREADS)
13 | set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
14 | set(THREADS_PREFER_PTHREAD_FLAG TRUE)
15 | find_package(Threads REQUIRED)
16 | endif()
17 |
18 | if(NCNN_VULKAN)
19 | if(NOT NCNN_SIMPLEVK)
20 | find_package(Vulkan REQUIRED)
21 | endif()
22 |
23 | if(NOT NCNN_SHARED_LIB)
24 | if(NCNN_SYSTEM_GLSLANG)
25 | find_package(glslang QUIET)
26 | if(NOT glslang_FOUND)
27 | set(GLSLANG_TARGET_DIR "")
28 | include(${GLSLANG_TARGET_DIR}/OSDependentTargets.cmake)
29 | include(${GLSLANG_TARGET_DIR}/OGLCompilerTargets.cmake)
30 | if(EXISTS "${GLSLANG_TARGET_DIR}/HLSLTargets.cmake")
31 | # hlsl support can be optional
32 | include("${GLSLANG_TARGET_DIR}/HLSLTargets.cmake")
33 | endif()
34 | include(${GLSLANG_TARGET_DIR}/glslangTargets.cmake)
35 | include(${GLSLANG_TARGET_DIR}/SPIRVTargets.cmake)
36 | endif()
37 | else()
38 | set(glslang_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../lib/cmake/glslang")
39 | find_package(glslang QUIET)
40 | endif()
41 | endif()
42 | endif()
43 |
44 | include(${CMAKE_CURRENT_LIST_DIR}/ncnn.cmake)
45 |
--------------------------------------------------------------------------------
/tncnn/libs/x86_64/lib/libncnn.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmdbug/ncnn-harmony/f634d001d7a70457f9062769182fa8987d1351e2/tncnn/libs/x86_64/lib/libncnn.a
--------------------------------------------------------------------------------
/tncnn/libs/x86_64/lib/pkgconfig/ncnn.pc:
--------------------------------------------------------------------------------
1 | prefix=${pcfiledir}/../..
2 | librarydir=${prefix}/lib
3 | includedir=${prefix}/include
4 |
5 | Name: ncnn
6 | Description: high-performance neural network inference framework optimized for the mobile platform
7 | Version: 1.0.20250108
8 | URL: https://github.com/Tencent/ncnn
9 | Libs: -L"${librarydir}" -lncnn
10 | Cflags: -I"${includedir}"
11 |
12 |
--------------------------------------------------------------------------------
/tncnn/obfuscation-rules.txt:
--------------------------------------------------------------------------------
1 | # Define project specific obfuscation rules here.
2 | # You can include the obfuscation configuration files in the current module's build-profile.json5.
3 | #
4 | # For more details, see
5 | # https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
6 |
7 | # Obfuscation options:
8 | # -disable-obfuscation: disable all obfuscations
9 | # -enable-property-obfuscation: obfuscate the property names
10 | # -enable-toplevel-obfuscation: obfuscate the names in the global scope
11 | # -compact: remove unnecessary blank spaces and all line feeds
12 | # -remove-log: remove all console.* statements
13 | # -print-namecache: print the name cache that contains the mapping from the old names to new names
14 | # -apply-namecache: reuse the given cache file
15 |
16 | # Keep options:
17 | # -keep-property-name: specifies property names that you want to keep
18 | # -keep-global-name: specifies names that you want to keep in the global scope
19 |
20 | -enable-property-obfuscation
21 | -enable-toplevel-obfuscation
22 | -enable-filename-obfuscation
23 | -enable-export-obfuscation
--------------------------------------------------------------------------------
/tncnn/oh-package-lock.json5:
--------------------------------------------------------------------------------
1 | {
2 | "meta": {
3 | "stableOrder": true
4 | },
5 | "lockfileVersion": 3,
6 | "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
7 | "specifiers": {
8 | "libtncnn.so@src/main/cpp/types/libtncnn": "libtncnn.so@src/main/cpp/types/libtncnn"
9 | },
10 | "packages": {
11 | "libtncnn.so@src/main/cpp/types/libtncnn": {
12 | "name": "libtncnn.so",
13 | "version": "1.0.0",
14 | "resolved": "src/main/cpp/types/libtncnn",
15 | "registryType": "local"
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/tncnn/oh-package.json5:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tncnn",
3 | "version": "1.0.0",
4 | "description": "Please describe the basic information.",
5 | "main": "",
6 | "author": "",
7 | "license": "",
8 | "dependencies": {
9 | "libtncnn.so": "file:./src/main/cpp/types/libtncnn"
10 | }
11 | }
--------------------------------------------------------------------------------
/tncnn/src/main/cpp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # the minimum version of CMake.
2 | cmake_minimum_required(VERSION 3.5.0)
3 | project(NcnnHarmony)
4 |
5 | set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
6 |
7 | if(DEFINED PACKAGE_FIND_FILE)
8 | include(${PACKAGE_FIND_FILE})
9 | endif()
10 |
11 | include_directories(${NATIVERENDER_ROOT_PATH}
12 | ${NATIVERENDER_ROOT_PATH}/include)
13 |
14 | set(ncnn_DIR ${CMAKE_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/lib/cmake/ncnn)
15 | find_package(ncnn REQUIRED)
16 |
17 | include_directories(${CMAKE_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/include/ncnn)
18 | aux_source_directory(. SRC_LIST)
19 | add_library(
20 | tncnn
21 | SHARED
22 | ${SRC_LIST}
23 | )
24 |
25 | target_link_libraries(tncnn PUBLIC ncnn libace_napi.z.so libhilog_ndk.z.so librawfile.z.so)
26 |
--------------------------------------------------------------------------------
/tncnn/src/main/cpp/benchmark_ncnn.cpp:
--------------------------------------------------------------------------------
1 | #include "benchmark_ncnn.h"
2 | #include
3 | #include