Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TensorExpr] Fix lowering for aten::div. #48329

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions test/test_jit_fuser_te.py
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,7 @@ def apply(fn):
torch.max,
lambda x, y: torch.lerp(x, y, 0.5),
torch.atan2,
torch.div,

# FIXME: comparison ops yield different results when fused
# torch.eq,
Expand All @@ -1316,12 +1317,13 @@ def apply(fn):
# torch.gt,
# torch.lt,

# TODO: test operators exercising division too
# TODO: fails on CPU backend with int8
# torch.fmod,
# torch.remainder,

# FIXME: segfaults on CPU backend
# operator.__rshift__,
# operator.__lshift__,
# torch.div,
]
devices = self.devices
for dtype, op, device in product(dtypes, binary_ops, devices):
Expand Down Expand Up @@ -1358,7 +1360,7 @@ def apply_with_scalar(fn, scalar):
torch.float16,
torch.float32,
torch.float64,
# torch.bool intentionally not included
torch.bool
]
binary_ops = [
operator.__and__,
Expand All @@ -1369,15 +1371,13 @@ def apply_with_scalar(fn, scalar):
torch.mul,
torch.eq,
torch.ne,
torch.div,

# FIXME: fails with dtype=uint8, scalar=-1
# torch.ge,
# torch.lt,
# torch.gt,

# FIXME: fails with integer dtype and scalar={3,0}
# torch.div,

# FIXME: segfaults on CPU backend
# operator.__rshift__,
# operator.__lshift__,
Expand Down
2 changes: 1 addition & 1 deletion torch/csrc/jit/tensorexpr/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ Tensor* TensorExprKernel::computeValue(const torch::jit::Value* v) {
case aten::div: {
return computeTwoOperand(
"aten_div", v, [](const ExprHandle& lhs, const ExprHandle& rhs) {
return boolToInteger(lhs) / boolToInteger(rhs);
return promoteIntegerToFloat(lhs) / promoteIntegerToFloat(rhs);
});
} break;

Expand Down