blob: e17b15a7cdadbdfca354a3f22f0e73d5ee093d39 [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
Pablo Marquez Tello6fc7d522021-07-13 11:09:47 +010017 if ctx.AConfig().PlatformVersionName() == "Q" || ctx.AConfig().PlatformVersionName() == "10" ||
Teresa Charlin65d04482021-02-12 12:29:26 +000018 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
Pablo Marquez Tello6fc7d522021-07-13 11:09:47 +010023 if (ctx.AConfig().PlatformVersionName() == "R" || ctx.AConfig().PlatformVersionName() == "11") &&
24 (ctx.AConfig().DevicePrimaryArchType().String() == "armv8-2a") {
25 cppflags = append(cppflags, "-march=armv8.2-a+fp16")
26 }
27
Michele Di Giorgiof0a4e602020-10-15 11:54:17 +010028 data_types := strings.Split(ctx.AConfig().GetenvWithDefault("COMPUTE_LIB_DATA_TYPE", "ALL"), ",")
29
30 for _, x := range data_types {
Michalis Spyroue9aaacd2021-01-14 13:24:05 +000031 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "INTEGER" {
32 cppflags = append(cppflags, "-DENABLE_INTEGER_KERNELS")
33 }
Michalis Spyrouc4d45552020-10-19 12:41:30 +010034 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "QASYMM8" {
35 cppflags = append(cppflags, "-DENABLE_QASYMM8_KERNELS")
36 }
37 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "QASYMM8_SIGNED" {
38 cppflags = append(cppflags, "-DENABLE_QASYMM8_SIGNED_KERNELS")
39 }
40 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "QASYMM16" {
41 cppflags = append(cppflags, "-DENABLE_QASYMM16_KERNELS")
42 }
Michalis Spyroue5a41282020-11-03 17:00:04 +000043 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "QSYMM16" {
44 cppflags = append(cppflags, "-DENABLE_QSYMM16_KERNELS")
45 }
Michele Di Giorgiof0a4e602020-10-15 11:54:17 +010046 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "FP16" {
47 cppflags = append(cppflags, "-DENABLE_FP16_KERNELS")
48 }
49 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "FP32" {
50 cppflags = append(cppflags, "-DENABLE_FP32_KERNELS")
51 }
52 }
53
Sheri Zhang79144a62021-02-08 17:43:04 +000054 data_layouts := strings.Split(ctx.AConfig().GetenvWithDefault("COMPUTE_LIB_DATA_LAYOUT", "ALL"), ",")
55
56 for _, x := range data_layouts {
57 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "NHWC" {
58 cppflags = append(cppflags, "-DENABLE_NHWC_KERNELS")
59 }
60 if strings.ToUpper(x) == "ALL" || strings.ToUpper(x) == "NCHW" {
61 cppflags = append(cppflags, "-DENABLE_NCHW_KERNELS")
62 }
63 }
64
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000065 cppflags = append(cppflags, "-ARM_COMPUTE_CPU_ENABLED")
66 cppflags = append(cppflags, "-ARM_COMPUTE_OPENCL_ENABLED")
67
Georgios Pinitas41984a02019-12-11 12:05:17 +000068 return cppflags
69}
70
71func clframeworkNNDriverDefaults(ctx android.LoadHookContext) {
72 type props struct {
73 Cppflags []string
74 }
75
76 p := &props{}
77 p.Cppflags = globalFlags(ctx)
78
79 ctx.AppendProperties(p)
80}
81
82func init() {
83
84 android.RegisterModuleType("arm_compute_library_defaults", clframeworkNNDriverDefaultsFactory)
85}
86
87func clframeworkNNDriverDefaultsFactory() android.Module {
88
89 module := cc.DefaultsFactory()
90 android.AddLoadHook(module, clframeworkNNDriverDefaults)
91 return module
92}