Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e3abcb2
use in-tree public codegen API.
bdhirsh Apr 12, 2021
611328f
use in-tree public codegen API.
bdhirsh Apr 12, 2021
74e512e
use in-tree public codegen API.
bdhirsh Apr 12, 2021
abe7177
stop pinning to feature branch
bdhirsh Apr 21, 2021
3287c32
remove torch_pin file before merging. preemptively update yaml to inc…
bdhirsh Apr 23, 2021
94d3a37
use in-tree public codegen API.
bdhirsh Apr 12, 2021
8eeb025
stop pinning to feature branch
bdhirsh Apr 21, 2021
7b96dc4
[WIP] remove bridge:: api from codegen. Start auto-gen'ing out/inplac…
bdhirsh Apr 23, 2021
929ac37
updated torch pin
bdhirsh May 4, 2021
59dd0a3
fix missing ops in yaml
bdhirsh May 11, 2021
ef715c6
remove torch_pin file before merging. preemptively update yaml to inc…
bdhirsh Apr 23, 2021
5abe8da
make codegen backend-agnostic, except for CPU fallbacks
bdhirsh May 5, 2021
cd9b98f
remove logging
bdhirsh May 11, 2021
44bd431
rename aten_xla_type.h -> XLANativeFunctions.h
bdhirsh May 19, 2021
e7419ea
rename aten_xla_type.h -> XLANativeFunctions.h
bdhirsh May 19, 2021
9cd0538
fix rename, delete aten_xla_type.h
bdhirsh May 19, 2021
b6955de
update torch_pin after the file rename
bdhirsh May 19, 2021
768fdf7
remove logging info from yaml
bdhirsh May 19, 2021
bf823ea
make codegen backend-agnostic, except for CPU fallbacks
bdhirsh May 5, 2021
16178e1
rename aten_xla_type.h -> XLANativeFunctions.h
bdhirsh May 19, 2021
b4c1b7a
fix rename, delete aten_xla_type.h
bdhirsh May 19, 2021
2b7be3a
use codegen'd inplace kernels, and delete manually written inplace ke…
bdhirsh May 21, 2021
a7dd973
fix test change
bdhirsh May 24, 2021
427690c
lint
bdhirsh May 24, 2021
5390b73
remove accidentally committed yaml changes
bdhirsh May 25, 2021
c967eb1
remove torch pin
bdhirsh May 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions test/cpp/test_aten_xla_tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ TEST_F(AtenXlaTensorTest, TestDivInPlace) {
}
}
ExpectCounterNotChanged("aten::.*", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::div_", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::div", cpp_test::GetIgnoredCounters());
}

TEST_F(AtenXlaTensorTest, TestDivInPlaceWithRoundingMode) {
Expand Down Expand Up @@ -443,7 +443,7 @@ TEST_F(AtenXlaTensorTest, TestDivInPlaceWithRoundingMode) {
}
}
ExpectCounterNotChanged("aten::.*", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::div_", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::div", cpp_test::GetIgnoredCounters());
}

TEST_F(AtenXlaTensorTest, TestDivScalar) {
Expand Down Expand Up @@ -485,7 +485,7 @@ TEST_F(AtenXlaTensorTest, TestDivScalarInPlace) {
}
}
ExpectCounterNotChanged("aten::.*", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::div_", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::div", cpp_test::GetIgnoredCounters());
}

TEST_F(AtenXlaTensorTest, TestDivOut) {
Expand Down Expand Up @@ -1920,7 +1920,7 @@ TEST_F(AtenXlaTensorTest, TestCosineSimilarity) {

ExpectCounterNotChanged("aten::.*", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::sum", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::clamp_min_", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::clamp_min", cpp_test::GetIgnoredCounters());
}
}

Expand All @@ -1944,7 +1944,7 @@ TEST_F(AtenXlaTensorTest, TestCosineEmbeddingLoss) {
AllClose(output, xla_output);
});
ExpectCounterNotChanged("aten::.*", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::clamp_min_", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::clamp_min", cpp_test::GetIgnoredCounters());
}
}
}
Expand All @@ -1968,7 +1968,7 @@ TEST_F(AtenXlaTensorTest, TestHingeEmbeddingLoss) {
});

ExpectCounterNotChanged("aten::.*", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::clamp_min_", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::clamp_min", cpp_test::GetIgnoredCounters());
}
}
}
Expand Down Expand Up @@ -2063,7 +2063,7 @@ TEST_F(AtenXlaTensorTest, TestMarginRankingLoss) {
});

ExpectCounterNotChanged("aten::.*", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::clamp_min_", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::clamp_min", cpp_test::GetIgnoredCounters());
}
}
}
Expand Down Expand Up @@ -2476,7 +2476,7 @@ TEST_F(AtenXlaTensorTest, TestAsinhInPlace) {
AllClose(b, xla_b, /*rtol=*/1e-3, /*atol=*/1e-5);
});
ExpectCounterNotChanged("aten::.*", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::asinh_", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::asinh", cpp_test::GetIgnoredCounters());
}

TEST_F(AtenXlaTensorTest, TestSin) {
Expand Down Expand Up @@ -2533,7 +2533,7 @@ TEST_F(AtenXlaTensorTest, TestAcoshInPlace) {
AllClose(b, xla_b, /*rtol=*/1e-3, /*atol=*/1e-5);
});
ExpectCounterNotChanged("aten::.*", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::acosh_", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::acosh", cpp_test::GetIgnoredCounters());
}

TEST_F(AtenXlaTensorTest, TestCos) {
Expand Down Expand Up @@ -2588,7 +2588,7 @@ TEST_F(AtenXlaTensorTest, TestAtanhInPlace) {
AllClose(b, xla_b, /*rtol=*/1e-3, /*atol=*/1e-5);
});
ExpectCounterNotChanged("aten::.*", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::atanh_", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::atanh", cpp_test::GetIgnoredCounters());
}

TEST_F(AtenXlaTensorTest, TestAtan2) {
Expand Down Expand Up @@ -2777,7 +2777,7 @@ TEST_F(AtenXlaTensorTest, TestClampMinExplicitInPlace) {
AllClose(b, xla_b);
});
ExpectCounterNotChanged("aten::.*", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::clamp_min_", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::clamp_min", cpp_test::GetIgnoredCounters());
}

TEST_F(AtenXlaTensorTest, TestClampMaxExplicitInPlace) {
Expand All @@ -2791,7 +2791,7 @@ TEST_F(AtenXlaTensorTest, TestClampMaxExplicitInPlace) {
AllClose(b, xla_b);
});
ExpectCounterNotChanged("aten::.*", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::clamp_max_", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::clamp_max", cpp_test::GetIgnoredCounters());
}

TEST_F(AtenXlaTensorTest, TestCeil) {
Expand Down Expand Up @@ -3192,7 +3192,7 @@ TEST_F(AtenXlaTensorTest, TestBlackmanWindow) {

ExpectCounterNotChanged("aten::.*", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::arange_out", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::cos_", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::cos", cpp_test::GetIgnoredCounters());
}
}

Expand All @@ -3213,7 +3213,7 @@ TEST_F(AtenXlaTensorTest, TestHammingWindow) {

ExpectCounterNotChanged("aten::.*", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::arange_out", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::cos_", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::cos", cpp_test::GetIgnoredCounters());
}
}

Expand All @@ -3231,7 +3231,7 @@ TEST_F(AtenXlaTensorTest, TestHannWindow) {

ExpectCounterNotChanged("aten::.*", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::arange_out", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::cos_", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::cos", cpp_test::GetIgnoredCounters());
}
}

Expand Down Expand Up @@ -3475,7 +3475,7 @@ TEST_F(AtenXlaTensorTest, TestBatchAddBatchMatMulInPlace) {
});

ExpectCounterNotChanged("aten::.*", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::baddbmm_", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::baddbmm", cpp_test::GetIgnoredCounters());
}

TEST_F(AtenXlaTensorTest, TestBatchMatMul) {
Expand Down Expand Up @@ -5513,7 +5513,7 @@ TEST_F(AtenXlaTensorTest, TestHardSigmoidInPlace) {
AllClose(output, xla_output);
});
ExpectCounterNotChanged("aten::.*", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::hardsigmoid_", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::hardsigmoid", cpp_test::GetIgnoredCounters());
}

TEST_F(AtenXlaTensorTest, TestHardSigmoidBackward) {
Expand Down
50 changes: 27 additions & 23 deletions test/cpp/test_tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "cpp_test_util.h"
#include "torch/csrc/autograd/variable.h"
#include "torch_xla/csrc/aten_xla_bridge.h"
#include "torch_xla/csrc/tensor.h"
#include "torch_xla/csrc/tensor_util.h"
#include "torch_xla_test.h"
Expand Down Expand Up @@ -205,13 +206,14 @@ TEST_F(TensorTest, TestViewMod) {
output.add_(one, 1.0);
input.add_(one, 1.0);
ForEachDevice([&](const Device& device) {
at::Tensor xinput =
at::zeros({32, 20, 4, 4}, at::TensorOptions(at::kFloat));
XLATensor dev_input = XLATensor::Create(xinput, device);
XLATensor dev_one = XLATensor::Create(one, device);
XLATensor dev_output = XLATensor::view(dev_input, {-1, 320});
XLATensor::add_(dev_output, dev_one, 1.0);
XLATensor::add_(dev_input, dev_one, 1.0);
at::Tensor dev_input =
at::zeros({32, 20, 4, 4},
at::TensorOptions(bridge::XlaDeviceToAtenDevice(device)));
at::Tensor dev_one = at::tensor(
1.0, at::TensorOptions(bridge::XlaDeviceToAtenDevice(device)));
at::Tensor dev_output = dev_input.view({-1, 320});
dev_output.add_(dev_one, 1.0);
dev_input.add_(dev_one, 1.0);
AllClose(output, dev_output);
AllClose(input, dev_input);
});
Expand All @@ -225,14 +227,15 @@ TEST_F(TensorTest, TestViewModComplex) {
at::Tensor output2 = input.view({-1, 160});
output2.add_(one, 1.0);
ForEachDevice([&](const Device& device) {
at::Tensor xinput =
at::zeros({32, 20, 4, 4}, at::TensorOptions(at::kFloat));
XLATensor dev_input = XLATensor::Create(xinput, device);
XLATensor dev_one = XLATensor::Create(one, device);
XLATensor dev_output1 = XLATensor::view(dev_input, {-1, 320});
XLATensor::add_(dev_output1, dev_one, 1.0);
XLATensor dev_output2 = XLATensor::view(dev_input, {-1, 160});
XLATensor::add_(dev_output2, dev_one, 1.0);
at::Tensor dev_input =
at::zeros({32, 20, 4, 4},
at::TensorOptions(bridge::XlaDeviceToAtenDevice(device)));
at::Tensor dev_one = at::tensor(
1.0, at::TensorOptions(bridge::XlaDeviceToAtenDevice(device)));
at::Tensor dev_output1 = dev_input.view({-1, 320});
dev_output1.add_(dev_one, 1.0);
at::Tensor dev_output2 = dev_input.view({-1, 160});
dev_output2.add_(dev_one, 1.0);
AllClose(output1, dev_output1);
AllClose(output2, dev_output2);
});
Expand All @@ -246,14 +249,15 @@ TEST_F(TensorTest, TestViewOfViewMod) {
at::Tensor output2 = output1.view({-1, 160});
output2.add_(one, 1.0);
ForEachDevice([&](const Device& device) {
at::Tensor xinput =
at::zeros({32, 20, 4, 4}, at::TensorOptions(at::kFloat));
XLATensor dev_input = XLATensor::Create(xinput, device);
XLATensor dev_one = XLATensor::Create(one, device);
XLATensor dev_output1 = XLATensor::view(dev_input, {-1, 320});
XLATensor::add_(dev_output1, dev_one, 1.0);
XLATensor dev_output2 = XLATensor::view(dev_output1, {-1, 160});
XLATensor::add_(dev_output2, dev_one, 1.0);
at::Tensor dev_input =
at::zeros({32, 20, 4, 4},
at::TensorOptions(bridge::XlaDeviceToAtenDevice(device)));
at::Tensor dev_one = at::tensor(
1.0, at::TensorOptions(bridge::XlaDeviceToAtenDevice(device)));
at::Tensor dev_output1 = dev_input.view({-1, 320});
dev_output1.add_(dev_one, 1.0);
at::Tensor dev_output2 = dev_input.view({-1, 160});
dev_output2.add_(dev_one, 1.0);
AllClose(output1, dev_output1);
AllClose(output2, dev_output2);
});
Expand Down
Loading