forked from tensorflow/tfjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflags_webgpu.ts
95 lines (80 loc) · 3.02 KB
/
flags_webgpu.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
import {env} from '@tensorflow/tfjs-core';
const ENV = env();
/** The batched dispatching calls size in the device queue. */
ENV.registerFlag('WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE', () => 15);
/**
* Whether we forward execution to the CPU backend if tensors are small and
* reside on the CPU.
*/
ENV.registerFlag('WEBGPU_CPU_FORWARD', () => true);
/**
* This flag is used to test different types of matmul programs.
*
* See MatMulProgramType in webgpu_util.ts for a list of available values.
*/
ENV.registerFlag('WEBGPU_MATMUL_PROGRAM_TYPE', () => -1);
/**
* Whether to use conv2dTranspose_naive which directly implement the
* conv2dTranspose logic rather than using a matmul to simulate.
*/
ENV.registerFlag('WEBGPU_USE_NAIVE_CONV2D_TRANSPOSE', () => true);
/**
* Whether we use low power GPU. Otherwise, a high performance GPU will be
* requested.
*/
ENV.registerFlag('WEBGPU_USE_LOW_POWER_GPU', () => false);
/**
* Threshold for input tensor size that determines whether WebGPU backend will
* delegate computation to CPU.
*
* Default value is 1000.
*/
ENV.registerFlag('WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD', () => 1000);
/**
* Whether to use a dummy canvas to make profiling tools like PIX work with
* TFJS webgpu backend.
*/
ENV.registerFlag('WEBGPU_USE_PROFILE_TOOL', () => false);
/**
* Whether to use import API.
*/
ENV.registerFlag('WEBGPU_IMPORT_EXTERNAL_TEXTURE', () => true);
/**
* Whether to use conv2dNaive for debugging.
*/
ENV.registerFlag('WEBGPU_USE_NAIVE_CONV2D_DEBUG', () => false);
/**
* Threshold to increase dispatched workgroups for matmul. If too few workgroups
* are dispatched, it means the hardware may be in low occupancy.
* -1 means it's not set by the user. A default strategy will be applied.
*/
ENV.registerFlag(
'WEBGPU_THRESHOLD_TO_INCREASE_WORKGROUPS_FOR_MATMUL', () => -1);
/**
* Whether we will run im2col as a separate shader for convolution.
*/
ENV.registerFlag('WEBGPU_CONV_SEPARATE_IM2COL_SHADER', () => false);
/**
* A string used to match shader key. If any matches, print the related shader.
* Seperated by comma. 'all' to print all. 'binary' to print binary(add, mul,
* etc.). 'unary,conv2d' to print both unary and conv2d.
*/
ENV.registerFlag('WEBGPU_PRINT_SHADER', () => '');
/** Experimental flag, whether enter compile only phase. */
ENV.registerFlag('WEBGPU_ENGINE_COMPILE_ONLY', () => false);