Repository navigation
div_kernel: throw when dividing by integer zero - #32629
Baranowski wants to merge 2 commits into
Conversation
|
Much to my surprise, the additional check does not seem to cause noticeable slowdown. To be fair, the measurements are not stable in my dev environment between different runs (and thus I'm not posting them) but both timeit and ASV suggest that there is nothing outrageous happening (i.e., if there is a slowdown, it's no greater than about 5%). For the record, here is my ASV benchmark: class TimeDiv:
params = [100, 500, 1000, 2000, 3000]
def setup(self, n):
self.a = torch.rand(n, n).mul(10000).ceil().int()
self.b = torch.rand(n, n).mul(10000).ceil().int().add(1)
def time_div(self, n):
self.a.div(self.b)And timeit: a = None
b = None
if __name__ == "__main__":
for size in (100, 500, 1000, 2000, 3000):
a = torch.rand(size, size).mul(10000).ceil().int()
b = torch.rand(size, size).mul(10000).ceil().int().add(1)
a.div(b)
print("{size}x{size}: {duration}".format(
size=size,
duration=timeit.timeit("a.div(b)", setup="from __main__ import a, b", number=10000)
))As for the error handling, division by zero results in the following: |
💊 CircleCI build failures summary and remediationsAs of commit ff61297:
Detailed failure analysisOne may explore the probable reasons each build failed interactively on the Dr. CI website. 🕵️ 1 new failure recognized by patternsThe following build failures do not appear to be due to upstream breakage:
|
bda13c1 to
04772aa
Compare
andreaskoepf
left a comment
There was a problem hiding this comment.
Looks good to me (see my comment for test_torch.py).
ezyang
left a comment
There was a problem hiding this comment.
Need some testing changes.
|
@VitalyFedyunin or @ngimel could you help us check if there are any perf implications; if the benchmarking above seems sufficient? |
|
As per https://www.agner.org/optimize/instruction_tables.pdf conditional short jump is about 20-40 times faster than division op. So slow down seems to be insignificant and benchmarks are correct. |
|
I think we can give it go, but prefer to have second opinion CC @ngimel |
|
As for the CI failure, I cannot reproduce it and it doesn't seem related to my change, so I'm tempted to claim it spurious. |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@ezyang is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
1 similar comment
Summary: Fixes pytorch#327 Pull Request resolved: pytorch#32629 Differential Revision: D19595782 Pulled By: ezyang fbshipit-source-id: f5bbb298f150efe63a698e8a0b53a84871d16560
Summary: Fixes pytorch#327 Pull Request resolved: pytorch#32629 Differential Revision: D19595782 Pulled By: ezyang fbshipit-source-id: f5bbb298f150efe63a698e8a0b53a84871d16560
Fixes #327