#pragma once #include "mlir/IR/Operation.h" #include "mlir/IR/Value.h" #include "llvm/ADT/STLFunctionalExtras.h" #include "llvm/ADT/StringRef.h" inline constexpr llvm::StringRef PimWeightAlwaysAttrName = "weightAlways"; namespace onnx_mlir { bool hasWeightAlways(mlir::Operation* op); /// Tags an op as producing a value that should stay materialized as a reusable /// weight across later PIM lowering/codegen stages. void markWeightAlways(mlir::Operation* op); bool isSpatialMvmVmmWeightUse(mlir::OpOperand& use); /// Returns true when a value flows only into Spatial weighted MVM/VMM operands, /// allowing later passes to preserve it as a dedicated weight-like object. bool hasOnlySpatialMvmVmmWeightUses(mlir::Value value); /// Visits weight operands consumed by Pim core ops/core batches so downstream /// passes can identify globals that must remain weight-backed. void walkPimMvmVmmWeightUses(mlir::Operation* root, llvm::function_ref callback); } // namespace onnx_mlir