Skip to content

Commit 3699e53

Browse files
ssjiaSS-JIA
authored andcommitted
[ET-VK][custom_ops] Standardize test case label format across binaries
Previously the test case labels printed by each custom_ops test binary used wildly inconsistent formats. Examples from a recent on-device pass: ACCU conv1d_dw [1,16,64] K=3 s=1 p=1 d=1 Tex(HP) f32 ACCU I=144 Buf(4W) correctness_1_64_32_Buffer_Float small_1d_linear_weight ACCU In=1,16,4,4 r=2 same_qp [4W4C->4W4C] ACCU 32->3 I=64,64 g=1 k=3 Buf(4C1W) [general] Standardize all 21 binaries on: [ACCU/PERF] [INPUT->OUTPUT dtype] [shape data + inline op params] [Storage(layout)] [optional suffix] Concrete examples after this commit: ACCU f32->f32 [1,16,64] k3 s1 p1 d1 Tex(HP) ACCU i8->i8 [144]+[144] Buf(4W) ACCU f32->f32 [1,64]x[32,64] Buf(WP) ACCU i32->f32 [1,8] lw Tex(WP) ACCU i8->i8 [1,16,4,4] r=2 Buf(4W4C)->Buf(4W4C) [same_qp] ACCU f32->f32 [1,3,64,64]x[32,3,3,3] s1 p1 d1 g1 Buf(4C1W) [general] Adds three helpers to test/custom_ops/utils.h: - dtype_short(vkapi::ScalarType) -> "f32" / "f16" / "i8" / "i32" - shape_bracket(std::vector<int64_t>) -> "[N,C,H,W]" form - make_test_label(prefix, in_dtype, out_dtype, shape_str, storage_str, suffix) assembles the four sections with two-space separators and an optional bracketed suffix. Each binary's TestCase-builder helper now invokes make_test_label rather than rolling its own ostringstream. Op-specific shape detail (kernel/stride/padding/dilation/groups for conv, ratio for pixel_shuffle, output_padding for transposed conv, layout-transition arrows for clone/qdq) is constructed inline since it varies per op. Information that was load-bearing in the old labels (impl_selector tags, +bias/no_bias flags, same_qp/diff_qp markers, const_b for binary ops, multi-stage Buf->Buf transitions) is preserved as a bracketed suffix. Two minor format deviations worth flagging: - choose_qparams_per_row produces two outputs (scale tensor + zero_point tensor). Encoded as out_dtype = "f32,i8" -- a comma-separated tuple after the arrow -- rather than forcing a single token. - test_embedding_q4gsw loses the free-form prose labels (small_1d_linear_weight, llama_3_2_1b_prefill_*). Replaced with structural shape info + an lw / scales-dtype suffix; readers can still derive the same context but it is less greppable as a "story". Differential Revision: [D105059941](https://our.internmc.facebook.com/intern/diff/D105059941/) ghstack-source-id: 381655474 Pull Request resolved: #19570
1 parent 7e94810 commit 3699e53

22 files changed

Lines changed: 340 additions & 155 deletions

backends/vulkan/test/custom_ops/add.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,12 @@ std::vector<TestCase> generate_add_test_cases() {
4545
TestCase test_case;
4646

4747
// Create a descriptive name for the test case
48-
std::string size_str = "";
49-
for (size_t i = 0; i < sizes.size(); ++i) {
50-
size_str += std::to_string(sizes[i]);
51-
if (i < sizes.size() - 1)
52-
size_str += "x";
53-
}
54-
55-
std::string storage_str =
56-
(storage_type == utils::kTexture3D) ? "Texture3D" : "Buffer";
57-
std::string dtype_str = (data_type == vkapi::kFloat) ? "Float" : "Half";
58-
59-
// Add data generation type to the name for clarity
60-
std::string test_name =
61-
"Add_" + size_str + "_" + storage_str + "_" + dtype_str;
48+
std::string shape_str =
49+
shape_bracket(sizes) + "+" + shape_bracket(sizes);
50+
std::string storage_str = repr_str(storage_type, utils::kWidthPacked);
51+
std::string dtype_str = dtype_short(data_type);
52+
std::string test_name = make_test_label(
53+
"ACCU", dtype_str, dtype_str, shape_str, storage_str);
6254
test_case.set_name(test_name);
6355

6456
// Set the operator name for the test case

backends/vulkan/test/custom_ops/choose_qparams_per_row.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,19 @@ TestCase create_test_case_from_config(
3737
vkapi::ScalarType input_dtype) {
3838
TestCase test_case;
3939

40-
// Create a descriptive name for the test case
41-
std::string storage_str =
42-
(storage_type == utils::kTexture3D) ? "Texture3D" : "Buffer";
43-
std::string dtype_str = (input_dtype == vkapi::kFloat) ? "Float" : "Half";
44-
40+
// Create a descriptive name for the test case. Op produces (scale, zero_pt)
41+
// per row; the "output" is conceptually i8 quantization params.
42+
bool is_perf =
43+
!(config.num_channels < kRefDimSizeLimit &&
44+
config.channel_size < kRefDimSizeLimit);
45+
std::string prefix = is_perf ? "PERF" : "ACCU";
46+
std::string in_dtype = dtype_short(input_dtype);
47+
std::string out_dtype = "f32,i8"; // pair: (scale, zero_point)
48+
std::string shape_str = "[" + std::to_string(config.num_channels) + "," +
49+
std::to_string(config.channel_size) + "]";
50+
std::string storage_str = repr_str(storage_type, utils::kWidthPacked);
4551
std::string test_name =
46-
config.test_case_name + "_" + storage_str + "_" + dtype_str;
52+
make_test_label(prefix, in_dtype, out_dtype, shape_str, storage_str);
4753
test_case.set_name(test_name);
4854

4955
// Set the operator name for the test case

backends/vulkan/test/custom_ops/q4gsw_linear.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,21 @@ TestCase create_test_case_from_config(
5050
TestCase test_case;
5151

5252
// Create a descriptive name for the test case
53-
std::string storage_str =
54-
(storage_type == utils::kTexture3D) ? "Texture3D" : "Buffer";
55-
std::string dtype_str = (input_dtype == vkapi::kFloat) ? "Float" : "Half";
56-
57-
std::string test_name =
58-
config.test_case_name + "_" + storage_str + "_" + dtype_str;
53+
bool is_perf =
54+
!(config.M < kRefDimSizeLimit && config.K < kRefDimSizeLimit &&
55+
config.N < kRefDimSizeLimit);
56+
std::string prefix = is_perf ? "PERF" : "ACCU";
57+
std::string dtype_str = dtype_short(input_dtype);
58+
std::string shape_str = "[" + std::to_string(config.M) + "," +
59+
std::to_string(config.K) + "]x[" + std::to_string(config.N) + "," +
60+
std::to_string(config.K) + "] g" + std::to_string(config.group_size);
61+
std::string storage_str = repr_str(storage_type, utils::kWidthPacked);
62+
std::string suffix = "[" + config.op_name + "]";
63+
if (!config.has_bias) {
64+
suffix += " no_bias";
65+
}
66+
std::string test_name = make_test_label(
67+
prefix, dtype_str, dtype_str, shape_str, storage_str, suffix);
5968
test_case.set_name(test_name);
6069

6170
// Set the operator name for the test case

backends/vulkan/test/custom_ops/q8csw_conv2d.cpp

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,27 @@ TestCase create_test_case_from_config(
2727
TestCase test_case;
2828

2929
// Create a descriptive name for the test case
30-
std::string storage_str =
31-
(storage_type == utils::kTexture3D) ? "Texture3D" : "Buffer";
32-
std::string dtype_str = (input_dtype == vkapi::kFloat) ? "Float" : "Half";
33-
34-
std::string test_name =
35-
config.test_case_name + "_" + storage_str + "_" + dtype_str;
30+
bool is_perf = config.channels.out > kRefDimSizeLimit ||
31+
config.channels.in > kRefDimSizeLimit ||
32+
config.input_size.h > kRefDimSizeLimit ||
33+
config.input_size.w > kRefDimSizeLimit;
34+
std::string prefix = is_perf ? "PERF" : "ACCU";
35+
std::string dtype_str = dtype_short(input_dtype);
36+
std::string in_shape = "[1," + std::to_string(config.channels.in) + "," +
37+
std::to_string(config.input_size.h) + "," +
38+
std::to_string(config.input_size.w) + "]";
39+
std::string weight_shape = "[" + std::to_string(config.channels.out) + "," +
40+
std::to_string(config.channels.in / config.groups) + "," +
41+
std::to_string(config.kernel.h) + "," + std::to_string(config.kernel.w) +
42+
"]";
43+
std::string shape_str = in_shape + "x" + weight_shape + " s" +
44+
std::to_string(config.stride.h) + " p" +
45+
std::to_string(config.padding.h) + " d" +
46+
std::to_string(config.dilation.h) + " g" + std::to_string(config.groups);
47+
std::string storage_str = repr_str(storage_type, utils::kChannelsPacked);
48+
std::string suffix = "[" + config.op_name + "]";
49+
std::string test_name = make_test_label(
50+
prefix, dtype_str, dtype_str, shape_str, storage_str, suffix);
3651
test_case.set_name(test_name);
3752

3853
// Set the operator name for the test case

backends/vulkan/test/custom_ops/q8csw_linear.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,24 @@ TestCase create_test_case_from_config(
3636
TestCase test_case;
3737

3838
// Create a descriptive name for the test case
39-
std::string storage_str =
40-
(storage_type == utils::kTexture3D) ? "Texture3D" : "Buffer";
41-
std::string dtype_str = (input_dtype == vkapi::kFloat) ? "Float" : "Half";
42-
43-
std::string test_name =
44-
config.test_case_name + "_" + storage_str + "_" + dtype_str;
39+
bool is_perf =
40+
!(config.M < kRefDimSizeLimit && config.K < kRefDimSizeLimit &&
41+
config.N < kRefDimSizeLimit);
42+
std::string prefix = is_perf ? "PERF" : "ACCU";
43+
std::string dtype_str = dtype_short(input_dtype);
44+
std::string shape_str = "[" + std::to_string(config.M) + "," +
45+
std::to_string(config.K) + "]x[" + std::to_string(config.N) + "," +
46+
std::to_string(config.K) + "]";
47+
utils::GPUMemoryLayout layout = (storage_type == utils::kTexture3D)
48+
? utils::kChannelsPacked
49+
: utils::kWidthPacked;
50+
std::string storage_str = repr_str(storage_type, layout);
51+
std::string suffix = "[" + config.op_name + "]";
52+
if (!config.has_bias) {
53+
suffix += " no_bias";
54+
}
55+
std::string test_name = make_test_label(
56+
prefix, dtype_str, dtype_str, shape_str, storage_str, suffix);
4557
test_case.set_name(test_name);
4658

4759
// Set the operator name for the test case

backends/vulkan/test/custom_ops/test_conv1d_dw.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,22 @@ static TestCase create_conv1d_dw_test_case(
3737
bool is_perf = config.C > kRefDimSizeLimit || config.L > kRefDimSizeLimit;
3838

3939
std::string prefix = is_perf ? "PERF" : "ACCU";
40-
std::string storage_str = storage_type_abbrev(storage_type);
41-
std::string dtype_str = (dtype == vkapi::kHalf) ? "f16" : "f32";
40+
std::string storage_str = storage_type_abbrev(storage_type) + "(HP)";
41+
std::string dtype_str = dtype_short(dtype);
4242
std::string bias_str = config.has_bias ? "+bias" : "";
4343

4444
int64_t L_out =
4545
(config.L + 2 * config.padding - config.dilation * (config.K - 1) - 1) /
4646
config.stride +
4747
1;
4848

49-
std::string name = prefix + " conv1d_dw" + bias_str + " [" +
50-
std::to_string(config.N) + "," + std::to_string(config.C) + "," +
51-
std::to_string(config.L) + "] K=" + std::to_string(config.K) +
52-
" s=" + std::to_string(config.stride) +
53-
" p=" + std::to_string(config.padding) +
54-
" d=" + std::to_string(config.dilation) + " " + storage_str + "(HP) " +
55-
dtype_str;
49+
std::string shape = "[" + std::to_string(config.N) + "," +
50+
std::to_string(config.C) + "," + std::to_string(config.L) + "] k" +
51+
std::to_string(config.K) + " s" + std::to_string(config.stride) + " p" +
52+
std::to_string(config.padding) + " d" + std::to_string(config.dilation);
53+
54+
std::string name = make_test_label(
55+
prefix, dtype_str, dtype_str, shape, storage_str, bias_str);
5656

5757
test_case.set_name(name);
5858
test_case.set_operator_name("test_etvk.test_conv1d_dw.default");

backends/vulkan/test/custom_ops/test_conv1d_pw.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,17 @@ static TestCase create_conv1d_pw_test_case(
3535
config.C_out > kRefDimSizeLimit || config.L > kRefDimSizeLimit;
3636

3737
std::string prefix = is_perf ? "PERF" : "ACCU";
38-
std::string storage_str = storage_type_abbrev(storage_type);
39-
std::string dtype_str = (dtype == vkapi::kHalf) ? "f16" : "f32";
38+
std::string storage_str = storage_type_abbrev(storage_type) + "(HP)";
39+
std::string dtype_str = dtype_short(dtype);
4040

4141
std::string bias_str = config.has_bias ? "+bias" : "";
4242

43-
std::string name = prefix + " conv1d_pw" + bias_str + " [" +
44-
std::to_string(config.N) + "," + std::to_string(config.C_in) + "," +
45-
std::to_string(config.L) + "]x[" + std::to_string(config.C_out) + "," +
46-
std::to_string(config.C_in) + ",1] " + storage_str + "(HP) " + dtype_str;
43+
std::string shape = "[" + std::to_string(config.N) + "," +
44+
std::to_string(config.C_in) + "," + std::to_string(config.L) + "]x[" +
45+
std::to_string(config.C_out) + "," + std::to_string(config.C_in) + ",1]";
46+
47+
std::string name = make_test_label(
48+
prefix, dtype_str, dtype_str, shape, storage_str, bias_str);
4749

4850
test_case.set_name(name);
4951
test_case.set_operator_name("test_etvk.test_conv1d_pw.default");

backends/vulkan/test/custom_ops/test_conv2d_dw.cpp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ static TestCase create_conv2d_dw_test_case(
5959
config.dims.H > kRefDimSizeLimit || config.dims.W > kRefDimSizeLimit;
6060

6161
std::string prefix = is_perf ? "PERF" : "ACCU";
62-
std::string storage_str = storage_type_abbrev(storage_type);
63-
std::string layout_str = layout_abbrev(memory_layout);
64-
std::string dtype_str = (dtype == vkapi::kHalf) ? "f16" : "f32";
62+
std::string storage_str = repr_str(storage_type, memory_layout);
63+
std::string dtype_str = dtype_short(dtype);
6564
std::string bias_str = config.has_bias ? "+bias" : "";
6665

6766
int64_t H_out = calc_out_size(
@@ -76,22 +75,27 @@ static TestCase create_conv2d_dw_test_case(
7675
config.stride.w,
7776
config.padding.w,
7877
config.dilation.w);
78+
(void)H_out;
79+
(void)W_out;
7980

81+
// groups for depthwise conv2d == number of input channels
8082
std::string shape = "[" + std::to_string(config.dims.N) + "," +
8183
std::to_string(config.dims.C) + "," + std::to_string(config.dims.H) +
8284
"," + std::to_string(config.dims.W) + "] k" +
83-
std::to_string(config.kernel.h) + "x" + std::to_string(config.kernel.w) +
84-
" s" + std::to_string(config.stride.h) + " p" +
85-
std::to_string(config.padding.h) + " d" +
86-
std::to_string(config.dilation.h) + "->[" +
87-
std::to_string(config.dims.N) + "," + std::to_string(config.dims.C) +
88-
"," + std::to_string(H_out) + "," + std::to_string(W_out) + "]";
89-
90-
std::string selector_str =
91-
impl_selector.empty() ? "" : " [" + impl_selector + "]";
92-
93-
std::string name = prefix + " conv2d_dw" + bias_str + " " + shape + " " +
94-
storage_str + "(" + layout_str + ") " + dtype_str + selector_str;
85+
std::to_string(config.kernel.h) + " s" + std::to_string(config.stride.h) +
86+
" p" + std::to_string(config.padding.h) + " d" +
87+
std::to_string(config.dilation.h) + " g" + std::to_string(config.dims.C);
88+
89+
std::string suffix = bias_str;
90+
if (!impl_selector.empty()) {
91+
if (!suffix.empty()) {
92+
suffix += " ";
93+
}
94+
suffix += "[" + impl_selector + "]";
95+
}
96+
97+
std::string name =
98+
make_test_label(prefix, dtype_str, dtype_str, shape, storage_str, suffix);
9599

96100
test_case.set_name(name);
97101
test_case.set_operator_name("test_etvk.test_conv2d_dw.default");

backends/vulkan/test/custom_ops/test_conv2d_pw.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,18 @@ static TestCase create_conv2d_pw_test_case(
3838
config.W > kRefDimSizeLimit;
3939

4040
std::string prefix = is_perf ? "PERF" : "ACCU";
41-
std::string storage_str = storage_type_abbrev(storage_type);
42-
std::string layout_str = layout_abbrev(memory_layout);
43-
std::string dtype_str = (dtype == vkapi::kHalf) ? "f16" : "f32";
41+
std::string storage_str = repr_str(storage_type, memory_layout);
42+
std::string dtype_str = dtype_short(dtype);
4443
std::string bias_str = config.has_bias ? "+bias" : "";
4544

45+
// Pointwise conv2d: kernel 1x1, stride 1, pad 0, dilation 1, groups 1
4646
std::string shape = "[" + std::to_string(config.N) + "," +
4747
std::to_string(config.C_in) + "," + std::to_string(config.H) + "," +
48-
std::to_string(config.W) + "]->[" + std::to_string(config.N) + "," +
49-
std::to_string(config.C_out) + "," + std::to_string(config.H) + "," +
50-
std::to_string(config.W) + "]";
48+
std::to_string(config.W) + "]x[" + std::to_string(config.C_out) + "," +
49+
std::to_string(config.C_in) + ",1,1] s1 p0 d1 g1";
5150

52-
std::string name = prefix + " conv2d_pw" + bias_str + " " + shape + " " +
53-
storage_str + "(" + layout_str + ") " + dtype_str;
51+
std::string name = make_test_label(
52+
prefix, dtype_str, dtype_str, shape, storage_str, bias_str);
5453

5554
test_case.set_name(name);
5655
test_case.set_operator_name("test_etvk.test_conv2d_pw.default");

backends/vulkan/test/custom_ops/test_embedding_q4gsw.cpp

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,35 @@ void embedding_4bit_reference(TestCase& tc) {
115115

116116
TestCase create_test_case(const EmbeddingConfig& config) {
117117
TestCase test_case;
118-
test_case.set_name(config.test_case_name);
118+
119+
// Compute the output shape for label: indices_shape + [embed_dim]
120+
std::vector<int64_t> output_shape_for_label = config.indices_shape;
121+
output_shape_for_label.push_back(config.embed_dim);
122+
123+
// Treat any case that uses the large llama vocab/embed sizes as PERF.
124+
// Otherwise default to ACCU (no PERF distinction is exercised by this op).
125+
bool is_perf = config.vocab_size > 1024 || config.embed_dim > 1024;
126+
std::string prefix = is_perf ? "PERF" : "ACCU";
127+
128+
std::string in_dtype = dtype_short(vkapi::kInt); // indices are i32
129+
std::string out_dtype = dtype_short(config.dtype);
130+
131+
std::string storage_str = repr_str(config.storage_type, utils::kWidthPacked);
132+
133+
std::string shape_str = shape_bracket(config.indices_shape) + "x[" +
134+
std::to_string(config.vocab_size) + "," +
135+
std::to_string(config.embed_dim) + "]";
136+
shape_str += " g" + std::to_string(config.group_size);
137+
if (config.is_linear_weight) {
138+
shape_str += " lw";
139+
}
140+
std::string suffix;
141+
if (config.scales_dtype == vkapi::kFloat) {
142+
suffix = "[f32_scales]";
143+
}
144+
std::string name = make_test_label(
145+
prefix, in_dtype, out_dtype, shape_str, storage_str, suffix);
146+
test_case.set_name(name);
119147
test_case.set_operator_name("et_vk.embedding_q4gsw.default");
120148
test_case.set_shader_filter({});
121149

0 commit comments

Comments
 (0)