@@ -71,11 +71,14 @@ std::string GenerateModule(const std::string& body) {
71
71
%uint_var_1 = OpVariable %uint_ptr_Private Private %uint_1
72
72
%var_uint_arr4_1_1_1_1 = OpVariable %uint_arr4_ptr_Private Private %uint_arr4_1_1_1_1
73
73
%tensor_uint_4 = OpTypeTensorARM %uint %uint_4
74
+ %tensor_uint_spec = OpTypeTensorARM %uint %uint_0_spec
74
75
%tensor_float = OpTypeTensorARM %float
75
76
%tensor_uint_4_ptr_UniformConstant = OpTypePointer UniformConstant %tensor_uint_4
76
77
%tensor_var = OpVariable %tensor_uint_4_ptr_UniformConstant UniformConstant
77
78
%tensor_float_ptr_UniformConstant = OpTypePointer UniformConstant %tensor_float
78
79
%tensor_var_float_unranked = OpVariable %tensor_float_ptr_UniformConstant UniformConstant
80
+ %tensor_uint_spec_ptr_UniformConstant = OpTypePointer UniformConstant %tensor_uint_spec
81
+ %tensor_var_spec_rank = OpVariable %tensor_uint_spec_ptr_UniformConstant UniformConstant
79
82
)" ;
80
83
const std::string footer = R"(
81
84
%fnep = OpFunction %void None %fnty
@@ -135,7 +138,8 @@ TEST_F(ValidateTensor, ValidTypeElementTypeAndRank) {
135
138
136
139
TEST_F (ValidateTensor, ValidTypeElementTypeAndRankUsingSpecConstant) {
137
140
const std::string src = R"(
138
- %test_type = OpTypeTensorARM %uint %uint_0_spec
141
+ %rank_spec = OpSpecConstant %uint 0
142
+ %test_type = OpTypeTensorARM %uint %rank_spec
139
143
)" ;
140
144
std::string spvasm = GenerateModule (src);
141
145
CompileSuccessfully (spvasm, SPVENV);
@@ -563,6 +567,20 @@ TEST_F(ValidateTensor, ValidTensorReadArray) {
563
567
EXPECT_EQ (SPV_SUCCESS, ValidateInstructions (SPVENV));
564
568
}
565
569
570
+ TEST_F (ValidateTensor, ValidTensorReadSpecConstantRank) {
571
+ const std::string src = R"(
572
+ %fn = OpFunction %void None %fnty
573
+ %label1 = OpLabel
574
+ %tensor = OpLoad %tensor_uint_spec %tensor_var_spec_rank
575
+ %val = OpTensorReadARM %uint %tensor %uint_arr4_1_1_1_1
576
+ OpReturn
577
+ OpFunctionEnd
578
+ )" ;
579
+ std::string spvasm = GenerateModule (src);
580
+ CompileSuccessfully (spvasm, SPVENV);
581
+ EXPECT_EQ (SPV_SUCCESS, ValidateInstructions (SPVENV));
582
+ }
583
+
566
584
TEST_F (ValidateTensor, InvalidTensorReadResultTypeVoid) {
567
585
const std::string src = R"(
568
586
%fn = OpFunction %void None %fnty
@@ -840,6 +858,20 @@ TEST_F(ValidateTensor, ValidTensorWriteArray) {
840
858
EXPECT_EQ (SPV_SUCCESS, ValidateInstructions (SPVENV));
841
859
}
842
860
861
+ TEST_F (ValidateTensor, ValidTensorWriteSpecConstantRank) {
862
+ const std::string src = R"(
863
+ %fn = OpFunction %void None %fnty
864
+ %label1 = OpLabel
865
+ %tensor = OpLoad %tensor_uint_spec %tensor_var_spec_rank
866
+ OpTensorWriteARM %tensor %uint_arr4_1_1_1_1 %uint_1
867
+ OpReturn
868
+ OpFunctionEnd
869
+ )" ;
870
+ std::string spvasm = GenerateModule (src);
871
+ CompileSuccessfully (spvasm, SPVENV);
872
+ EXPECT_EQ (SPV_SUCCESS, ValidateInstructions (SPVENV));
873
+ }
874
+
843
875
TEST_F (ValidateTensor, InvalidTensorWriteObjectNotScalarOrArrayOfScalar) {
844
876
const std::string src = R"(
845
877
%fn = OpFunction %void None %fnty
@@ -1069,12 +1101,9 @@ TEST_F(ValidateTensor, ValidTensorQuerySize) {
1069
1101
1070
1102
TEST_F (ValidateTensor, ValidTensorQuerySizeSpecConstant) {
1071
1103
const std::string src = R"(
1072
- %tensor_uint_4_spec = OpTypeTensorARM %uint %uint_0_spec
1073
- %tensor_uint_4_spec_ptr_UniformConstant = OpTypePointer UniformConstant %tensor_uint_4_spec
1074
- %tensor_var_spec = OpVariable %tensor_uint_4_spec_ptr_UniformConstant UniformConstant
1075
1104
%fn = OpFunction %void None %fnty
1076
1105
%label1 = OpLabel
1077
- %tensor = OpLoad %tensor_uint_4_spec %tensor_var_spec
1106
+ %tensor = OpLoad %tensor_uint_spec %tensor_var_spec_rank
1078
1107
%size = OpTensorQuerySizeARM %uint %tensor %uint_0_spec
1079
1108
OpReturn
1080
1109
OpFunctionEnd
0 commit comments