mirror of
https://github.com/zebrajr/tensorflow.git
synced 2025-12-06 12:20:11 +01:00
Add helper functions for creating constant SymbolicExpr
Similarly to GetAffineConstantExpr, I'm introducing GetSymbolicConstantExpr/s to create constants of SymbolicExpr from a list of values. PiperOrigin-RevId: 826020777
This commit is contained in:
parent
fd71e8be05
commit
345a251037
17
third_party/xla/xla/hlo/analysis/symbolic_expr.h
vendored
17
third_party/xla/xla/hlo/analysis/symbolic_expr.h
vendored
|
|
@ -167,6 +167,23 @@ class SymbolicExprContext {
|
|||
mlir::MLIRContext* mlir_context_;
|
||||
};
|
||||
|
||||
// Free function to create a constant SymbolicExpr.
|
||||
inline SymbolicExpr GetSymbolicConstantExpr(int64_t constant,
|
||||
SymbolicExprContext* context) {
|
||||
return context->CreateConstant(constant);
|
||||
}
|
||||
|
||||
// Free function to create a vector of constant SymbolicExprs.
|
||||
inline llvm::SmallVector<SymbolicExpr> GetSymbolicConstantExprs(
|
||||
llvm::ArrayRef<int64_t> constants, SymbolicExprContext* context) {
|
||||
llvm::SmallVector<SymbolicExpr> exprs;
|
||||
exprs.reserve(constants.size());
|
||||
for (int64_t constant : constants) {
|
||||
exprs.push_back(GetSymbolicConstantExpr(constant, context));
|
||||
}
|
||||
return exprs;
|
||||
}
|
||||
|
||||
} // namespace xla
|
||||
|
||||
namespace llvm {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user