MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / FoldTranspose

Function FoldTranspose

source/opt/const_folding_rules.cpp:404–423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

402}
403
404const analysis::Constant* FoldTranspose(
405 IRContext* context, Instruction* inst,
406 const std::vector<const analysis::Constant*>& constants) {
407 assert(inst->opcode() == spv::Op::OpTranspose);
408
409 analysis::TypeManager* type_mgr = context->get_type_mgr();
410 if (!inst->IsFloatingPointFoldingAllowed()) {
411 if (HasFloatingPoint(type_mgr->GetType(inst->type_id()))) {
412 return nullptr;
413 }
414 }
415
416 const analysis::Constant* matrix = constants[0];
417 if (matrix == nullptr) {
418 return nullptr;
419 }
420
421 auto* result_type = type_mgr->GetType(inst->type_id());
422 return TransposeMatrix(matrix, result_type->AsMatrix(), context);
423}
424
425ConstantFoldingRule FoldVectorTimesMatrix() {
426 return [](IRContext* context, Instruction* inst,

Callers

nothing calls this directly

Calls 8

TransposeMatrixFunction · 0.85
get_type_mgrMethod · 0.80
AsMatrixMethod · 0.80
HasFloatingPointFunction · 0.70
opcodeMethod · 0.45
GetTypeMethod · 0.45
type_idMethod · 0.45

Tested by

no test coverage detected