aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/compiler/xla/python
diff options
context:
space:
mode:
authorGravatar Yunxing Dai <yunxing@google.com>2018-08-21 17:08:12 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-08-21 17:12:22 -0700
commit3cb3a450ed845c4602080f43d7bb6cfade298a22 (patch)
tree21e5a40fcb72737bd2cb00829bd049c5173d20e0 /tensorflow/compiler/xla/python
parent95d718a8a41370f31ccb3b32aaac7fd00b0291e4 (diff)
[XLA] gtl::optional->absl::optional
PiperOrigin-RevId: 209686671
Diffstat (limited to 'tensorflow/compiler/xla/python')
-rw-r--r--tensorflow/compiler/xla/python/local_computation_builder.cc9
-rw-r--r--tensorflow/compiler/xla/python/local_computation_builder.h5
-rw-r--r--tensorflow/compiler/xla/python/local_computation_builder.i12
-rw-r--r--tensorflow/compiler/xla/python/numpy_bridge.cc32
4 files changed, 27 insertions, 31 deletions
diff --git a/tensorflow/compiler/xla/python/local_computation_builder.cc b/tensorflow/compiler/xla/python/local_computation_builder.cc
index c133a20419..00e36c3c86 100644
--- a/tensorflow/compiler/xla/python/local_computation_builder.cc
+++ b/tensorflow/compiler/xla/python/local_computation_builder.cc
@@ -137,8 +137,7 @@ static StatusOr<ScopedShapedBuffer> ToBuffer(LocalClient* client,
/* static */
StatusOr<LocalShapedBuffer*> LocalShapedBuffer::FromLiteral(
- const Literal& argument,
- const tensorflow::gtl::optional<Shape>& shape_with_layout) {
+ const Literal& argument, const absl::optional<Shape>& shape_with_layout) {
LocalClient* client = GetOrCreateLocalClient();
StatusOr<ScopedShapedBuffer> buf = [&] {
if (shape_with_layout) {
@@ -163,7 +162,7 @@ CompiledLocalComputation::CompiledLocalComputation(
StatusOr<std::unique_ptr<Literal>> CompiledLocalComputation::Execute(
const std::vector<Literal>& arguments,
- const std::vector<tensorflow::gtl::optional<Shape>>& shapes_with_layout) {
+ const std::vector<absl::optional<Shape>>& shapes_with_layout) {
LocalClient* client = GetOrCreateLocalClient();
VLOG(1) << "Execution requested with " << GetReplicaCount() << " replicas.";
@@ -194,7 +193,7 @@ StatusOr<std::unique_ptr<Literal>> CompiledLocalComputation::Execute(
scoped_buffers.reserve(arguments.size());
for (int i = 0; i < arguments.size(); ++i) {
const Literal& argument = arguments[i];
- const tensorflow::gtl::optional<Shape>& shape_with_layout =
+ const absl::optional<Shape>& shape_with_layout =
shapes_with_layout[i];
StatusOr<ScopedShapedBuffer> pushed;
@@ -576,7 +575,7 @@ StatusOr<bool> LocalComputationBuilder::IsConstant(const LocalOp& operand) {
}
LocalOp LocalComputationBuilder::Sort(const LocalOp& operand, int64 dimension) {
- return xla::Sort(operand.op(), tensorflow::gtl::nullopt, dimension);
+ return xla::Sort(operand.op(), absl::nullopt, dimension);
}
LocalOp LocalComputationBuilder::SortKeyVal(const LocalOp& keys,
diff --git a/tensorflow/compiler/xla/python/local_computation_builder.h b/tensorflow/compiler/xla/python/local_computation_builder.h
index 5f9078ab84..d9543b958d 100644
--- a/tensorflow/compiler/xla/python/local_computation_builder.h
+++ b/tensorflow/compiler/xla/python/local_computation_builder.h
@@ -60,8 +60,7 @@ StatusOr<std::unique_ptr<Literal> > TransferFromOutfeedLocalReplica(
class LocalShapedBuffer {
public:
static StatusOr<LocalShapedBuffer*> FromLiteral(
- const Literal& argument,
- const tensorflow::gtl::optional<Shape>& shape_with_layout);
+ const Literal& argument, const absl::optional<Shape>& shape_with_layout);
LocalShapedBuffer(ScopedShapedBuffer shaped_buffer);
const ScopedShapedBuffer* shaped_buffer() const;
@@ -120,7 +119,7 @@ class CompiledLocalComputation {
// shapes_with_layout.
StatusOr<std::unique_ptr<Literal> > Execute(
const std::vector<Literal>& arguments,
- const std::vector<tensorflow::gtl::optional<Shape> >& shapes_with_layout);
+ const std::vector<absl::optional<Shape> >& shapes_with_layout);
LocalShapedBuffer* ExecuteWithShapedBuffers(
tensorflow::gtl::ArraySlice<LocalShapedBuffer*> argument_handles);
diff --git a/tensorflow/compiler/xla/python/local_computation_builder.i b/tensorflow/compiler/xla/python/local_computation_builder.i
index fa5d75908f..e1060d54e2 100644
--- a/tensorflow/compiler/xla/python/local_computation_builder.i
+++ b/tensorflow/compiler/xla/python/local_computation_builder.i
@@ -409,10 +409,10 @@ tensorflow::ImportNumpy();
$1 = &temp;
}
-%typemap(in) const tensorflow::gtl::optional<Shape>& (
- tensorflow::gtl::optional<Shape> temp) {
+%typemap(in) const absl::optional<Shape>& (
+ absl::optional<Shape> temp) {
if ($input == Py_None) {
- temp = tensorflow::gtl::nullopt;
+ temp = absl::nullopt;
$1 = &temp;
} else {
StatusOr<Shape> statusor = numpy::XlaShapeFromPyShape($input);
@@ -448,8 +448,8 @@ tensorflow::ImportNumpy();
$1 = &temps;
}
-%typemap(in) const std::vector<tensorflow::gtl::optional<Shape> >& (
- std::vector<tensorflow::gtl::optional<Shape> > temps) {
+%typemap(in) const std::vector<absl::optional<Shape> >& (
+ std::vector<absl::optional<Shape> > temps) {
if (!PySequence_Check($input)) {
PyErr_SetString(PyExc_TypeError, "Argument is not a sequence");
SWIG_fail;
@@ -458,7 +458,7 @@ tensorflow::ImportNumpy();
for (int i = 0; i < size; ++i) {
PyObject* o = PySequence_GetItem($input, i);
if (o == Py_None) {
- temps.push_back(tensorflow::gtl::nullopt);
+ temps.push_back(absl::nullopt);
} else {
StatusOr<Shape> statusor = numpy::XlaShapeFromPyShape(o);
Py_DECREF(o);
diff --git a/tensorflow/compiler/xla/python/numpy_bridge.cc b/tensorflow/compiler/xla/python/numpy_bridge.cc
index 6f665faf61..4b9970eadc 100644
--- a/tensorflow/compiler/xla/python/numpy_bridge.cc
+++ b/tensorflow/compiler/xla/python/numpy_bridge.cc
@@ -281,15 +281,15 @@ StatusOr<Shape> XlaShapeFromPyShape(PyObject* o) {
// Helper that retrieves the member with attr_name, stringifies it if is not
// None, and returns it as a C++ string.
-static tensorflow::gtl::optional<string> GetAttrAsString(
- PyObject* o, const string& attr_name) {
+static absl::optional<string> GetAttrAsString(PyObject* o,
+ const string& attr_name) {
if (!PyObject_HasAttrString(o, attr_name.c_str())) {
- return tensorflow::gtl::nullopt;
+ return absl::nullopt;
}
PyObject* attr = PyObject_GetAttrString(o, attr_name.c_str());
if (attr == Py_None) {
Py_DECREF(attr);
- return tensorflow::gtl::nullopt;
+ return absl::nullopt;
}
string result = PyObjectCppStr(attr);
Py_DECREF(attr);
@@ -298,48 +298,46 @@ static tensorflow::gtl::optional<string> GetAttrAsString(
// Helper that retrieves the member with attr_name, checks that it is an integer
// if it is not None, and returns it as an int32 value.
-static tensorflow::gtl::optional<int32> GetAttrAsInt32(
- PyObject* o, const string& attr_name) {
+static absl::optional<int32> GetAttrAsInt32(PyObject* o,
+ const string& attr_name) {
if (!PyObject_HasAttrString(o, attr_name.c_str())) {
- return tensorflow::gtl::nullopt;
+ return absl::nullopt;
}
PyObject* attr = PyObject_GetAttrString(o, attr_name.c_str());
if (attr == Py_None) {
Py_DECREF(attr);
- return tensorflow::gtl::nullopt;
+ return absl::nullopt;
}
if (!CheckPyIntOrLong(attr)) {
Py_DECREF(attr);
- return tensorflow::gtl::nullopt;
+ return absl::nullopt;
}
long value = PyIntOrPyLongToLong(attr); // NOLINT
Py_DECREF(attr);
if (value == -1 && PyErr_Occurred() != nullptr) {
- return tensorflow::gtl::nullopt;
+ return absl::nullopt;
}
if (static_cast<int32>(value) != value) {
- return tensorflow::gtl::nullopt;
+ return absl::nullopt;
}
return value;
}
StatusOr<OpMetadata> OpMetadataFromPyObject(PyObject* o) {
OpMetadata result;
- tensorflow::gtl::optional<string> op_type = GetAttrAsString(o, "op_type");
+ absl::optional<string> op_type = GetAttrAsString(o, "op_type");
if (op_type.has_value()) {
result.set_op_type(op_type.value());
}
- tensorflow::gtl::optional<string> op_name = GetAttrAsString(o, "op_name");
+ absl::optional<string> op_name = GetAttrAsString(o, "op_name");
if (op_name.has_value()) {
result.set_op_name(op_name.value());
}
- tensorflow::gtl::optional<string> source_file =
- GetAttrAsString(o, "source_file");
+ absl::optional<string> source_file = GetAttrAsString(o, "source_file");
if (source_file.has_value()) {
result.set_source_file(source_file.value());
}
- tensorflow::gtl::optional<int32> source_line =
- GetAttrAsInt32(o, "source_line");
+ absl::optional<int32> source_line = GetAttrAsInt32(o, "source_line");
if (source_line.has_value()) {
result.set_source_line(source_line.value());
}