Skip to content

Commit

Permalink
Add assert to ensure the divisor is not 0 (#25960)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch/pytorch#25960

Pull Request resolved: pytorch#124

Reviewed By: dskhudia

Differential Revision: D17292372

fbshipit-source-id: 71a72f87b99c65b3b956bd8361694b1de05fc333
  • Loading branch information
jianyuh authored and facebook-github-bot committed Sep 11, 2019
1 parent 9f096ab commit 685b185
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/FbgemmI8DepthwiseAvx2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2538,6 +2538,14 @@ void depthwise_3x3_pad_1(
bool fuse_relu,
int thread_id,
int num_threads) {
if (stride_h == 0 || stride_w == 0 || num_threads == 0) {
assert(0 && "stride_h == 0 || stride_w == 0 || num_threads == 0");
return;
}
if (N == 0) {
// In C2, batch size 0 is allowed, so we should just early return.
return;
}
if (fuse_relu) {
if (7 == H && 7 == W && 1 == stride_h && 1 == stride_w) {
depthwise_3x3_pad_1_<true /* FUSE_RELU */>(
Expand Down Expand Up @@ -2958,6 +2966,16 @@ void depthwise_3x3x3_pad_1(
bool fuse_relu,
int thread_id,
int num_threads) {
if (stride_t == 0 || stride_h == 0 || stride_w == 0 || num_threads == 0) {
assert(
0 &&
"stride_t == 0 || stride_h == 0 || stride_w == 0 || num_threads == 0");
return;
}
if (N == 0) {
// In C2, batch size 0 is allowed, so we should just early return.
return;
}
if (fuse_relu) {
depthwise_3x3x3_pad_1_<true /*FUSE_RELU*/>(
N,
Expand Down Expand Up @@ -3158,6 +3176,14 @@ void depthwise_3x3_per_channel_quantization_pad_1(
bool fuse_relu,
int thread_id,
int num_threads) {
if (stride_h == 0 || stride_w == 0 || num_threads == 0) {
assert(0 && "stride_h == 0 || stride_w == 0 || num_threads == 0");
return;
}
if (N == 0) {
// In C2, batch size 0 is allowed, so we should just early return.
return;
}
if (fuse_relu) {
if (7 == H && 7 == W && 1 == stride_h && 1 == stride_w) {
depthwise_3x3_per_channel_quantization_pad_1_<true /* FUSE_RELU */>(
Expand Down Expand Up @@ -3524,6 +3550,16 @@ void depthwise_3x3x3_per_channel_quantization_pad_1(
bool fuse_relu,
int thread_id,
int num_threads) {
if (stride_t == 0 || stride_h == 0 || stride_w == 0 || num_threads == 0) {
assert(
0 &&
"stride_t == 0 || stride_h == 0 || stride_w == 0 || num_threads == 0");
return;
}
if (N == 0) {
// In C2, batch size 0 is allowed, so we should just early return.
return;
}
if (fuse_relu) {
depthwise_3x3x3_per_channel_quantization_pad_1_<true /* FUSE_RELU */>(
N,
Expand Down

0 comments on commit 685b185

Please sign in to comment.