blob: 9413edf843e33b7c653ae2808640918f5108a9c8 [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
Georgios Pinitas38eec1b2020-02-06 11:22:49 +000017 if ctx.AConfig().PlatformVersionName() == "Q" || ctx.AConfig().PlatformVersionName() == "10" {
Georgios Pinitas41984a02019-12-11 12:05:17 +000018 cppflags = append(cppflags, "-fno-addrsig")
19 }
20
Georgios Pinitasfec13b82020-02-26 16:11:32 +000021 if ctx.AConfig().PlatformVersionName() == "R" || ctx.AConfig().PlatformVersionName() == "11" {
22 cppflags = append(cppflags, "-fno-addrsig")
23 }
24
Michele Di Giorgiof0a4e602020-10-15 11:54:17 +010025 data_types := strings.Split(ctx.AConfig().GetenvWithDefault("COMPUTE_LIB_DATA_TYPE", "ALL"), ",")
26
27 for _, x := range data_types {
Michalis Spyrouc4d45552020-10-19 12:41:30 +010028 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "QASYMM8" {
29 cppflags = append(cppflags, "-DENABLE_QASYMM8_KERNELS")
30 }
31 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "QASYMM8_SIGNED" {
32 cppflags = append(cppflags, "-DENABLE_QASYMM8_SIGNED_KERNELS")
33 }
34 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "QASYMM16" {
35 cppflags = append(cppflags, "-DENABLE_QASYMM16_KERNELS")
36 }
Michalis Spyroue5a41282020-11-03 17:00:04 +000037 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "QSYMM16" {
38 cppflags = append(cppflags, "-DENABLE_QSYMM16_KERNELS")
39 }
Michele Di Giorgiof0a4e602020-10-15 11:54:17 +010040 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "FP16" {
41 cppflags = append(cppflags, "-DENABLE_FP16_KERNELS")
42 }
43 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "FP32" {
44 cppflags = append(cppflags, "-DENABLE_FP32_KERNELS")
45 }
46 }
47
Georgios Pinitas41984a02019-12-11 12:05:17 +000048 return cppflags
49}
50
51func clframeworkNNDriverDefaults(ctx android.LoadHookContext) {
52 type props struct {
53 Cppflags []string
54 }
55
56 p := &props{}
57 p.Cppflags = globalFlags(ctx)
58
59 ctx.AppendProperties(p)
60}
61
62func init() {
63
64 android.RegisterModuleType("arm_compute_library_defaults", clframeworkNNDriverDefaultsFactory)
65}
66
67func clframeworkNNDriverDefaultsFactory() android.Module {
68
69 module := cc.DefaultsFactory()
70 android.AddLoadHook(module, clframeworkNNDriverDefaults)
71 return module
72}