Skip to content

Commit eac930c

Browse files
authored
Add support for SPV_ARM_tensors (KhronosGroup#6134)
* Add support for SPV_ARM_tensors - Assembler/disassembler - Validator Signed-off-by: Kevin Petit <[email protected]> Change-Id: I87f20fccbca848dae96304f52873cdba80dec5ae * Address review comments * Update DEPS to pick up headers * format fixes * update other build systems * use alternative syntax for regexes * format fixes * use RE2 for regular expression matching * add re2 dep to Bazel Also remove stray debug trace. * remove re2 dep and weaken regular expressions for compatibility * further tweak regular expressions --------- Signed-off-by: Kevin Petit <[email protected]>
1 parent 11df9e8 commit eac930c

22 files changed

+1792
-9
lines changed

Android.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ SPVTOOLS_SRC_FILES := \
7575
source/val/validate_ray_tracing_reorder.cpp \
7676
source/val/validate_scopes.cpp \
7777
source/val/validate_small_type_uses.cpp \
78+
source/val/validate_tensor.cpp \
7879
source/val/validate_tensor_layout.cpp \
7980
source/val/validate_type.cpp\
8081
source/val/validate_invalid_type.cpp

BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ static_library("spvtools_val") {
369369
"source/val/validate_scopes.cpp",
370370
"source/val/validate_scopes.h",
371371
"source/val/validate_small_type_uses.cpp",
372+
"source/val/validate_tensor.cpp",
372373
"source/val/validate_tensor_layout.cpp",
373374
"source/val/validate_type.cpp",
374375
"source/val/validate_invalid_type.cpp",

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ vars = {
1414

1515
're2_revision': 'c84a140c93352cdabbfb547c531be34515b12228',
1616

17-
'spirv_headers_revision': '6d0784e9f1ab92c17eeea94821b2465c14a52be9',
17+
'spirv_headers_revision': 'c9aad99f9276817f18f72a4696239237c83cb775',
1818
}
1919

2020
deps = {

include/spirv-tools/libspirv.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,10 @@ typedef enum spv_operand_type_t {
339339
SPV_OPERAND_TYPE_SHDEBUG100_DEBUG_OPERATION,
340340
SPV_OPERAND_TYPE_SHDEBUG100_DEBUG_TYPE_QUALIFIER,
341341

342+
// SPV_ARM_tensors
343+
SPV_OPERAND_TYPE_TENSOR_OPERANDS,
344+
SPV_OPERAND_TYPE_OPTIONAL_TENSOR_OPERANDS,
345+
342346
// This is a sentinel value, and does not represent an operand type.
343347
// It should come last.
344348
SPV_OPERAND_TYPE_NUM_OPERAND_TYPES,

source/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ set(SPIRV_SOURCES
278278
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_scopes.cpp
279279
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_small_type_uses.cpp
280280
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_tensor_layout.cpp
281+
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_tensor.cpp
281282
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_type.cpp
282283
${CMAKE_CURRENT_SOURCE_DIR}/val/validate_invalid_type.cpp
283284
${CMAKE_CURRENT_SOURCE_DIR}/val/decoration.h

source/binary.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,8 @@ spv_result_t Parser::parseOperand(size_t inst_offset,
720720
case SPV_OPERAND_TYPE_IMAGE:
721721
case SPV_OPERAND_TYPE_OPTIONAL_IMAGE:
722722
case SPV_OPERAND_TYPE_MEMORY_ACCESS:
723+
case SPV_OPERAND_TYPE_TENSOR_OPERANDS:
724+
case SPV_OPERAND_TYPE_OPTIONAL_TENSOR_OPERANDS:
723725
case SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS:
724726
case SPV_OPERAND_TYPE_OPTIONAL_RAW_ACCESS_CHAIN_OPERANDS:
725727
case SPV_OPERAND_TYPE_SELECTION_CONTROL:
@@ -745,6 +747,8 @@ spv_result_t Parser::parseOperand(size_t inst_offset,
745747
if (type == SPV_OPERAND_TYPE_OPTIONAL_MATRIX_MULTIPLY_ACCUMULATE_OPERANDS)
746748
parsed_operand.type =
747749
SPV_OPERAND_TYPE_MATRIX_MULTIPLY_ACCUMULATE_OPERANDS;
750+
if (type == SPV_OPERAND_TYPE_OPTIONAL_TENSOR_OPERANDS)
751+
parsed_operand.type = SPV_OPERAND_TYPE_TENSOR_OPERANDS;
748752

749753
// Check validity of set mask bits. Also prepare for operands for those
750754
// masks if they have any. To get operand order correct, scan from

source/opcode.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ int32_t spvOpcodeGeneratesType(spv::Op op) {
262262
case spv::Op::OpTypeNodePayloadArrayAMDX:
263263
case spv::Op::OpTypeTensorLayoutNV:
264264
case spv::Op::OpTypeTensorViewNV:
265+
case spv::Op::OpTypeTensorARM:
265266
return true;
266267
default:
267268
// In particular, OpTypeForwardPointer does not generate a type,

source/operand.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ const char* spvOperandTypeStr(spv_operand_type_t type) {
139139
case SPV_OPERAND_TYPE_MATRIX_MULTIPLY_ACCUMULATE_OPERANDS:
140140
case SPV_OPERAND_TYPE_OPTIONAL_MATRIX_MULTIPLY_ACCUMULATE_OPERANDS:
141141
return "matrix multiply accumulate operands";
142+
case SPV_OPERAND_TYPE_TENSOR_OPERANDS:
143+
case SPV_OPERAND_TYPE_OPTIONAL_TENSOR_OPERANDS:
144+
return "tensor operands";
142145
case SPV_OPERAND_TYPE_INITIALIZATION_MODE_QUALIFIER:
143146
return "initialization mode qualifier";
144147
case SPV_OPERAND_TYPE_HOST_ACCESS_QUALIFIER:
@@ -366,6 +369,7 @@ bool spvOperandIsConcreteMask(spv_operand_type_t type) {
366369
case SPV_OPERAND_TYPE_RAW_ACCESS_CHAIN_OPERANDS:
367370
case SPV_OPERAND_TYPE_COOPERATIVE_MATRIX_REDUCE:
368371
case SPV_OPERAND_TYPE_TENSOR_ADDRESSING_OPERANDS:
372+
case SPV_OPERAND_TYPE_TENSOR_OPERANDS:
369373
return true;
370374
default:
371375
break;
@@ -389,6 +393,7 @@ bool spvOperandIsOptional(spv_operand_type_t type) {
389393
case SPV_OPERAND_TYPE_OPTIONAL_CIV:
390394
case SPV_OPERAND_TYPE_OPTIONAL_RAW_ACCESS_CHAIN_OPERANDS:
391395
case SPV_OPERAND_TYPE_OPTIONAL_FPENCODING:
396+
case SPV_OPERAND_TYPE_OPTIONAL_TENSOR_OPERANDS:
392397
return true;
393398
default:
394399
break;

source/text.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ spv_result_t spvTextEncodeOperand(const spvtools::AssemblyGrammar& grammar,
412412
case SPV_OPERAND_TYPE_LOOP_CONTROL:
413413
case SPV_OPERAND_TYPE_IMAGE:
414414
case SPV_OPERAND_TYPE_OPTIONAL_IMAGE:
415+
case SPV_OPERAND_TYPE_TENSOR_OPERANDS:
416+
case SPV_OPERAND_TYPE_OPTIONAL_TENSOR_OPERANDS:
415417
case SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS:
416418
case SPV_OPERAND_TYPE_OPTIONAL_RAW_ACCESS_CHAIN_OPERANDS:
417419
case SPV_OPERAND_TYPE_SELECTION_CONTROL:

source/val/validate.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ spv_result_t ValidateBinaryUsingContextAndValidationState(
367367
if (auto error = RayReorderNVPass(*vstate, &instruction)) return error;
368368
if (auto error = MeshShadingPass(*vstate, &instruction)) return error;
369369
if (auto error = TensorLayoutPass(*vstate, &instruction)) return error;
370+
if (auto error = TensorPass(*vstate, &instruction)) return error;
370371
if (auto error = InvalidTypePass(*vstate, &instruction)) return error;
371372
}
372373

0 commit comments

Comments
 (0)