Skip to content

spirv-fuzz: Replace linear algebra instructions with its mathematical definition #3354

@andreperezmaselco

Description

@andreperezmaselco

Instructions such as OpVectorTimesMatrix, OpMatrixTimesVector, OpMatrixTimesMatrix, OpOuterProduct and OpDot can be replaced with its mathematical definition. For example, the OpDot instruction can divided into sub-instructions such as OpFMul and OpFAdd.

Reference shader:

%2 = OpTypeFloat 32
%3 = OpTypeVector %2 2
%4 = OpConstant %2 1
%5 = OpConstant %2 2
%6 = OpConstant %2 3
%7 = OpConstant %2 4
%8 = OpConstantComposite %3 %4 %5
%9 = OpConstantComposite %3 %6 %7
%dot_product = OpDot %2 %8 %9

Variant shader:

%2 = OpTypeFloat 32
%3 = OpTypeVector %2 2
%4 = OpConstant %2 1
%5 = OpConstant %2 2
%6 = OpConstant %2 3
%7 = OpConstant %2 4
%8 = OpConstantComposite %3 %4 %5
%9 = OpConstantComposite %3 %6 %7
%10 = OpFMul %2 %4 %6
%11 = OpFMul %2 %5 %7
%dot_product = OpFAdd %2 %10 %11

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions