diff --git a/tensorflow_serving/servables/tensorflow/multi_inference_test.cc b/tensorflow_serving/servables/tensorflow/multi_inference_test.cc index befa5bb2cd5..de38d93ea2b 100644 --- a/tensorflow_serving/servables/tensorflow/multi_inference_test.cc +++ b/tensorflow_serving/servables/tensorflow/multi_inference_test.cc @@ -60,7 +60,8 @@ class MultiInferenceTest : public ::testing::Test { static void TearDownTestSuite() { server_core_.reset(); } protected: - static Status CreateServerCore(std::unique_ptr* server_core) { + static absl::Status CreateServerCore( + std::unique_ptr* server_core) { ModelServerConfig config; auto model_config = config.mutable_model_config_list()->add_config(); model_config->set_name(kTestModelName); @@ -90,7 +91,7 @@ class MultiInferenceTest : public ::testing::Test { ServerCore* GetServerCore() { return this->server_core_.get(); } - Status GetInferenceRunner( + absl::Status GetInferenceRunner( std::unique_ptr* inference_runner) { ServableHandle bundle; ModelSpec model_spec; @@ -103,7 +104,7 @@ class MultiInferenceTest : public ::testing::Test { return absl::OkStatus(); } - Status GetServableHandle(ServableHandle* bundle) { + absl::Status GetServableHandle(ServableHandle* bundle) { ModelSpec model_spec; model_spec.set_name(kTestModelName); return GetServerCore()->GetServableHandle(model_spec, bundle); @@ -142,8 +143,8 @@ void PopulateTask(const string& signature_name, const string& method_name, task->set_method_name(method_name); } -void ExpectStatusError(const Status& status, - const tensorflow::errors::Code expected_code, +void ExpectStatusError(const absl::Status& status, + const absl::StatusCode expected_code, const string& message_substring) { EXPECT_EQ(expected_code, status.code()); EXPECT_THAT(status.message(), ::testing::HasSubstr(message_substring)); diff --git a/tensorflow_serving/servables/tensorflow/predict_util.cc b/tensorflow_serving/servables/tensorflow/predict_util.cc index 41ac069ef49..3dcc1295e8e 100644 --- a/tensorflow_serving/servables/tensorflow/predict_util.cc +++ b/tensorflow_serving/servables/tensorflow/predict_util.cc @@ -35,7 +35,7 @@ namespace tensorflow { namespace serving { namespace { -Status VerifySignature(const SignatureDef& signature) { +absl::Status VerifySignature(const SignatureDef& signature) { if (GetSignatureMethodNameCheckFeature() && signature.method_name() != kPredictMethodName && signature.method_name() != kClassifyMethodName && @@ -48,8 +48,8 @@ Status VerifySignature(const SignatureDef& signature) { return absl::OkStatus(); } -Status VerifyRequestInputsSize(const SignatureDef& signature, - const PredictRequest& request) { +absl::Status VerifyRequestInputsSize(const SignatureDef& signature, + const PredictRequest& request) { if (request.inputs().size() > signature.inputs().size() || (request.inputs().size() < signature.inputs().size() && signature.defaults().empty())) { @@ -59,7 +59,7 @@ Status VerifyRequestInputsSize(const SignatureDef& signature, SetDifference(request_inputs, signature_inputs); const std::set missing = SetDifference(signature_inputs, request_inputs); - return tensorflow::Status( + return absl::Status( static_cast(absl::StatusCode::kInvalidArgument), absl::StrCat( "input size does not match signature: ", request.inputs().size(), @@ -75,7 +75,7 @@ Status VerifyRequestInputsSize(const SignatureDef& signature, } // namespace namespace internal { -Status RunPredict( +absl::Status RunPredict( const RunOptions& run_options, const MetaGraphDef& meta_graph_def, const absl::optional& servable_version, const internal::PredictResponseTensorSerializationOption option, @@ -116,11 +116,11 @@ Status RunPredict( response); } -Status PreProcessPrediction(const SignatureDef& signature, - const PredictRequest& request, - std::vector>* inputs, - std::vector* output_tensor_names, - std::vector* output_tensor_aliases) { +absl::Status PreProcessPrediction( + const SignatureDef& signature, const PredictRequest& request, + std::vector>* inputs, + std::vector* output_tensor_names, + std::vector* output_tensor_aliases) { TF_RETURN_IF_ERROR(VerifySignature(signature)); TF_RETURN_IF_ERROR(VerifyRequestInputsSize(signature, request)); TF_RETURN_IF_ERROR( @@ -133,7 +133,7 @@ Status PreProcessPrediction(const SignatureDef& signature, for (auto& alias : output_filter) { auto iter = signature.outputs().find(alias); if (iter == signature.outputs().end()) { - return tensorflow::Status( + return absl::Status( static_cast(absl::StatusCode::kInvalidArgument), strings::StrCat("output tensor alias not found in signature: ", alias, " Outputs expected to be in the set {", @@ -141,7 +141,7 @@ Status PreProcessPrediction(const SignatureDef& signature, "}.")); } if (seen_outputs.find(alias) != seen_outputs.end()) { - return tensorflow::Status( + return absl::Status( static_cast(absl::StatusCode::kInvalidArgument), "duplicate output tensor alias: " + alias); } @@ -160,15 +160,15 @@ Status PreProcessPrediction(const SignatureDef& signature, return absl::OkStatus(); } -Status PostProcessPredictionResult( +absl::Status PostProcessPredictionResult( const std::vector& output_tensor_aliases, const std::vector& output_tensors, const internal::PredictResponseTensorSerializationOption option, PredictResponse* response) { // Validate and return output. if (output_tensors.size() != output_tensor_aliases.size()) { - return tensorflow::Status( - static_cast(absl::StatusCode::kUnknown), + return absl::Status( + static_cast(absl::StatusCode::kUnknown), "Predict internal error"); } switch (option) { @@ -191,12 +191,12 @@ Status PostProcessPredictionResult( } // namespace internal -Status RunPredict(const RunOptions& run_options, - const MetaGraphDef& meta_graph_def, - const absl::optional& servable_version, - Session* session, const PredictRequest& request, - PredictResponse* response, - const thread::ThreadPoolOptions& thread_pool_options) { +absl::Status RunPredict(const RunOptions& run_options, + const MetaGraphDef& meta_graph_def, + const absl::optional& servable_version, + Session* session, const PredictRequest& request, + PredictResponse* response, + const thread::ThreadPoolOptions& thread_pool_options) { return internal::RunPredict( run_options, meta_graph_def, servable_version, internal::PredictResponseTensorSerializationOption::kAsProtoField, diff --git a/tensorflow_serving/servables/tensorflow/predict_util_test.cc b/tensorflow_serving/servables/tensorflow/predict_util_test.cc index d94f3f78930..55fb9fffd56 100644 --- a/tensorflow_serving/servables/tensorflow/predict_util_test.cc +++ b/tensorflow_serving/servables/tensorflow/predict_util_test.cc @@ -51,40 +51,42 @@ class FakeSession : public tensorflow::Session { public: FakeSession() {} ~FakeSession() override = default; - Status Create(const GraphDef& graph) override { + absl::Status Create(const GraphDef& graph) override { return errors::Unimplemented("not available in fake"); } - Status Extend(const GraphDef& graph) override { + absl::Status Extend(const GraphDef& graph) override { return errors::Unimplemented("not available in fake"); } - Status Close() override { + absl::Status Close() override { return errors::Unimplemented("not available in fake"); } - Status ListDevices(std::vector* response) override { + absl::Status ListDevices(std::vector* response) override { return errors::Unimplemented("not available in fake"); } - Status Run(const std::vector>& inputs, - const std::vector& output_names, - const std::vector& target_nodes, - std::vector* outputs) override { + absl::Status Run(const std::vector>& inputs, + const std::vector& output_names, + const std::vector& target_nodes, + std::vector* outputs) override { RunMetadata run_metadata; return Run(RunOptions(), inputs, output_names, target_nodes, outputs, &run_metadata); } - Status Run(const RunOptions& run_options, - const std::vector>& inputs, - const std::vector& output_names, - const std::vector& target_nodes, - std::vector* outputs, RunMetadata* run_metadata) override { + absl::Status Run(const RunOptions& run_options, + const std::vector>& inputs, + const std::vector& output_names, + const std::vector& target_nodes, + std::vector* outputs, + RunMetadata* run_metadata) override { return Run(run_options, inputs, output_names, target_nodes, outputs, run_metadata, thread::ThreadPoolOptions()); } - Status Run(const RunOptions& run_options, - const std::vector>& inputs, - const std::vector& output_names, - const std::vector& target_nodes, - std::vector* outputs, RunMetadata* run_metadata, - const thread::ThreadPoolOptions& thread_pool_options) override { + absl::Status Run( + const RunOptions& run_options, + const std::vector>& inputs, + const std::vector& output_names, + const std::vector& target_nodes, std::vector* outputs, + RunMetadata* run_metadata, + const thread::ThreadPoolOptions& thread_pool_options) override { for (const auto& t : inputs) { outputs->push_back(t.second); } @@ -118,8 +120,8 @@ class PredictImplTest : public ::testing::Test { } protected: - static Status CreateServerCore(const string& model_path, - std::unique_ptr* server_core) { + static absl::Status CreateServerCore( + const string& model_path, std::unique_ptr* server_core) { ModelServerConfig config; auto model_config = config.mutable_model_config_list()->add_config(); model_config->set_name(kTestModelName); @@ -152,17 +154,18 @@ class PredictImplTest : public ::testing::Test { return saved_model_server_core_counter_model_.get(); } - Status GetSavedModelServableHandle(ServerCore* server_core, - ServableHandle* bundle) { + absl::Status GetSavedModelServableHandle( + ServerCore* server_core, ServableHandle* bundle) { ModelSpec model_spec; model_spec.set_name(kTestModelName); return server_core->GetServableHandle(model_spec, bundle); } - Status CallPredict(ServerCore* server_core, const PredictRequest& request, - PredictResponse* response, - const thread::ThreadPoolOptions& thread_pool_options = - thread::ThreadPoolOptions()) { + absl::Status CallPredict( + ServerCore* server_core, const PredictRequest& request, + PredictResponse* response, + const thread::ThreadPoolOptions& thread_pool_options = + thread::ThreadPoolOptions()) { ServableHandle bundle; TF_RETURN_IF_ERROR(GetSavedModelServableHandle(server_core, &bundle)); return RunPredict(GetRunOptions(), bundle->meta_graph_def, @@ -238,7 +241,7 @@ TEST_F(PredictImplTest, InputTensorsDontMatchModelSpecInputs) { tensor_proto2.mutable_tensor_shape()->add_dim()->set_size(1); (*inputs)["unknown_key2"] = tensor_proto2; - Status status = CallPredict(GetServerCore(), request, &response); + absl::Status status = CallPredict(GetServerCore(), request, &response); EXPECT_EQ(status.code(), static_cast(absl::StatusCode::kInvalidArgument)); EXPECT_THAT(status.message(), @@ -283,7 +286,7 @@ TEST_F(PredictImplTest, OutputFiltersDontMatchModelSpecOutputs) { request.add_output_filter("output_filter"); // Output filter like this doesn't exist. - Status status1 = CallPredict(GetServerCore(), request, &response); + absl::Status status1 = CallPredict(GetServerCore(), request, &response); EXPECT_EQ(status1.code(), static_cast(absl::StatusCode::kInvalidArgument)); EXPECT_THAT(status1.message(), @@ -296,7 +299,7 @@ TEST_F(PredictImplTest, OutputFiltersDontMatchModelSpecOutputs) { request.add_output_filter(kOutputTensorKey); // Duplicate output filter specified. - Status status2 = CallPredict(GetServerCore(), request, &response); + absl::Status status2 = CallPredict(GetServerCore(), request, &response); EXPECT_EQ(status2.code(), static_cast(absl::StatusCode::kInvalidArgument)); EXPECT_THAT(status2.message(), @@ -319,7 +322,7 @@ TEST_F(PredictImplTest, InputTensorsHaveWrongType) { request.add_output_filter(kOutputTensorKey); // Input tensors are all wrong. - Status status = CallPredict(GetServerCore(), request, &response); + absl::Status status = CallPredict(GetServerCore(), request, &response); EXPECT_EQ(status.code(), static_cast(absl::StatusCode::kInvalidArgument)); EXPECT_THAT(status.message(), diff --git a/tensorflow_serving/servables/tensorflow/regressor.cc b/tensorflow_serving/servables/tensorflow/regressor.cc index 7d0a5eb4a75..fad3e728d44 100644 --- a/tensorflow_serving/servables/tensorflow/regressor.cc +++ b/tensorflow_serving/servables/tensorflow/regressor.cc @@ -58,8 +58,8 @@ class SavedModelTensorFlowRegressor : public RegressorInterface { ~SavedModelTensorFlowRegressor() override = default; - Status Regress(const RegressionRequest& request, - RegressionResult* result) override { + absl::Status Regress(const RegressionRequest& request, + RegressionResult* result) override { TRACELITERAL("SavedModelTensorFlowRegressor::Regress"); string input_tensor_name; @@ -99,8 +99,8 @@ class SavedModelRegressor : public RegressorInterface { ~SavedModelRegressor() override = default; - Status Regress(const RegressionRequest& request, - RegressionResult* result) override { + absl::Status Regress(const RegressionRequest& request, + RegressionResult* result) override { SignatureDef signature; TF_RETURN_IF_ERROR(GetRegressionSignatureDef( request.model_spec(), bundle_->meta_graph_def, &signature)); @@ -118,14 +118,14 @@ class SavedModelRegressor : public RegressorInterface { } // namespace -Status CreateRegressorFromSavedModelBundle( +absl::Status CreateRegressorFromSavedModelBundle( const RunOptions& run_options, std::unique_ptr bundle, std::unique_ptr* service) { service->reset(new SavedModelRegressor(run_options, std::move(bundle))); return absl::OkStatus(); } -Status CreateFlyweightTensorFlowRegressor( +absl::Status CreateFlyweightTensorFlowRegressor( const RunOptions& run_options, Session* session, const SignatureDef* signature, std::unique_ptr* service) { @@ -133,7 +133,7 @@ Status CreateFlyweightTensorFlowRegressor( run_options, session, signature, thread::ThreadPoolOptions(), service); } -Status CreateFlyweightTensorFlowRegressor( +absl::Status CreateFlyweightTensorFlowRegressor( const RunOptions& run_options, Session* session, const SignatureDef* signature, const thread::ThreadPoolOptions& thread_pool_options, @@ -143,9 +143,9 @@ Status CreateFlyweightTensorFlowRegressor( return absl::OkStatus(); } -Status GetRegressionSignatureDef(const ModelSpec& model_spec, - const MetaGraphDef& meta_graph_def, - SignatureDef* signature) { +absl::Status GetRegressionSignatureDef(const ModelSpec& model_spec, + const MetaGraphDef& meta_graph_def, + SignatureDef* signature) { const string signature_name = model_spec.signature_name().empty() ? kDefaultServingSignatureDefKey : model_spec.signature_name(); @@ -167,9 +167,9 @@ Status GetRegressionSignatureDef(const ModelSpec& model_spec, return absl::OkStatus(); } -Status PreProcessRegression(const SignatureDef& signature, - string* input_tensor_name, - std::vector* output_tensor_names) { +absl::Status PreProcessRegression(const SignatureDef& signature, + string* input_tensor_name, + std::vector* output_tensor_names) { if (GetSignatureMethodNameCheckFeature() && signature.method_name() != kRegressMethodName) { return errors::InvalidArgument(strings::StrCat( @@ -207,7 +207,7 @@ Status PreProcessRegression(const SignatureDef& signature, return absl::OkStatus(); } -Status PostProcessRegressionResult( +absl::Status PostProcessRegressionResult( const SignatureDef& signature, int num_examples, const std::vector& output_tensor_names, const std::vector& output_tensors, RegressionResult* result) { @@ -266,12 +266,12 @@ Status PostProcessRegressionResult( return absl::OkStatus(); } -Status RunRegress(const RunOptions& run_options, - const MetaGraphDef& meta_graph_def, - const absl::optional& servable_version, - Session* session, const RegressionRequest& request, - RegressionResponse* response, - const thread::ThreadPoolOptions& thread_pool_options) { +absl::Status RunRegress(const RunOptions& run_options, + const MetaGraphDef& meta_graph_def, + const absl::optional& servable_version, + Session* session, const RegressionRequest& request, + RegressionResponse* response, + const thread::ThreadPoolOptions& thread_pool_options) { SignatureDef signature; TF_RETURN_IF_ERROR(GetRegressionSignatureDef(request.model_spec(), meta_graph_def, &signature)); diff --git a/tensorflow_serving/servables/tensorflow/regressor_test.cc b/tensorflow_serving/servables/tensorflow/regressor_test.cc index bb7cc5d271d..69c33c49935 100644 --- a/tensorflow_serving/servables/tensorflow/regressor_test.cc +++ b/tensorflow_serving/servables/tensorflow/regressor_test.cc @@ -65,25 +65,25 @@ class FakeSession : public tensorflow::Session { explicit FakeSession(absl::optional expected_timeout) : expected_timeout_(expected_timeout) {} ~FakeSession() override = default; - Status Create(const GraphDef& graph) override { + absl::Status Create(const GraphDef& graph) override { return errors::Unimplemented("not available in fake"); } - Status Extend(const GraphDef& graph) override { + absl::Status Extend(const GraphDef& graph) override { return errors::Unimplemented("not available in fake"); } - Status Close() override { + absl::Status Close() override { return errors::Unimplemented("not available in fake"); } - Status ListDevices(std::vector* response) override { + absl::Status ListDevices(std::vector* response) override { return errors::Unimplemented("not available in fake"); } - Status Run(const std::vector>& inputs, - const std::vector& output_names, - const std::vector& target_nodes, - std::vector* outputs) override { + absl::Status Run(const std::vector>& inputs, + const std::vector& output_names, + const std::vector& target_nodes, + std::vector* outputs) override { if (expected_timeout_) { LOG(FATAL) << "Run() without RunOptions not expected to be called"; } @@ -92,21 +92,23 @@ class FakeSession : public tensorflow::Session { &run_metadata); } - Status Run(const RunOptions& run_options, - const std::vector>& inputs, - const std::vector& output_names, - const std::vector& target_nodes, - std::vector* outputs, RunMetadata* run_metadata) override { + absl::Status Run(const RunOptions& run_options, + const std::vector>& inputs, + const std::vector& output_names, + const std::vector& target_nodes, + std::vector* outputs, + RunMetadata* run_metadata) override { return Run(run_options, inputs, output_names, target_nodes, outputs, run_metadata, thread::ThreadPoolOptions()); } - Status Run(const RunOptions& run_options, - const std::vector>& inputs, - const std::vector& output_names, - const std::vector& target_nodes, - std::vector* outputs, RunMetadata* run_metadata, - const thread::ThreadPoolOptions& thread_pool_options) override { + absl::Status Run( + const RunOptions& run_options, + const std::vector>& inputs, + const std::vector& output_names, + const std::vector& target_nodes, std::vector* outputs, + RunMetadata* run_metadata, + const thread::ThreadPoolOptions& thread_pool_options) override { if (expected_timeout_) { CHECK_EQ(*expected_timeout_, run_options.timeout_in_ms()); } @@ -123,8 +125,8 @@ class FakeSession : public tensorflow::Session { } // Parses TensorFlow Examples from a string Tensor. - static Status GetExamples(const Tensor& input, - std::vector* examples) { + static absl::Status GetExamples(const Tensor& input, + std::vector* examples) { examples->clear(); const int batch_size = input.dim_size(0); const auto& flat_input = input.flat(); @@ -151,9 +153,9 @@ class FakeSession : public tensorflow::Session { // Creates a Tensor by copying the "output" feature from each Example. // Requires each Example have an bytes feature called "class" which is of the // same non-zero length. - static Status GetOutputTensor(const std::vector& examples, - const string& output_tensor_name, - Tensor* tensor) { + static absl::Status GetOutputTensor(const std::vector& examples, + const string& output_tensor_name, + Tensor* tensor) { if (examples.empty()) { return errors::Internal("empty example list"); } @@ -232,7 +234,7 @@ class RegressorTest : public ::testing::TestWithParam { return example; } - Status Create() { + absl::Status Create() { std::unique_ptr saved_model(new SavedModelBundle); saved_model->meta_graph_def = saved_model_bundle_->meta_graph_def; saved_model->session = std::move(saved_model_bundle_->session); @@ -374,7 +376,7 @@ TEST_P(RegressorTest, InvalidNamedSignature) { request_.mutable_input()->mutable_example_list()->mutable_examples(); *examples->Add() = example_with_output(2.0); *examples->Add() = example_with_output(3.0); - Status status = regressor_->Regress(request_, &result_); + absl::Status status = regressor_->Regress(request_, &result_); ASSERT_FALSE(status.ok()); EXPECT_EQ(static_cast(absl::StatusCode::kInvalidArgument), status.code()) @@ -397,7 +399,7 @@ TEST_P(RegressorTest, MalformedOutputs) { request_.mutable_input()->mutable_example_list()->mutable_examples(); *examples->Add() = example_with_output(2.0); *examples->Add() = example_with_output(3.0); - Status status = regressor_->Regress(request_, &result_); + absl::Status status = regressor_->Regress(request_, &result_); ASSERT_FALSE(status.ok()); EXPECT_EQ(static_cast(absl::StatusCode::kInvalidArgument), @@ -417,7 +419,7 @@ TEST_P(RegressorTest, EmptyInput) { TF_ASSERT_OK(Create()); // Touch input. request_.mutable_input(); - Status status = regressor_->Regress(request_, &result_); + absl::Status status = regressor_->Regress(request_, &result_); ASSERT_FALSE(status.ok()); EXPECT_EQ(status.code(), error::Code::INVALID_ARGUMENT); EXPECT_THAT(status.message(), ::testing::HasSubstr("Input is empty")); @@ -432,7 +434,7 @@ TEST_P(RegressorTest, EmptyInput) { TEST_P(RegressorTest, EmptyExampleList) { TF_ASSERT_OK(Create()); request_.mutable_input()->mutable_example_list(); - Status status = regressor_->Regress(request_, &result_); + absl::Status status = regressor_->Regress(request_, &result_); ASSERT_FALSE(status.ok()); EXPECT_EQ(status.code(), error::Code::INVALID_ARGUMENT); EXPECT_THAT(status.message(), ::testing::HasSubstr("Input is empty")); @@ -450,7 +452,7 @@ TEST_P(RegressorTest, EmptyExampleListWithContext) { *request_.mutable_input() ->mutable_example_list_with_context() ->mutable_context() = example_with_output(3); - Status status = regressor_->Regress(request_, &result_); + absl::Status status = regressor_->Regress(request_, &result_); ASSERT_FALSE(status.ok()); EXPECT_EQ(status.code(), error::Code::INVALID_ARGUMENT); EXPECT_THAT(status.message(), ::testing::HasSubstr("Input is empty")); @@ -471,7 +473,7 @@ TEST_P(RegressorTest, RunsFails) { TF_ASSERT_OK(Create()); *request_.mutable_input()->mutable_example_list()->mutable_examples()->Add() = example_with_output(2.0); - Status status = regressor_->Regress(request_, &result_); + absl::Status status = regressor_->Regress(request_, &result_); ASSERT_FALSE(status.ok()); EXPECT_THAT(status.ToString(), ::testing::HasSubstr("Run totally failed")); RegressionResponse response; @@ -491,7 +493,7 @@ TEST_P(RegressorTest, UnexpectedOutputTensorSize) { TF_ASSERT_OK(Create()); *request_.mutable_input()->mutable_example_list()->mutable_examples()->Add() = example_with_output(2.0); - Status status = regressor_->Regress(request_, &result_); + absl::Status status = regressor_->Regress(request_, &result_); ASSERT_FALSE(status.ok()); EXPECT_THAT(status.ToString(), ::testing::HasSubstr("output batch size")); EXPECT_CALL(*mock, Run(_, _, _, _, _, _, _)) @@ -515,7 +517,7 @@ TEST_P(RegressorTest, UnexpectedOutputTensorType) { TF_ASSERT_OK(Create()); *request_.mutable_input()->mutable_example_list()->mutable_examples()->Add() = example_with_output(2.0); - Status status = regressor_->Regress(request_, &result_); + absl::Status status = regressor_->Regress(request_, &result_); ASSERT_FALSE(status.ok()); EXPECT_THAT(status.ToString(), ::testing::HasSubstr("Expected output Tensor of DT_FLOAT")); @@ -542,7 +544,7 @@ TEST_P(RegressorTest, MissingRegressionSignature) { *request_.mutable_input()->mutable_example_list()->mutable_examples()->Add() = example; // TODO(b/26220896): This error should move to construction time. - Status status = regressor_->Regress(request_, &result_); + absl::Status status = regressor_->Regress(request_, &result_); ASSERT_FALSE(status.ok()); EXPECT_EQ(static_cast(absl::StatusCode::kInvalidArgument), status.code()) diff --git a/tensorflow_serving/servables/tensorflow/saved_model_bundle_factory.cc b/tensorflow_serving/servables/tensorflow/saved_model_bundle_factory.cc index ae9e0d7adbf..1b749199a16 100644 --- a/tensorflow_serving/servables/tensorflow/saved_model_bundle_factory.cc +++ b/tensorflow_serving/servables/tensorflow/saved_model_bundle_factory.cc @@ -55,9 +55,10 @@ std::vector GetSignatureDefs(const SavedModelBundle& bundle) { // TODO(b/140959776): Move this upstream alongside `kSavedModelFilenamePb`. const char kTfLiteModelFilename[] = "model.tflite"; -Status LoadTfLiteModel(const string& model_dir, SavedModelBundle* bundle, - const SessionOptions& options, int num_interpreter_pools, - int num_interpreters_per_pool) { +absl::Status LoadTfLiteModel(const string& model_dir, SavedModelBundle* bundle, + const SessionOptions& options, + int num_interpreter_pools, + int num_interpreters_per_pool) { std::unique_ptr session; const string& fname = io::JoinPath(model_dir, kTfLiteModelFilename); @@ -88,7 +89,7 @@ bool TfLiteModelFound(const string& model_dir) { } // namespace -Status SavedModelBundleFactory::Create( +absl::Status SavedModelBundleFactory::Create( const SessionBundleConfig& config, std::unique_ptr* factory) { std::shared_ptr batcher; @@ -100,24 +101,24 @@ Status SavedModelBundleFactory::Create( return absl::OkStatus(); } -Status SavedModelBundleFactory::EstimateResourceRequirement( +absl::Status SavedModelBundleFactory::EstimateResourceRequirement( const string& path, ResourceAllocation* estimate) const { return EstimateResourceFromPath( path, config_.resource_estimation_uses_validation_result(), estimate); } -Status SavedModelBundleFactory::CreateSavedModelBundleWithMetadata( +absl::Status SavedModelBundleFactory::CreateSavedModelBundleWithMetadata( const Loader::Metadata& metadata, const string& path, std::unique_ptr* bundle) { return InternalCreateSavedModelBundle(metadata, path, bundle); } -Status SavedModelBundleFactory::CreateSavedModelBundle( +absl::Status SavedModelBundleFactory::CreateSavedModelBundle( const string& path, std::unique_ptr* bundle) { return InternalCreateSavedModelBundle({}, path, bundle); } -Status SavedModelBundleFactory::InternalCreateSavedModelBundle( +absl::Status SavedModelBundleFactory::InternalCreateSavedModelBundle( const absl::optional& metadata, const string& path, std::unique_ptr* bundle) { bundle->reset(new SavedModelBundle); diff --git a/tensorflow_serving/servables/tensorflow/saved_model_warmup_test_util.cc b/tensorflow_serving/servables/tensorflow/saved_model_warmup_test_util.cc index 20ebb7f5ae0..7fedd63dbae 100644 --- a/tensorflow_serving/servables/tensorflow/saved_model_warmup_test_util.cc +++ b/tensorflow_serving/servables/tensorflow/saved_model_warmup_test_util.cc @@ -66,9 +66,9 @@ void PopulateRegressionRequest(RegressionRequest* request) { request->mutable_model_spec()->set_signature_name(kRegressMethodName); } -Status PopulatePredictionLog(PredictionLog* prediction_log, - PredictionLog::LogTypeCase log_type, - int num_repeated_values) { +absl::Status PopulatePredictionLog(PredictionLog* prediction_log, + PredictionLog::LogTypeCase log_type, + int num_repeated_values) { if ((num_repeated_values > 1) && (log_type != PredictionLog::kPredictStreamedLog)) { return errors::InvalidArgument( @@ -106,9 +106,9 @@ Status PopulatePredictionLog(PredictionLog* prediction_log, return absl::OkStatus(); } -Status WriteWarmupData(const string& fname, - const std::vector& warmup_records, - int num_warmup_records) { +absl::Status WriteWarmupData(const string& fname, + const std::vector& warmup_records, + int num_warmup_records) { Env* env = Env::Default(); std::unique_ptr file; TF_RETURN_IF_ERROR(env->NewWritableFile(fname, &file)); @@ -124,7 +124,7 @@ Status WriteWarmupData(const string& fname, return absl::OkStatus(); } -Status WriteWarmupDataAsSerializedProtos( +absl::Status WriteWarmupDataAsSerializedProtos( const string& fname, const std::vector& warmup_records, int num_warmup_records) { Env* env = Env::Default(); @@ -139,7 +139,7 @@ Status WriteWarmupDataAsSerializedProtos( return absl::OkStatus(); } -Status AddMixedWarmupData( +absl::Status AddMixedWarmupData( std::vector* warmup_records, const std::vector& log_types) { for (auto& log_type : log_types) { @@ -148,9 +148,9 @@ Status AddMixedWarmupData( return absl::OkStatus(); } -Status AddToWarmupData(std::vector* warmup_records, - PredictionLog::LogTypeCase log_type, - int num_repeated_values) { +absl::Status AddToWarmupData(std::vector* warmup_records, + PredictionLog::LogTypeCase log_type, + int num_repeated_values) { PredictionLog prediction_log; TF_RETURN_IF_ERROR( PopulatePredictionLog(&prediction_log, log_type, num_repeated_values)); diff --git a/tensorflow_serving/servables/tensorflow/saved_model_warmup_util.cc b/tensorflow_serving/servables/tensorflow/saved_model_warmup_util.cc index b31af35763d..4a889447dd3 100644 --- a/tensorflow_serving/servables/tensorflow/saved_model_warmup_util.cc +++ b/tensorflow_serving/servables/tensorflow/saved_model_warmup_util.cc @@ -58,9 +58,9 @@ uint64_t GetLatencyMicroseconds(const uint64_t start_microseconds) { constexpr char WarmupConsts::kRequestsFileName[]; constexpr int WarmupConsts::kMaxNumRecords; -Status RunSavedModelWarmup( +absl::Status RunSavedModelWarmup( const ModelWarmupOptions& model_warmup_options, const string export_dir, - std::function warmup_request_executor) { + std::function warmup_request_executor) { WarmupStateRegistry::Handle warmup_handle; auto per_model_data = std::make_unique(); per_model_data->warmup_all_batch_sizes = @@ -102,7 +102,7 @@ Status RunSavedModelWarmup( ? std::max(model_warmup_options.num_model_warmup_threads().value(), 1) : 1; std::unique_ptr tf_record_file_reader; - Status status; + absl::Status status; int num_warmup_records = 0; if (num_model_warmup_threads <= 1) { tf_record_file_reader.reset( @@ -132,7 +132,7 @@ Status RunSavedModelWarmup( ::tensorflow::mutex mu; int num_thread_task_done ABSL_GUARDED_BY(mu){0}; int num_warmup_records ABSL_GUARDED_BY(mu){0}; - ::tensorflow::Status warm_up_status ABSL_GUARDED_BY(mu); + absl::Status warm_up_status ABSL_GUARDED_BY(mu); // Condition variable to wait until all scheduled warmup tasks are // executed. ::tensorflow::condition_variable done ABSL_GUARDED_BY(mu); @@ -153,10 +153,10 @@ Status RunSavedModelWarmup( executor->Schedule([state, num_request_iterations, warmup_request_executor, warmup_path, num_model_warmup_threads]() { - Status status = absl::OkStatus(); + absl::Status status = absl::OkStatus(); while (status.ok()) { tstring record; - Status execution_status; + absl::Status execution_status; tensorflow::serving::PredictionLog prediction_log; { ::tensorflow::mutex_lock lock(state->mu); diff --git a/tensorflow_serving/servables/tensorflow/saved_model_warmup_util_test.cc b/tensorflow_serving/servables/tensorflow/saved_model_warmup_util_test.cc index b1e3a5f25d3..cb660cc8908 100644 --- a/tensorflow_serving/servables/tensorflow/saved_model_warmup_util_test.cc +++ b/tensorflow_serving/servables/tensorflow/saved_model_warmup_util_test.cc @@ -174,7 +174,7 @@ TEST_P(SavedModelBundleWarmupUtilTest, UnsupportedFileFormat) { TF_ASSERT_OK(WriteWarmupDataAsSerializedProtos(fname, warmup_records, 10)); SavedModelBundle saved_model_bundle; AddSignatures(&saved_model_bundle.meta_graph_def); - const Status status = RunSavedModelWarmup( + const absl::Status status = RunSavedModelWarmup( CreateModelWarmupOptions(), base_path, [](PredictionLog prediction_log) { return absl::OkStatus(); }); ASSERT_FALSE(status.ok()); @@ -197,7 +197,7 @@ TEST_P(SavedModelBundleWarmupUtilTest, TooManyWarmupRecords) { internal::WarmupConsts::kMaxNumRecords + 1)); SavedModelBundle saved_model_bundle; AddSignatures(&saved_model_bundle.meta_graph_def); - const Status status = RunSavedModelWarmup( + const absl::Status status = RunSavedModelWarmup( CreateModelWarmupOptions(), base_path, [](PredictionLog prediction_log) { return absl::OkStatus(); }); ASSERT_FALSE(status.ok()); @@ -219,7 +219,7 @@ TEST_P(SavedModelBundleWarmupUtilTest, UnparsableRecord) { std::vector warmup_records = {"malformed_record"}; TF_ASSERT_OK(WriteWarmupData(fname, warmup_records, 10)); SavedModelBundle saved_model_bundle; - const Status status = RunSavedModelWarmup( + const absl::Status status = RunSavedModelWarmup( CreateModelWarmupOptions(), base_path, [](PredictionLog prediction_log) { return absl::OkStatus(); }); ASSERT_FALSE(status.ok()); @@ -243,7 +243,7 @@ TEST_P(SavedModelBundleWarmupUtilTest, RunFailure) { TF_ASSERT_OK(WriteWarmupData(fname, warmup_records, num_warmup_records)); SavedModelBundle saved_model_bundle; AddSignatures(&saved_model_bundle.meta_graph_def); - Status status = RunSavedModelWarmup( + absl::Status status = RunSavedModelWarmup( CreateModelWarmupOptions(), base_path, [](PredictionLog prediction_log) { return errors::InvalidArgument("Run failed"); });