Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit b6f2e0d

Browse files
authored
Merge pull request #187 from facebookresearch/dock-fixes
Bunch of doc fixes and use correct reduction operators
2 parents c572c93 + 25c34ea commit b6f2e0d

File tree

9 files changed

+15
-16
lines changed

9 files changed

+15
-16
lines changed

docs/source/framework/pytorch_integration/layers_database.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Average pooling
3333
.. code::
3434
3535
def avgpool(float(B, C, H, W) input) -> (output) {{
36-
output(b, c, h, w) += input(b, c, h * {sH} + kh, w * {sW} + kw) where kh in 0:{kH}, kw in 0:{kW}
36+
output(b, c, h, w) +=! input(b, c, h * {sH} + kh, w * {sW} + kw) / ({kH} * {kW}) where kh in 0:{kH}, kw in 0:{kW}
3737
}}
3838
3939
@@ -43,7 +43,7 @@ Max pooling
4343
.. code::
4444
4545
def maxpool(float(B, C, H, W) input) -> (output) {{
46-
output(b, c, h, w) max= input(b, c, h * {sH} + kh, w * {sW} + kw) where kh in 0:{kH}, kw in 0:{kW}
46+
output(b, c, h, w) max=! input(b, c, h * {sH} + kh, w * {sW} + kw) where kh in 0:{kH}, kw in 0:{kW}
4747
}}
4848
4949
Convolution layers

docs/source/framework/pytorch_integration/writing_layers.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ adopt whatever feels more convenient.
182182
import torch
183183
lang = """
184184
def avgpool(float(B, C, H, W) input) -> (output) {{
185-
output(b, c, h, w) += input(b, c, h * {sH} + kh, w * {sW} + kw) where kh in 0:{kH}, kw in 0:{kW}
185+
output(b, c, h, w) +=! input(b, c, h * {sH} + kh, w * {sW} + kw) / ({kH} * {kW}) where kh in 0:{kH}, kw in 0:{kW}
186186
}}
187187
"""
188188
avgpool = tc.define(lang, name="avgpool", constants={"sH":1, "sW":1, "kH":2, "kW":2})
@@ -205,7 +205,7 @@ adopt whatever feels more convenient.
205205
import re
206206
LANG="""
207207
def avgpool(float(B, C, H, W) input) -> (output) {
208-
output(b, c, h, w) += input(b, c, h * <sh> + kh, w * <sw> + kw) where kh in 0:<kH>, kw in 0:<kW>
208+
output(b, c, h, w) +=! input(b, c, h * <sh> + kh, w * <sw> + kw) / (<kH> * <kW>) where kh in 0:<kH>, kw in 0:<kW>
209209
}
210210
"""
211211
sH, sW, kH, kW = 1, 1, 2, 2

tensor_comprehensions/library/layers.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@
6161
- name: avgpool
6262
lang: |
6363
def avgpool(float(B, C, H, W) input) -> (output) {{
64-
output(b, c, h, w) += input(b, c, h * {sH} + kh, w * {sW} + kw) where kh in 0:{kH}, kw in 0:{kW}
64+
output(b, c, h, w) +=! input(b, c, h * {sH} + kh, w * {sW} + kw) / ({kH} * {kW}) where kh in 0:{kH}, kw in 0:{kW}
6565
}}
6666
6767
- name: maxpool
6868
lang: |
6969
def maxpool(float(B, C, H, W) input) -> (output) {{
70-
output(b, c, h, w) max= input(b, c, h * {sH} + kh, w * {sW} + kw) where kh in 0:{kH}, kw in 0:{kW}
70+
output(b, c, h, w) max=! input(b, c, h * {sH} + kh, w * {sW} + kw) where kh in 0:{kH}, kw in 0:{kW}
7171
}}
7272
7373
- name: scale

tensor_comprehensions/tc_unit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def __call__(self, *inputs, **kwargs):
397397
398398
* :attr:`conv`: if kernel resembles a convolution operation
399399
400-
* :attr:`group_conv`: if kernel resembles a convolution operation
400+
* :attr:`group_conv`: if kernel resembles a group convolution operation
401401
402402
* :attr:`naive`: if none of the above, then chose naive *Default*
403403
@@ -542,7 +542,7 @@ def autotune(self, *inputs, **kwargs):
542542
543543
* :attr:`conv`: if kernel resembles a convolution operation
544544
545-
* :attr:`group_conv`: if kernel resembles a convolution operation
545+
* :attr:`group_conv`: if kernel resembles a group convolution operation
546546
547547
* :attr:`naive`: if none of the above, then chose naive *Default*
548548

test_python/layers/test_avgpool.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import tensor_comprehensions as tc
1717

1818
import torch
19-
import torch.cuda
2019
import unittest
2120

2221

@@ -26,7 +25,7 @@ def test_avgpool(self):
2625
# NOTE: take note of use of {{ }} below for handling TC with scalars
2726
LANG = """
2827
def avgpool(float(B, C, H, W) input) -> (output) {{
29-
output(b, c, h, w) += input(b, c, h * {sH} + kh, w * {sW} + kw) where kh in 0:{kH}, kw in 0:{kW}
28+
output(b, c, h, w) +=! input(b, c, h * {sH} + kh, w * {sW} + kw) / ({kH} * {kW}) where kh in 0:{kH}, kw in 0:{kW}
3029
}}
3130
"""
3231
avgpool = tc.define(LANG, name="avgpool", constants={"sH":1, "sW":1, "kH":2, "kW":2})

test_python/layers/test_avgpool_autotune.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_avgpool_autotune(self):
3131
# NOTE: take note of use of {{ }} below for handling TC with scalars
3232
LANG = """
3333
def avgpool(float(B, C, H, W) input) -> (output) {{
34-
output(b, c, h, w) += input(b, c, h * {sH} + kh, w * {sW} + kw) where kh in 0:{kH}, kw in 0:{kW}
34+
output(b, c, h, w) +=! input(b, c, h * {sH} + kh, w * {sW} + kw) / ({kH} * {kW}) where kh in 0:{kH}, kw in 0:{kW}
3535
}}
3636
"""
3737
avgpool = tc.define(LANG, name="avgpool", constants={"sH":1, "sW":1, "kH":2, "kW":2})

test_python/layers/test_maxpool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_maxpool(self):
2626
# NOTE: take note of use of {{ }}
2727
LANG = """
2828
def maxpool(float(B, C, H, W) input) -> (output) {{
29-
output(b, c, h, w) max= input(b, c, h * {sH} + kh, w * {sW} + kw) where kh in 0:{kH}, kw in 0:{kW}
29+
output(b, c, h, w) max=! input(b, c, h * {sH} + kh, w * {sW} + kw) where kh in 0:{kH}, kw in 0:{kW}
3030
}}
3131
"""
3232
maxpool = tc.define(LANG, name="maxpool", constants={"sH":1, "sW":1, "kH":2, "kW":2})

test_python/test_scalar_tc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test_avgpool_option1(self):
2525
# NOTE: take note of use of {{ }} below for handling TC with scalars
2626
LANG = """
2727
def avgpool(float(B, C, H, W) input) -> (output) {{
28-
output(b, c, h, w) += input(b, c, h * {sH} + kh, w * {sW} + kw) where kh in 0:{kH}, kw in 0:{kW}
28+
output(b, c, h, w) +=! input(b, c, h * {sH} + kh, w * {sW} + kw) / ({kH} * {kW}) where kh in 0:{kH}, kw in 0:{kW}
2929
}}
3030
"""
3131
avgpool = tc.define(LANG, name="avgpool", constants={"sH":1, "sW":1, "kH":2, "kW":2})
@@ -36,7 +36,7 @@ def test_avgpool_option2(self):
3636
# NOTE: take note of use of {{ }}
3737
LANG="""
3838
def avgpool(float(B, C, H, W) input) -> (output) {{
39-
output(b, c, h, w) += input(b, c, h * {sh} + kh, w * {sw} + kw) where kh = [0, {kH}[, kw = [0, {kW}[
39+
output(b, c, h, w) +=! input(b, c, h * {sh} + kh, w * {sw} + kw) / ({kH} * {kW}) where kh = [0, {kH}[, kw = [0, {kW}[
4040
}}
4141
"""
4242
sH, sW, kH, kW = 1, 1, 2, 2
@@ -51,7 +51,7 @@ def test_avgpool_option3(self):
5151
import re
5252
LANG="""
5353
def avgpool(float(B, C, H, W) input) -> (output) {
54-
output(b, c, h, w) += input(b, c, h * <sh> + kh, w * <sw> + kw) where kh in 0:<kH>, kw in 0:<kW>
54+
output(b, c, h, w) +=! input(b, c, h * <sh> + kh, w * <sw> + kw) / (<kH> * <kW>) where kh in 0:<kH>, kw in 0:<kW>
5555
}
5656
"""
5757
sH, sW, kH, kW = 1, 1, 2, 2

test_python/test_tc_torch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def test_avgpool(self):
102102
# NOTE: take note of use of {{ }}
103103
LANG = """
104104
def avgpool(float(B, C, H, W) input) -> (output) {{
105-
output(b, c, h, w) += input(b, c, h * {sH} + kh, w * {sW} + kw) where kh in 0:{kH}, kw in 0:{kW}
105+
output(b, c, h, w) +=! input(b, c, h * {sH} + kh, w * {sW} + kw) / ({kH} * {kW}) where kh in 0:{kH}, kw in 0:{kW}
106106
}}
107107
"""
108108
avgpool = tc.define(LANG, name="avgpool", constants={"sH":1, "sW":1, "kH":2, "kW":2})

0 commit comments

Comments
 (0)