Skip to content

Commit 1c9b704

Browse files
tlongeriGoogle-ML-Automation
authored andcommitted
[Mosaic] Add hasVectorOperandsOrResults utility function
PiperOrigin-RevId: 820222017
1 parent 00d707e commit 1c9b704

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

jaxlib/mosaic/dialect/tpu/util.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,4 +371,13 @@ SmallVector<Operation *> getNontrivialTransitiveUsers(Value v) {
371371
return users;
372372
}
373373

374+
bool hasVectorOperandsOrResults(Operation& op) {
375+
for (Value value : llvm::concat<Value>(op.getOperands(), op.getResults())) {
376+
if (isa<VectorType>(value.getType())) {
377+
return true;
378+
}
379+
}
380+
return false;
381+
}
382+
374383
} // namespace mlir::tpu

jaxlib/mosaic/dialect/tpu/util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ std::optional<int64_t> getIntConst(Value v);
299299
// results.
300300
SmallVector<Operation *> getNontrivialTransitiveUsers(Value v);
301301

302+
bool hasVectorOperandsOrResults(Operation& op);
303+
302304
// Return a mod b for a, b > 0, but adjusted to return b when a mod b == 0 such
303305
// that the result is strictly positive.
304306
template <typename U, typename V>

0 commit comments

Comments
 (0)