Skip to content

Commit

Permalink
Fix logical or/and usage for MSVC compilation.
Browse files Browse the repository at this point in the history
The `or`/`and` alternate spellings are not supported on all compilers without additinoal flags (https://learn.microsoft.com/en-us/cpp/cpp/logical-or-operator-pipe-pipe?view=msvc-170#operator-keyword-for-).
  • Loading branch information
ScottTodd committed Jan 27, 2025
1 parent 4f0b79c commit d94e357
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/Conversion/TorchOnnxToTorch/DefaultDomainGtoP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2346,7 +2346,7 @@ void mlir::torch::onnx_c::populateDefaultDomainGtoP(
ArrayRef<int64_t> inputShape = inputTensorType.getSizes();
unsigned inputRank = inputShape.size();
// only handle 2D, 3D and 5D pooling cases
if (inputRank > 5 or inputRank < 3) {
if (inputRank > 5 || inputRank < 3) {
return failure();
}
if (!resultType || !resultType.hasSizes()) {
Expand Down Expand Up @@ -2454,7 +2454,7 @@ void mlir::torch::onnx_c::populateDefaultDomainGtoP(
"Unimplemented: unranked tensor");
unsigned rank = *maybeRank;
// only 1D, 2D and 3D LpPool is supported.
if (rank > 5 or rank < 3) {
if (rank > 5 || rank < 3) {
return failure();
}

Expand Down
8 changes: 4 additions & 4 deletions lib/Dialect/Torch/Transforms/DecomposeComplexOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9780,16 +9780,16 @@ class DecomposeAtenNllLossForwardOp
auto targetSizes = targetType.getSizes();
int64_t selfRank = selfSizes.size();
int64_t targetRank = targetSizes.size();
if (selfRank <= 0 or selfRank > 2) {
if (selfRank <= 0 || selfRank > 2) {
return rewriter.notifyMatchFailure(op, "input tensor should be 1D or 2D");
}
if (targetRank > 1) {
return rewriter.notifyMatchFailure(op,
"target tensor shoule be 0D or 1D!");
}

if (selfRank != 1 or targetRank != 0) {
if (!(selfSizes[0] == kUnknownSize and targetSizes[0] == kUnknownSize) and
if (selfRank != 1 || targetRank != 0) {
if (!(selfSizes[0] == kUnknownSize && targetSizes[0] == kUnknownSize) &&
selfSizes[0] != targetSizes[0]) {
return rewriter.notifyMatchFailure(
op,
Expand Down Expand Up @@ -9907,7 +9907,7 @@ class DecomposeAtenNllLossForwardOp
zeroTensor);

Value totalWeight;
if (reduction == 0 and selfRank > 1) {
if (reduction == 0 && selfRank > 1) {
auto zeroFloat =
rewriter.create<ConstantFloatOp>(loc, rewriter.getF64FloatAttr(0.0));
Value twSize = rewriter.create<PrimListConstructOp>(
Expand Down

0 comments on commit d94e357

Please sign in to comment.