Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 0 additions & 7 deletions torch_xla/csrc/aten_xla_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3032,13 +3032,6 @@ at::Tensor& XLANativeFunctions::t_(at::Tensor& self) {
return self;
}

at::Tensor XLANativeFunctions::take(const at::Tensor& self,
const at::Tensor& index) {
XLA_FN_COUNTER("xla::");
return bridge::AtenFromXlaTensor(
XLATensor::take(bridge::GetXlaTensor(self), bridge::GetXlaTensor(index)));
}

at::Tensor XLANativeFunctions::tanh_backward(const at::Tensor& grad_output,
const at::Tensor& output) {
XLA_FN_COUNTER("xla::");
Expand Down
15 changes: 0 additions & 15 deletions torch_xla/csrc/ops/ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,21 +713,6 @@ torch::lazy::NodePtr MinUnary(const torch::lazy::Value& input) {
std::move(lower_fn));
}

torch::lazy::NodePtr Take(const torch::lazy::Value& input,
const torch::lazy::Value& index) {
auto lower_fn = [](const XlaNode& node,
LoweringContext* loctx) -> XlaOpVector {
xla::XlaOp xla_input = loctx->GetOutputOp(node.operand(0));
xla::XlaOp xla_index = loctx->GetOutputOp(node.operand(1));
xla::XlaOp result = BuildTake(xla_input, xla_index);
return node.ReturnOp(result, loctx);
};
xla::Shape result_shape = GetXlaShape(index);
result_shape.set_element_type(GetXlaShape(input).element_type());
return GenericOp(torch::lazy::OpKind(at::aten::take), {input, index},
std::move(result_shape), std::move(lower_fn));
}

torch::lazy::NodePtr TanhGelu(const torch::lazy::Value& input) {
// TODO: add proper lowering function
torch::lazy::ScopePusher ir_scope("aten::tanh_gelu");
Expand Down
3 changes: 0 additions & 3 deletions torch_xla/csrc/ops/ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,6 @@ torch::lazy::NodePtr MaxUnary(const torch::lazy::Value& input);

torch::lazy::NodePtr MinUnary(const torch::lazy::Value& input);

torch::lazy::NodePtr Take(const torch::lazy::Value& input,
const torch::lazy::Value& index);

torch::lazy::NodePtr TanhGelu(const torch::lazy::Value& input);

torch::lazy::NodePtr TanhGeluBackward(const torch::lazy::Value& grad,
Expand Down
8 changes: 8 additions & 0 deletions torch_xla/csrc/ops/ops_lower_fn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "tensorflow/compiler/xla/client/lib/logdet.h"
#include "tensorflow/compiler/xla/client/lib/math.h"
#include "torch_xla/csrc/data_ops.h"
#include "torch_xla/csrc/elementwise.h"
#include "torch_xla/csrc/helpers.h"
#include "torch_xla/csrc/matrix.h"
Expand Down Expand Up @@ -298,6 +299,13 @@ torch_xla::XlaOpVector Sinh::Lower(LoweringContext* loctx) const {
// return ReturnOps({result.sign, result.logdet}, loctx);
// }

torch_xla::XlaOpVector Take::Lower(LoweringContext* loctx) const {
xla::XlaOp xla_input = loctx->GetOutputOp(operand(0));
xla::XlaOp xla_index = loctx->GetOutputOp(operand(1));
xla::XlaOp result = BuildTake(xla_input, xla_index);
return ReturnOp(result, loctx);
}

torch_xla::XlaOpVector Tan::Lower(LoweringContext* loctx) const {
xla::XlaOp xla_input = loctx->GetOutputOp(operand(0));
return ReturnOp(xla::Tan(xla_input), loctx);
Expand Down
7 changes: 7 additions & 0 deletions torch_xla/csrc/ops/ops_xla_shape_fn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,13 @@ xla::Shape TanOutputShape(const torch::lazy::Value& input) {
return GetXlaShape(input);
}

xla::Shape TakeOutputShape(const torch::lazy::Value& input,
const torch::lazy::Value& index) {
xla::Shape result_shape = GetXlaShape(index);
result_shape.set_element_type(GetXlaShape(input).element_type());
return result_shape;
}

xla::Shape TanhOutputShape(const torch::lazy::Value& input) {
return GetXlaShape(input);
}
Expand Down
3 changes: 3 additions & 0 deletions torch_xla/csrc/ops/ops_xla_shape_fn.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ xla::Shape SinhOutputShape(const torch::lazy::Value& input);
/* Blocked on https://github.com/pytorch/xla/issues/3596 */
// xla::Shape SlogdetOutputShape(const torch::lazy::Value& input);

xla::Shape TakeOutputShape(const torch::lazy::Value& input,
const torch::lazy::Value& index);

xla::Shape TanOutputShape(const torch::lazy::Value& input);

xla::Shape TanhOutputShape(const torch::lazy::Value& input);
Expand Down
5 changes: 0 additions & 5 deletions torch_xla/csrc/tensor_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2648,11 +2648,6 @@ std::tuple<XLATensorPtr, XLATensorPtr> XLATensor::symeig(
input->CreateFrom(torch::lazy::Value(node, 1)));
}

XLATensorPtr XLATensor::take(const XLATensorPtr& input,
const XLATensorPtr& index) {
return input->CreateFrom(Take(input->GetIrValue(), index->GetIrValue()));
}

XLATensorPtr XLATensor::tanh_backward(const XLATensorPtr& grad_output,
const XLATensorPtr& output) {
return XLATensor::mul(grad_output,
Expand Down
2 changes: 1 addition & 1 deletion xla_native_functions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ full_codegen:
- silu_backward
- sin
- sinh
- take
- tan
- tanh
- tril
Expand Down Expand Up @@ -307,7 +308,6 @@ supported:
- symeig
- t
- t_
- take
- tanh_backward
- threshold
- threshold_backward
Expand Down