MCPcopy Create free account
hub / github.com/NVIDIA/FasterTransformer / test

Function test

examples/cpp/swin/swin_example.cc:30–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28
29template<typename T>
30void test(int version, int model_type, int window_size, int img_size, int batch)
31{
32 cudnnHandle_t cudnn_handle;
33 cublasHandle_t cublas_handle;
34 cublasLtHandle_t cublaslt_handle;
35 cudaStream_t stream = 0;
36 checkCUDNN(cudnnCreate(&cudnn_handle));
37 checkCUDNN(cudnnSetStream(cudnn_handle, stream));
38 check_cuda_error(cublasCreate(&cublas_handle));
39 check_cuda_error(cublasSetStream(cublas_handle, stream));
40 check_cuda_error(cublasLtCreate(&cublaslt_handle));
41
42 cublasAlgoMap* cublas_algo_map = new cublasAlgoMap(GEMM_CONFIG);
43
44 std::mutex* cublas_wrapper_mutex = new std::mutex();
45
46 cublasMMWrapper* cublas_wrapper =
47 new cublasMMWrapper(cublas_handle, cublaslt_handle, stream, cublas_algo_map, cublas_wrapper_mutex, nullptr);
48
49 if (std::is_same<T, half>::value) {
50 cublas_wrapper->setFP16GemmConfig();
51 }
52#ifdef ENABLE_BF16
53 else if (std::is_same<T, __nv_bfloat16>::value) {
54 cublas_wrapper->setBF16GemmConfig();
55 }
56#endif
57 else if (std::is_same<T, float>::value) {
58 cublas_wrapper->setFP32GemmConfig();
59 }
60
61 int embed_dim;
62 int shift_size;
63 int depths[4], num_heads[4];
64
65 if (model_type == 0) { // tiny
66 embed_dim = 96;
67 shift_size = window_size / 2;
68 depths[0] = 2;
69 depths[1] = 2;
70 depths[2] = 6;
71 depths[3] = 2;
72 num_heads[0] = 3;
73 num_heads[1] = 6;
74 num_heads[2] = 12;
75 num_heads[3] = 24;
76 }
77 else if (model_type == 1) { // small
78 embed_dim = 96;
79 shift_size = window_size / 2;
80 depths[0] = 2;
81 depths[1] = 2;
82 depths[2] = 18;
83 depths[3] = 2;
84 num_heads[0] = 3;
85 num_heads[1] = 6;
86 num_heads[2] = 12;
87 num_heads[3] = 24;

Callers

nothing calls this directly

Calls 8

getWeightNumFunction · 0.85
generateWeightSizeFunction · 0.85
getSMVersionFunction · 0.85
setFP16GemmConfigMethod · 0.80
sizeMethod · 0.45
forwardMethod · 0.45
startMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected