【发布时间】:2019-07-26 20:53:43
【问题描述】:
我知道 git diff 可以显示两个提交之间的差异。但是,我不知道如何为每个提交的文件获取更改的行(例如@@ -12,6 +12,11 @@)。我已经使用正则表达式来获取数字,但我想为每个文件分开它们。
换句话说,我想要这样的东西:
a/aten/src/ATen/cpu/vec256/vec256_int.h
@@ -12,6 +12,11 @@
@@ -95,25 +100,19 @@
@@ -190,25 +189,19 @@
@@ -380,25 +373,19 @@
diff --git a/test/test_torch.py b/test/test_torch.py
@@ -1388,6 +1388,14 @@
来自下面的输出:
diff --git a/aten/src/ATen/cpu/vec256/vec256_int.h b/aten/src/ATen/cpu/vec256/vec256_int.h
index 9d2581e18..5c1cf80d5 100644
--- a/aten/src/ATen/cpu/vec256/vec256_int.h
+++ b/aten/src/ATen/cpu/vec256/vec256_int.h
@@ -12,6 +12,11 @@ namespace {
struct Vec256i {
protected:
__m256i values;
+
+ static inline __m256i invert(const __m256i& v) {
+ const auto ones = _mm256_set1_epi64x(-1);
+ return _mm256_xor_si256(ones, v);
+ }
public:
Vec256i() {}
Vec256i(__m256i v) : values(v) {}
@@ -95,25 +100,19 @@ struct Vec256<int64_t> : public Vec256i {
return _mm256_cmpeq_epi64(values, other.values);
}
@@ -190,25 +189,19 @@ struct Vec256<int32_t> : public Vec256i {
return _mm256_cmpeq_epi32(values, other.values);
}
@@ -380,25 +373,19 @@ struct Vec256<int16_t> : public Vec256i {
return _mm256_cmpeq_epi16(values, other.values);
}
diff --git a/test/test_torch.py b/test/test_torch.py
index 0c30c1f1a..10f6085cf 100644
--- a/test/test_torch.py
+++ b/test/test_torch.py
@@ -1388,6 +1388,14 @@ class _TestTorchMixin(object):
def test_neg(self):
self._test_neg(self, lambda t: t)
+ def test_threshold(self):
+ for dtype in torch.testing.get_all_dtypes():
+ if dtype != torch.uint8 and dtype != torch.float16:
+ # 100 is wide enough to use AVX2 instructions for all types
+ x = torch.randn(100).sign().to(dtype=dtype)
+ y = torch.threshold(x, 0, 0)
+ self.assertTrue(y.le(0).any())
+
def test_reciprocal(self):
a = torch.randn(100, 89)
res_div = 1 / a
注意:我使用的是 Python 语言。
【问题讨论】: