Skip to content

Commit ebca9ee

Browse files
authored
Merge pull request #99 from deepray-AI/1022
[OPS] TFOkStatus compatibility code for C++
2 parents bd193dd + 14b8146 commit ebca9ee

13 files changed

Lines changed: 33 additions & 23 deletions

File tree

.github/workflows/ci_test.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ jobs:
2929
name: Notebook lint
3030
runs-on: ubuntu-latest
3131
steps:
32-
- uses: actions/setup-python@v1
33-
- uses: actions/checkout@v4
32+
- uses: actions/checkout@v5
33+
- uses: actions/setup-python@v6
34+
with:
35+
python-version: '3.13'
3436
- name: Install tensorflow-docs
3537
run: python3 -m pip install -U git+https://github.com/tensorflow/docs
3638
- name: Lint notebooks

build_deps/tf_dependency/build_defs.bzl.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
D_GLIBCXX_USE_CXX11_ABI = "%{tf_cx11_abi}"
44
CPLUSPLUS_VERSION = "%{tf_cplusplus_ver}"
5-
DTF_VERSION_INTEGER = "%{tf_version_integer}"
5+
TF_VERSION_INTEGER = "%{tf_version_integer}"

build_deps/tf_dependency/tf_configure.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def _tf_pip_impl(repository_ctx):
213213
tf_shared_cc_library_path = "%s/%s" % (tf_shared_library_dir, tf_shared_cc_library_name)
214214
tf_cx11_abi = "-D_GLIBCXX_USE_CXX11_ABI=%s" % (repository_ctx.os.environ[_TF_CXX11_ABI_FLAG])
215215
tf_cplusplus_ver = "-std=%s" % repository_ctx.os.environ[_TF_CPLUSPLUS_VER]
216-
tf_version_integer = "-DTF_VERSION_INTEGER=%s" % (repository_ctx.os.environ[_TF_VERSION_INTEGER])
216+
tf_version_integer = "TF_VERSION_INTEGER=%s" % (repository_ctx.os.environ[_TF_VERSION_INTEGER])
217217

218218
tf_shared_library_rule = _symlink_genrule_for_dir(
219219
repository_ctx,

configure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import shutil
2626
import subprocess
2727
import sys
28-
from typing import Optional
28+
from typing import List, Optional
2929

3030
import tensorflow as tf
3131
from packaging.version import Version
@@ -873,7 +873,7 @@ def _find_executable_or_die(executable_name: str, executable_path: Optional[str]
873873
return resolved_path_to_exe
874874

875875

876-
def _get_cuda_compute_capabilities_or_die() -> list[str]:
876+
def _get_cuda_compute_capabilities_or_die() -> List[str]:
877877
"""Finds compute capabilities via nvidia-smi or rasies exception.
878878
879879
Returns:

deepray/custom_ops/parquet_dataset/BUILD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ custom_op_library(
1414
deps = [
1515
":arrow_util",
1616
":parquet_batch_reader",
17+
"//deepray/custom_ops/utils:ok_status_util",
1718
],
1819
)
1920

@@ -31,6 +32,7 @@ cc_library(
3132
"DEEPREC_ARROW_ZEROCOPY",
3233
],
3334
deps = [
35+
"//deepray/custom_ops/utils:ok_status_util",
3436
"@local_config_tf//:libtensorflow_framework",
3537
"@local_config_tf//:tf_header_lib",
3638
"@org_apache_arrow//:arrow",
@@ -47,6 +49,7 @@ cc_library(
4749
],
4850
deps = [
4951
":arrow_util",
52+
"//deepray/custom_ops/utils:ok_status_util",
5053
"@local_config_tf//:libtensorflow_framework",
5154
"@local_config_tf//:tf_header_lib",
5255
"@org_apache_arrow//:arrow",

deepray/custom_ops/parquet_dataset/cc/kernels/arrow_util.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ limitations under the License.
2525

2626
#include "arrow/array.h"
2727
#include "arrow/util/thread_pool.h"
28+
#include "deepray/custom_ops/utils/ok_status_util.h"
2829
#include "eigen.h"
2930
#include "tensorflow/core/framework/allocation_description.pb.h"
3031

@@ -252,7 +253,7 @@ class RaggedTensorBuilder : public ::arrow::ArrayVisitor {
252253
#define CASE_ARROW_ENUM_SET_DTYPE(PTR, ENUM) \
253254
case ENUM: { \
254255
*PTR = DataTypeToEnum<ArrowEnumToDataType<ENUM>::Type>::value; \
255-
return OkStatus(); \
256+
return TFOkStatus; \
256257
}
257258

258259
Status MakeDataTypeAndRaggedRankFromArrowDataType(
@@ -280,7 +281,7 @@ Status MakeDataTypeAndRaggedRankFromArrowDataType(
280281
return errors::Unimplemented("Arrow data type ", arrow_dtype->ToString(),
281282
" not supported.");
282283
}
283-
return OkStatus();
284+
return TFOkStatus;
284285
}
285286

286287
Status MakeTensorsFromArrowArray(
@@ -297,7 +298,7 @@ Status MakeTensorsFromArrowArray(
297298

298299
RaggedTensorBuilder builder(dtype, ragged_rank);
299300
TF_RETURN_IF_ARROW_ERROR(builder.Build(arrow_array, output_tensors));
300-
return OkStatus();
301+
return TFOkStatus;
301302
}
302303

303304
int UpdateArrowCpuThreadPoolCapacityFromEnv() {

deepray/custom_ops/parquet_dataset/cc/kernels/parquet_batch_reader.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ limitations under the License.
2121

2222
#include "absl/strings/match.h"
2323
#include "arrow_util.h"
24+
#include "deepray/custom_ops/utils/ok_status_util.h"
2425

2526
namespace tensorflow {
2627
namespace data {
@@ -44,7 +45,7 @@ class ParquetBatchReader::Impl {
4445

4546
Status Open() {
4647
if (TF_PREDICT_TRUE(batch_reader_)) {
47-
return OkStatus();
48+
return TFOkStatus;
4849
}
4950
if (TF_PREDICT_FALSE(partition_index_ >= partition_count_)) {
5051
return errors::InvalidArgument("Partition index ", partition_index_,
@@ -101,7 +102,7 @@ class ParquetBatchReader::Impl {
101102

102103
TF_RETURN_IF_ARROW_ERROR(reader_->GetRecordBatchReader(
103104
row_group_indices_, column_indices_, &batch_reader_));
104-
return OkStatus();
105+
return TFOkStatus;
105106
}
106107

107108
Status Read(std::vector<Tensor>* output_tensors) {
@@ -123,7 +124,7 @@ class ParquetBatchReader::Impl {
123124
field_dtypes_[i], field_ragged_ranks_[i], arrays[i], output_tensors));
124125
}
125126

126-
return OkStatus();
127+
return TFOkStatus;
127128
}
128129

129130
private:

deepray/custom_ops/parquet_dataset/cc/kernels/parquet_dataset_ops.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ limitations under the License.
1616

1717
#include <unordered_set>
1818

19+
#include "deepray/custom_ops/utils/ok_status_util.h"
1920
#include "tensorflow/core/framework/common_shape_fns.h"
2021
#include "tensorflow/core/framework/op.h"
2122
#include "tensorflow/core/framework/op_def_builder.h"
@@ -83,14 +84,14 @@ class ParquetTabularDatasetOp::Dataset : public DatasetBase {
8384
return output_shapes_;
8485
}
8586

86-
Status CheckExternalState() const override { return OkStatus(); }
87+
Status CheckExternalState() const override { return TFOkStatus; }
8788

8889
string DebugString() const override {
8990
return "ParquetTabularDatasetOp::Dataset";
9091
}
9192

9293
Status InputDatasets(std::vector<const DatasetBase*>* inputs) const override {
93-
return OkStatus();
94+
return TFOkStatus;
9495
}
9596

9697
protected:
@@ -122,7 +123,7 @@ class ParquetTabularDatasetOp::Dataset : public DatasetBase {
122123
{"partition_index", partition_index},
123124
{"drop_remainder", drop_remainder}},
124125
output));
125-
return OkStatus();
126+
return TFOkStatus;
126127
}
127128

128129
private:
@@ -159,7 +160,7 @@ class ParquetTabularDatasetOp::Dataset::Iterator
159160
return s;
160161
}
161162
*end_of_sequence = true;
162-
return OkStatus();
163+
return TFOkStatus;
163164
}
164165

165166
protected:

deepray/custom_ops/utils/BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
load("@local_config_cuda//cuda:build_defs.bzl", "cuda_library")
2+
load("@local_config_tf//:build_defs.bzl", "TF_VERSION_INTEGER")
23
load("@org_tensorflow//tensorflow:tensorflow.bzl", "tf_copts")
34

45
package(default_visibility = ["//visibility:public"])
@@ -24,6 +25,9 @@ cc_library(
2425
srcs = [
2526
"ok_status_util.h",
2627
],
28+
defines = [
29+
TF_VERSION_INTEGER,
30+
],
2731
visibility = ["//visibility:public"],
2832
)
2933

deepray/custom_ops/utils/ok_status_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ This code is for compatibility.*/
3333
#else
3434
// #pragma message(PRINT_MACRO(TF_VERSION_INTEGER))
3535
// #define TFOkStatus Status::OK()
36-
#define TFOkStatus absl::OkStatus()
36+
#define TFOkStatus Status::OK()
3737
#endif
3838
} // namespace deepray
3939
} // namespace tensorflow

0 commit comments

Comments
 (0)