MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / GetCommonDefines

Function GetCommonDefines

tensorflow/lite/delegates/gpu/cl/kernels/util.cc:29–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27namespace cl {
28
29std::string GetCommonDefines(CalculationsPrecision precision) {
30 std::string result;
31
32 switch (precision) {
33 case CalculationsPrecision::F32:
34 result += "#define ACCUM_FLT4 float4\n";
35 result += "#define FLT float\n";
36 result += "#define FLT2 float2\n";
37 result += "#define FLT3 float3\n";
38 result += "#define FLT4 float4\n";
39 result += "#define TO_FLT4 convert_float4\n";
40 result += "#define TO_ACCUM_TYPE convert_float4\n";
41 result += "#define TO_ACCUM_FLT convert_float\n";
42 result += "#define READ_IMAGE read_imagef\n";
43 result += "#define WRITE_IMAGE write_imagef\n";
44 break;
45 case CalculationsPrecision::F16:
46 result += "#pragma OPENCL EXTENSION cl_khr_fp16 : enable\n";
47 result += "#define ACCUM_FLT4 half4\n";
48 result += "#define FLT half\n";
49 result += "#define FLT2 half2\n";
50 result += "#define FLT3 half3\n";
51 result += "#define FLT4 half4\n";
52 result += "#define TO_FLT4 convert_half4\n";
53 result += "#define TO_ACCUM_TYPE convert_half4\n";
54 result += "#define TO_ACCUM_FLT convert_half\n";
55 result += "#define READ_IMAGE read_imageh\n";
56 result += "#define WRITE_IMAGE write_imageh\n";
57 break;
58 case CalculationsPrecision::F32_F16:
59 result += "#pragma OPENCL EXTENSION cl_khr_fp16 : enable\n";
60 result += "#define ACCUM_FLT4 float4\n";
61 result += "#define FLT half\n";
62 result += "#define FLT2 half2\n";
63 result += "#define FLT3 half3\n";
64 result += "#define FLT4 half4\n";
65 result += "#define TO_FLT4 convert_half4\n";
66 result += "#define TO_ACCUM_TYPE convert_float4\n";
67 result += "#define TO_ACCUM_FLT convert_float\n";
68 result += "#define READ_IMAGE read_imageh\n";
69 result += "#define WRITE_IMAGE write_imageh\n";
70 break;
71 }
72
73 result +=
74 "const sampler_t smp_edge = CLK_NORMALIZED_COORDS_FALSE | "
75 "CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n";
76 result +=
77 "const sampler_t smp_none = CLK_NORMALIZED_COORDS_FALSE | "
78 "CLK_ADDRESS_NONE | CLK_FILTER_NEAREST;\n";
79 result +=
80 "const sampler_t smp_zero = CLK_NORMALIZED_COORDS_FALSE | "
81 "CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST;\n";
82
83 return result;
84}
85
86std::string GetGlobalAddressNoDeclaration(TensorStorageType storage_type,

Callers 15

GetSoftmaxKernelCodeFunction · 0.85
GetMaxUnoolingKernelCodeFunction · 0.85
GetUpsampleCodeFunction · 0.85
GenerateConvBufferFunction · 0.85
GetPaddingCodeFunction · 0.85
GetElementWiseCodeMethod · 0.85
GenerateConvBuffer1x1Function · 0.85
GetConcatKernelCodeFunction · 0.85
GetReshapeCodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected