Georgios Pinitas | 41984a0 | 2019-12-11 12:05:17 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2020 ARM Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | package arm_compute_library_nn_driver |
| 7 | |
| 8 | import ( |
| 9 | "android/soong/android" |
| 10 | "android/soong/cc" |
Michele Di Giorgio | f0a4e60 | 2020-10-15 11:54:17 +0100 | [diff] [blame] | 11 | "strings" |
Georgios Pinitas | 41984a0 | 2019-12-11 12:05:17 +0000 | [diff] [blame] | 12 | ) |
| 13 | |
| 14 | func globalFlags(ctx android.BaseContext) []string { |
| 15 | var cppflags []string |
| 16 | |
Georgios Pinitas | 38eec1b | 2020-02-06 11:22:49 +0000 | [diff] [blame] | 17 | if ctx.AConfig().PlatformVersionName() == "Q" || ctx.AConfig().PlatformVersionName() == "10" { |
Georgios Pinitas | 41984a0 | 2019-12-11 12:05:17 +0000 | [diff] [blame] | 18 | cppflags = append(cppflags, "-fno-addrsig") |
| 19 | } |
| 20 | |
Georgios Pinitas | fec13b8 | 2020-02-26 16:11:32 +0000 | [diff] [blame] | 21 | if ctx.AConfig().PlatformVersionName() == "R" || ctx.AConfig().PlatformVersionName() == "11" { |
| 22 | cppflags = append(cppflags, "-fno-addrsig") |
| 23 | } |
| 24 | |
Michele Di Giorgio | f0a4e60 | 2020-10-15 11:54:17 +0100 | [diff] [blame] | 25 | data_types := strings.Split(ctx.AConfig().GetenvWithDefault("COMPUTE_LIB_DATA_TYPE", "ALL"), ",") |
| 26 | |
| 27 | for _, x := range data_types { |
Michalis Spyrou | c4d4555 | 2020-10-19 12:41:30 +0100 | [diff] [blame] | 28 | 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 | } |
Michele Di Giorgio | f0a4e60 | 2020-10-15 11:54:17 +0100 | [diff] [blame] | 37 | if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "FP16" { |
| 38 | cppflags = append(cppflags, "-DENABLE_FP16_KERNELS") |
| 39 | } |
| 40 | if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "FP32" { |
| 41 | cppflags = append(cppflags, "-DENABLE_FP32_KERNELS") |
| 42 | } |
| 43 | } |
| 44 | |
Georgios Pinitas | 41984a0 | 2019-12-11 12:05:17 +0000 | [diff] [blame] | 45 | return cppflags |
| 46 | } |
| 47 | |
| 48 | func clframeworkNNDriverDefaults(ctx android.LoadHookContext) { |
| 49 | type props struct { |
| 50 | Cppflags []string |
| 51 | } |
| 52 | |
| 53 | p := &props{} |
| 54 | p.Cppflags = globalFlags(ctx) |
| 55 | |
| 56 | ctx.AppendProperties(p) |
| 57 | } |
| 58 | |
| 59 | func init() { |
| 60 | |
| 61 | android.RegisterModuleType("arm_compute_library_defaults", clframeworkNNDriverDefaultsFactory) |
| 62 | } |
| 63 | |
| 64 | func clframeworkNNDriverDefaultsFactory() android.Module { |
| 65 | |
| 66 | module := cc.DefaultsFactory() |
| 67 | android.AddLoadHook(module, clframeworkNNDriverDefaults) |
| 68 | return module |
| 69 | } |