#ifndef SOURCE_FUZZ_TRANSFORMATION_REPLACE_LINEAR_ALGEBRA_INSTRUCTION_H_
#define SOURCE_FUZZ_TRANSFORMATION_REPLACE_LINEAR_ALGEBRA_INSTRUCTION_H_
#include "source/fuzz/protobufs/spirvfuzz_protobufs.h"
#include "source/fuzz/transformation.h"
#include "source/fuzz/transformation_context.h"
#include "source/opt/ir_context.h"
namespace spvtools {
namespace fuzz {
class TransformationReplaceLinearAlgebraInstruction : public Transformation {
public:
explicit TransformationReplaceLinearAlgebraInstruction(
protobufs::TransformationReplaceLinearAlgebraInstruction message);
TransformationReplaceLinearAlgebraInstruction(
const std::vector<uint32_t>& fresh_ids,
const protobufs::InstructionDescriptor& instruction_descriptor);
bool IsApplicable(
opt::IRContext* ir_context,
const TransformationContext& transformation_context) const override;
void Apply(opt::IRContext* ir_context,
TransformationContext* transformation_context) const override;
std::unordered_set<uint32_t> GetFreshIds() const override;
protobufs::Transformation ToMessage() const override;
static uint32_t GetRequiredFreshIdCount(opt::IRContext* ir_context,
opt::Instruction* instruction);
private:
protobufs::TransformationReplaceLinearAlgebraInstruction message_;
void ReplaceOpTranspose(opt::IRContext* ir_context,
opt::Instruction* instruction) const;
void ReplaceOpVectorTimesScalar(opt::IRContext* ir_context,
opt::Instruction* instruction) const;
void ReplaceOpMatrixTimesScalar(opt::IRContext* ir_context,
opt::Instruction* instruction) const;
void ReplaceOpVectorTimesMatrix(opt::IRContext* ir_context,
opt::Instruction* instruction) const;
void ReplaceOpMatrixTimesVector(opt::IRContext* ir_context,
opt::Instruction* instruction) const;
void ReplaceOpMatrixTimesMatrix(opt::IRContext* ir_context,
opt::Instruction* instruction) const;
void ReplaceOpOuterProduct(opt::IRContext* ir_context,
opt::Instruction* instruction) const;
void ReplaceOpDot(opt::IRContext* ir_context,
opt::Instruction* instruction) const;
};
}
}
#endif