# Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ncnn build
import("//build/ohos.gni")
import("//third_party/ncnn/ncnn.gni")
config("ncnn_config") {
cflags_cc = [
"-Wextra",
"-Ofast",
"-Wno-unused-function",
"-Wno-unused-variable",
"-Wno-sign-compare",
"-Wno-missing-field-initializers",
"-Wno-unused-parameter",
"-Wno-sometimes-uninitialized",
"-frtti",
#"-fvisibility=hidden",
#"-fvisibility-inlines-hidden",
]
if (NCNN_DISABLE_EXCEPTION) {
cflags_cc += ["-fno-exceptions"]
}
if (NCNN_SIMPLEOMP) {
cflags_cc += ["-fopenmp"]
}
}
ohos_source_set("ncnn_dynamic") {
sources = [
"//third_party/ncnn/src/allocator.cpp",
"//third_party/ncnn/src/benchmark.cpp",
"//third_party/ncnn/src/blob.cpp",
"//third_party/ncnn/src/c_api.cpp",
"//third_party/ncnn/src/command.cpp",
"//third_party/ncnn/src/cpu.cpp",
"//third_party/ncnn/src/datareader.cpp",
"//third_party/ncnn/src/gpu.cpp",
"//third_party/ncnn/src/layer.cpp",
"//third_party/ncnn/src/mat.cpp",
"//third_party/ncnn/src/mat_pixel.cpp",
"//third_party/ncnn/src/mat_pixel_affine.cpp",
"//third_party/ncnn/src/mat_pixel_drawing.cpp",
"//third_party/ncnn/src/mat_pixel_resize.cpp",
"//third_party/ncnn/src/mat_pixel_rotate.cpp",
"//third_party/ncnn/src/modelbin.cpp",
"//third_party/ncnn/src/net.cpp",
"//third_party/ncnn/src/option.cpp",
"//third_party/ncnn/src/paramdict.cpp",
"//third_party/ncnn/src/pipeline.cpp",
"//third_party/ncnn/src/pipelinecache.cpp",
"//third_party/ncnn/src/simpleocv.cpp",
"//third_party/ncnn/src/simpleomp.cpp",
"//third_party/ncnn/src/simplestl.cpp",
"//third_party/ncnn/src/layer/absval.cpp",
"//third_party/ncnn/src/layer/arm/absval_arm.cpp",
"//third_party/ncnn/src/layer/dropout.cpp",
"//third_party/ncnn/src/layer/arm/dropout_arm.cpp",
"//third_party/ncnn/src/layer/lrn.cpp",
"//third_party/ncnn/src/layer/arm/lrn_arm.cpp",
"//third_party/ncnn/src/layer/batchnorm.cpp",
"//third_party/ncnn/src/layer/arm/batchnorm_arm.cpp",
"//third_party/ncnn/src/layer/bias.cpp",
"//third_party/ncnn/src/layer/arm/bias_arm.cpp",
"//third_party/ncnn/src/layer/bnll.cpp",
"//third_party/ncnn/src/layer/concat.cpp",
"//third_party/ncnn/src/layer/arm/concat_arm.cpp",
"//third_party/ncnn/src/layer/convolution.cpp",
"//third_party/ncnn/src/layer/arm/convolution_arm.cpp",
"//third_party/ncnn/src/layer/crop.cpp",
"//third_party/ncnn/src/layer/arm/crop_arm.cpp",
"//third_party/ncnn/src/layer/deconvolution.cpp",
"//third_party/ncnn/src/layer/arm/deconvolution_arm.cpp",
"//third_party/ncnn/src/layer/eltwise.cpp",
"//third_party/ncnn/src/layer/arm/eltwise_arm.cpp",
"//third_party/ncnn/src/layer/elu.cpp",
"//third_party/ncnn/src/layer/embed.cpp",
"//third_party/ncnn/src/layer/exp.cpp",
"//third_party/ncnn/src/layer/flatten.cpp",
"//third_party/ncnn/src/layer/arm/flatten_arm.cpp",
"//third_party/ncnn/src/layer/innerproduct.cpp",
"//third_party/ncnn/src/layer/arm/innerproduct_arm.cpp",
"//third_party/ncnn/src/layer/input.cpp",
"//third_party/ncnn/src/layer/log.cpp",
"//third_party/ncnn/src/layer/memorydata.cpp",
"//third_party/ncnn/src/layer/mvn.cpp",
"//third_party/ncnn/src/layer/pooling.cpp",
"//third_party/ncnn/src/layer/arm/pooling_arm.cpp",
"//third_party/ncnn/src/layer/power.cpp",
"//third_party/ncnn/src/layer/prelu.cpp",
"//third_party/ncnn/src/layer/arm/prelu_arm.cpp",
"//third_party/ncnn/src/layer/proposal.cpp",
"//third_party/ncnn/src/layer/reduction.cpp",
"//third_party/ncnn/src/layer/relu.cpp",
"//third_party/ncnn/src/layer/arm/relu_arm.cpp",
"//third_party/ncnn/src/layer/reshape.cpp",
"//third_party/ncnn/src/layer/arm/reshape_arm.cpp",
"//third_party/ncnn/src/layer/roipooling.cpp",
"//third_party/ncnn/src/layer/scale.cpp",
"//third_party/ncnn/src/layer/arm/scale_arm.cpp",
"//third_party/ncnn/src/layer/sigmoid.cpp",
"//third_party/ncnn/src/layer/arm/sigmoid_arm.cpp",
"//third_party/ncnn/src/layer/slice.cpp",
"//third_party/ncnn/src/layer/arm/slice_arm.cpp",
"//third_party/ncnn/src/layer/softmax.cpp",
"//third_party/ncnn/src/layer/arm/softmax_arm.cpp",
"//third_party/ncnn/src/layer/split.cpp",
"//third_party/ncnn/src/layer/tanh.cpp",
"//third_party/ncnn/src/layer/arm/tanh_arm.cpp",
"//third_party/ncnn/src/layer/threshold.cpp",
"//third_party/ncnn/src/layer/rnn.cpp",
"//third_party/ncnn/src/layer/arm/rnn_arm.cpp",
"//third_party/ncnn/src/layer/lstm.cpp",
"//third_party/ncnn/src/layer/arm/lstm_arm.cpp",
"//third_party/ncnn/src/layer/binaryop.cpp",
"//third_party/ncnn/src/layer/arm/binaryop_arm.cpp",
"//third_party/ncnn/src/layer/unaryop.cpp",
"//third_party/ncnn/src/layer/arm/unaryop_arm.cpp",
"//third_party/ncnn/src/layer/convolutiondepthwise.cpp",
"//third_party/ncnn/src/layer/arm/convolutiondepthwise_arm.cpp",
"//third_party/ncnn/src/layer/padding.cpp",
"//third_party/ncnn/src/layer/arm/padding_arm.cpp",
"//third_party/ncnn/src/layer/squeeze.cpp",
"//third_party/ncnn/src/layer/expanddims.cpp",
"//third_party/ncnn/src/layer/normalize.cpp",
"//third_party/ncnn/src/layer/permute.cpp",
"//third_party/ncnn/src/layer/priorbox.cpp",
"//third_party/ncnn/src/layer/detectionoutput.cpp",
"//third_party/ncnn/src/layer/interp.cpp",
"//third_party/ncnn/src/layer/arm/interp_arm.cpp",
"//third_party/ncnn/src/layer/deconvolutiondepthwise.cpp",
"//third_party/ncnn/src/layer/arm/deconvolutiondepthwise_arm.cpp",
"//third_party/ncnn/src/layer/shufflechannel.cpp",
"//third_party/ncnn/src/layer/arm/shufflechannel_arm.cpp",
"//third_party/ncnn/src/layer/instancenorm.cpp",
"//third_party/ncnn/src/layer/arm/instancenorm_arm.cpp",
"//third_party/ncnn/src/layer/clip.cpp",
"//third_party/ncnn/src/layer/arm/clip_arm.cpp",
"//third_party/ncnn/src/layer/reorg.cpp",
"//third_party/ncnn/src/layer/yolodetectionoutput.cpp",
"//third_party/ncnn/src/layer/quantize.cpp",
"//third_party/ncnn/src/layer/arm/quantize_arm.cpp",
"//third_party/ncnn/src/layer/dequantize.cpp",
"//third_party/ncnn/src/layer/arm/dequantize_arm.cpp",
"//third_party/ncnn/src/layer/yolov3detectionoutput.cpp",
"//third_party/ncnn/src/layer/psroipooling.cpp",
"//third_party/ncnn/src/layer/roialign.cpp",
"//third_party/ncnn/src/layer/packing.cpp",
"//third_party/ncnn/src/layer/arm/packing_arm.cpp",
"//third_party/ncnn/src/layer/requantize.cpp",
"//third_party/ncnn/src/layer/arm/requantize_arm.cpp",
"//third_party/ncnn/src/layer/cast.cpp",
"//third_party/ncnn/src/layer/arm/cast_arm.cpp",
"//third_party/ncnn/src/layer/hardsigmoid.cpp",
"//third_party/ncnn/src/layer/arm/hardsigmoid_arm.cpp",
"//third_party/ncnn/src/layer/selu.cpp",
"//third_party/ncnn/src/layer/arm/selu_arm.cpp",
"//third_party/ncnn/src/layer/hardswish.cpp",
"//third_party/ncnn/src/layer/arm/hardswish_arm.cpp",
"//third_party/ncnn/src/layer/noop.cpp",
"//third_party/ncnn/src/layer/pixelshuffle.cpp",
"//third_party/ncnn/src/layer/arm/pixelshuffle_arm.cpp",
"//third_party/ncnn/src/layer/deepcopy.cpp",
"//third_party/ncnn/src/layer/mish.cpp",
"//third_party/ncnn/src/layer/arm/mish_arm.cpp",
"//third_party/ncnn/src/layer/statisticspooling.cpp",
"//third_party/ncnn/src/layer/swish.cpp",
"//third_party/ncnn/src/layer/arm/swish_arm.cpp",
"//third_party/ncnn/src/layer/gemm.cpp",
"//third_party/ncnn/src/layer/groupnorm.cpp",
"//third_party/ncnn/src/layer/layernorm.cpp",
"//third_party/ncnn/src/layer/softplus.cpp",
"//third_party/ncnn/src/layer/gru.cpp",
"//third_party/ncnn/src/layer/arm/gru_arm.cpp",
"//third_party/ncnn/src/layer/multiheadattention.cpp",
"//third_party/ncnn/src/layer/gelu.cpp",
"//third_party/ncnn/src/layer/convolution1d.cpp",
"//third_party/ncnn/src/layer/arm/convolution1d_arm.cpp",
"//third_party/ncnn/src/layer/pooling1d.cpp",
"//third_party/ncnn/src/layer/convolutiondepthwise1d.cpp",
"//third_party/ncnn/src/layer/convolution3d.cpp",
"//third_party/ncnn/src/layer/convolutiondepthwise3d.cpp",
"//third_party/ncnn/src/layer/pooling3d.cpp",
]
include_dirs = [
"//third_party/ncnn/src/layer/arm/",
"//third_party/ncnn/src/layer/",
"//third_party/ncnn/src/",
"${target_gen_dir}/include/",
]
deps = [":gen_layer_header"]
ldflags = []
if (NCNN_THREADS) {
ldflags += [ "-lThreads" ]
}
if (NCNN_SIMPLESTL) {
ldflags += [ "-lm" ]
}
if (NCNN_SIMPLEOMP) {
ldflags += [ "-lpthread" ]
}
configs = [ ":ncnn_config" ]
}
action("gen_layer_header") {
script = "//third_party/ncnn/src/config_layer_inc_file.sh"
args = []
outputs = ["${target_gen_dir}/include/layer_declaration.h",
"${target_gen_dir}/include/layer_registry.h",
"${target_gen_dir}/include/layer_shader_registry.h",
"${target_gen_dir}/include/layer_shader_spv_data.h",
"${target_gen_dir}/include/layer_shader_type_enum.h",
"${target_gen_dir}/include/layer_type_enum.h",
]
}
ohos_shared_library("ohosncnn") {
deps = [ ":ncnn_dynamic" ]
#下面两项,请根据实际进行修改并曲线注释
#part_name = "inputmethod_native"
#subsystem_name = "miscservices"
}
ohos_executable("ncnn_benchmark") {
sources = [
"//third_party/ncnn/benchmark/benchncnn.cpp",
]
include_dirs = [
"//third_party/ncnn/src/",
"${target_gen_dir}/include/",
]
deps = [":ohosncnn"]
configs = [ ":ncnn_config" ]
#下面两项,请根据实际进行修改并曲线注释
#part_name = "inputmethod_native"
#subsystem_name = "miscservices"
}