17
17
#include " absl/base/thread_annotations.h"
18
18
#include " absl/container/flat_hash_map.h"
19
19
#include " absl/meta/type_traits.h"
20
+ #include " absl/status/status.h"
20
21
#include " absl/strings/string_view.h"
21
22
#include " absl/synchronization/mutex.h"
22
23
#include " absl/types/span.h"
23
- #include " src/sentencepiece_model.pb.h"
24
24
#include " src/sentencepiece.pb.h"
25
+ #include " src/sentencepiece_model.pb.h"
25
26
#include " src/sentencepiece_processor.h"
26
27
#include " tensorflow/core/framework/bounds_check.h"
27
28
#include " tensorflow/core/framework/dataset_stateful_op_allowlist.h"
33
34
#include " tensorflow/core/framework/tensor_types.h"
34
35
#include " tensorflow/core/framework/types.h"
35
36
#include " tensorflow/core/framework/types.pb.h"
37
+ #include " tensorflow/core/graph/graph.h"
36
38
#include " tensorflow/core/graph/graph_def_builder.h"
37
39
#include " tensorflow/core/lib/core/errors.h"
38
40
#include " tensorflow/core/lib/core/refcount.h"
@@ -67,7 +69,7 @@ struct SentencepieceResource : public ResourceBase {
67
69
(reverse == this ->reverse );
68
70
}
69
71
70
- Status AsGraphDef (GraphDefBuilder* builder, Node** out) const override {
72
+ sentencepiece::util:: Status AsGraphDef (GraphDefBuilder* builder, Node** out) const override {
71
73
absl::ReaderMutexLock l (&mu);
72
74
// We set use_node_name_sharing with a unique node name so that the resource
73
75
// can outlive the kernel. This means that the lifetime of the re-created
@@ -93,10 +95,10 @@ struct SentencepieceResource : public ResourceBase {
93
95
// TODO(broken) Determine a medium cost of a call to the SentencePiece processor
94
96
constexpr int64 kCostPerUnit = 10000 ;
95
97
96
- ::tensorflow ::Status ToTFStatus (const sentencepiece::util::Status& s) {
97
- if (s.ok ()) return :: tensorflow ::Status ();
98
- return :: tensorflow ::Status (static_cast <::tensorflow::errors::Code >(s.code ()),
99
- ::tensorflow::string (s.message()));
98
+ absl ::Status ToTFStatus (const sentencepiece::util::Status& s) {
99
+ if (s.ok ()) return sentencepiece::util ::Status ();
100
+ return sentencepiece::util ::Status (static_cast <absl::StatusCode >(s.code ()),
101
+ ::tensorflow::string (s.message()));
100
102
}
101
103
102
104
template <typename T>
@@ -114,8 +116,8 @@ int32 GetPieceOrId<int32>(
114
116
return sp.id ();
115
117
}
116
118
117
- tensorflow ::Status HandleExtraOptions (OpKernelContext* ctx,
118
- SentencepieceResource* sp) {
119
+ absl ::Status HandleExtraOptions (OpKernelContext* ctx,
120
+ SentencepieceResource* sp) {
119
121
const Tensor* add_bos_tensor = nullptr ;
120
122
TF_RETURN_IF_ERROR (ctx->input (" add_bos" , &add_bos_tensor));
121
123
const bool add_bos = add_bos_tensor->scalar <bool >()();
@@ -209,7 +211,7 @@ class SentencepieceOp : public OpKernel {
209
211
GetNodeAttr (this ->def (), " model" , &model_proto_attr));
210
212
211
213
if (TF_PREDICT_FALSE (model_proto_attr.empty ())) {
212
- return Status (tensorflow::errors::InvalidArgument (
214
+ return sentencepiece::util:: Status (tensorflow::errors::InvalidArgument (
213
215
" Model argument must be specified." ));
214
216
}
215
217
// Loads serialized sentencepiece model proto to enable embedding
0 commit comments