blob: 8b1b80a7a7abc0fbe78d25231886a9c32d3fe920 [file] [log] [blame]
Georgios Pinitas41984a02019-12-11 12:05:17 +00001//
2// Copyright © 2020 ARM Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6package arm_compute_library_nn_driver
7
8import (
9 "android/soong/android"
10 "android/soong/cc"
Michele Di Giorgiof0a4e602020-10-15 11:54:17 +010011 "strings"
Georgios Pinitas41984a02019-12-11 12:05:17 +000012)
13
14func globalFlags(ctx android.BaseContext) []string {
15 var cppflags []string
16
Teresa Charlin65d04482021-02-12 12:29:26 +000017 if ctx.AConfig().PlatformVersionName() == "Q" || ctx.AConfig().PlatformVersionName() == "10" ||
18 ctx.AConfig().PlatformVersionName() == "R" || ctx.AConfig().PlatformVersionName() == "11" ||
19 ctx.AConfig().PlatformVersionName() == "S" || ctx.AConfig().PlatformVersionName() == "12" {
Georgios Pinitasfec13b82020-02-26 16:11:32 +000020 cppflags = append(cppflags, "-fno-addrsig")
21 }
22
Michele Di Giorgiof0a4e602020-10-15 11:54:17 +010023 data_types := strings.Split(ctx.AConfig().GetenvWithDefault("COMPUTE_LIB_DATA_TYPE", "ALL"), ",")
24
25 for _, x := range data_types {
Michalis Spyroue9aaacd2021-01-14 13:24:05 +000026 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "INTEGER" {
27 cppflags = append(cppflags, "-DENABLE_INTEGER_KERNELS")
28 }
Michalis Spyrouc4d45552020-10-19 12:41:30 +010029 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "QASYMM8" {
30 cppflags = append(cppflags, "-DENABLE_QASYMM8_KERNELS")
31 }
32 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "QASYMM8_SIGNED" {
33 cppflags = append(cppflags, "-DENABLE_QASYMM8_SIGNED_KERNELS")
34 }
35 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "QASYMM16" {
36 cppflags = append(cppflags, "-DENABLE_QASYMM16_KERNELS")
37 }
Michalis Spyroue5a41282020-11-03 17:00:04 +000038 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "QSYMM16" {
39 cppflags = append(cppflags, "-DENABLE_QSYMM16_KERNELS")
40 }
Michele Di Giorgiof0a4e602020-10-15 11:54:17 +010041 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "FP16" {
42 cppflags = append(cppflags, "-DENABLE_FP16_KERNELS")
43 }
44 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "FP32" {
45 cppflags = append(cppflags, "-DENABLE_FP32_KERNELS")
46 }
47 }
48
Sheri Zhang79144a62021-02-08 17:43:04 +000049 data_layouts := strings.Split(ctx.AConfig().GetenvWithDefault("COMPUTE_LIB_DATA_LAYOUT", "ALL"), ",")
50
51 for _, x := range data_layouts {
52 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "NHWC" {
53 cppflags = append(cppflags, "-DENABLE_NHWC_KERNELS")
54 }
55 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "NCHW" {
56 cppflags = append(cppflags, "-DENABLE_NCHW_KERNELS")
57 }
58 }
59
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000060 cppflags = append(cppflags, "-ARM_COMPUTE_CPU_ENABLED")
61 cppflags = append(cppflags, "-ARM_COMPUTE_OPENCL_ENABLED")
62
Georgios Pinitas41984a02019-12-11 12:05:17 +000063 return cppflags
64}
65
66func clframeworkNNDriverDefaults(ctx android.LoadHookContext) {
67 type props struct {
68 Cppflags []string
69 }
70
71 p := &props{}
72 p.Cppflags = globalFlags(ctx)
73
74 ctx.AppendProperties(p)
75}
76
77func init() {
78
79 android.RegisterModuleType("arm_compute_library_defaults", clframeworkNNDriverDefaultsFactory)
80}
81
82func clframeworkNNDriverDefaultsFactory() android.Module {
83
84 module := cc.DefaultsFactory()
85 android.AddLoadHook(module, clframeworkNNDriverDefaults)
86 return module
87}