Use absl::Status and co explicitly
This commit is contained in:
parent
c6c80c3745
commit
5b155941bf
|
@ -58,7 +58,7 @@ MEDIAPIPE_REGISTER_NODE(MatrixToVectorCalculator);
|
||||||
|
|
||||||
absl::Status MatrixToVectorCalculator::Open(CalculatorContext* cc) {
|
absl::Status MatrixToVectorCalculator::Open(CalculatorContext* cc) {
|
||||||
cc->SetOffset(0);
|
cc->SetOffset(0);
|
||||||
return mediapipe::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::Status MatrixToVectorCalculator::Process(CalculatorContext* cc) {
|
absl::Status MatrixToVectorCalculator::Process(CalculatorContext* cc) {
|
||||||
|
|
|
@ -63,7 +63,7 @@ absl::StatusOr<Packet<TfLiteModelPtr>> InferenceCalculator::GetModelAsPacket(
|
||||||
return TfLiteModelLoader::LoadFromPath(options.model_path());
|
return TfLiteModelLoader::LoadFromPath(options.model_path());
|
||||||
}
|
}
|
||||||
if (!kSideInModel(cc).IsEmpty()) return kSideInModel(cc);
|
if (!kSideInModel(cc).IsEmpty()) return kSideInModel(cc);
|
||||||
return absl::Status(mediapipe::StatusCode::kNotFound,
|
return absl::Status(absl::StatusCode::kNotFound,
|
||||||
"Must specify TFLite model as path or loaded model.");
|
"Must specify TFLite model as path or loaded model.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,11 +144,10 @@ absl::Status InferenceCalculatorGlImpl::Open(CalculatorContext* cc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MP_RETURN_IF_ERROR(gpu_helper_.Open(cc));
|
MP_RETURN_IF_ERROR(gpu_helper_.Open(cc));
|
||||||
MP_RETURN_IF_ERROR(
|
MP_RETURN_IF_ERROR(gpu_helper_.RunInGlContext([this, &cc]() -> absl::Status {
|
||||||
gpu_helper_.RunInGlContext([this, &cc]() -> ::mediapipe::Status {
|
return use_advanced_gpu_api_ ? InitTFLiteGPURunner(cc)
|
||||||
return use_advanced_gpu_api_ ? InitTFLiteGPURunner(cc)
|
: LoadDelegateAndAllocateTensors(cc);
|
||||||
: LoadDelegateAndAllocateTensors(cc);
|
}));
|
||||||
}));
|
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +161,7 @@ absl::Status InferenceCalculatorGlImpl::Process(CalculatorContext* cc) {
|
||||||
|
|
||||||
if (use_advanced_gpu_api_) {
|
if (use_advanced_gpu_api_) {
|
||||||
MP_RETURN_IF_ERROR(gpu_helper_.RunInGlContext(
|
MP_RETURN_IF_ERROR(gpu_helper_.RunInGlContext(
|
||||||
[this, &input_tensors, &output_tensors]() -> ::mediapipe::Status {
|
[this, &input_tensors, &output_tensors]() -> absl::Status {
|
||||||
for (int i = 0; i < input_tensors.size(); ++i) {
|
for (int i = 0; i < input_tensors.size(); ++i) {
|
||||||
MP_RETURN_IF_ERROR(tflite_gpu_runner_->BindSSBOToInputTensor(
|
MP_RETURN_IF_ERROR(tflite_gpu_runner_->BindSSBOToInputTensor(
|
||||||
input_tensors[i].GetOpenGlBufferReadView().name(), i));
|
input_tensors[i].GetOpenGlBufferReadView().name(), i));
|
||||||
|
@ -177,8 +176,8 @@ absl::Status InferenceCalculatorGlImpl::Process(CalculatorContext* cc) {
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
MP_RETURN_IF_ERROR(gpu_helper_.RunInGlContext(
|
MP_RETURN_IF_ERROR(
|
||||||
[this, &input_tensors]() -> ::mediapipe::Status {
|
gpu_helper_.RunInGlContext([this, &input_tensors]() -> absl::Status {
|
||||||
// Explicitly copy input.
|
// Explicitly copy input.
|
||||||
for (int i = 0; i < input_tensors.size(); ++i) {
|
for (int i = 0; i < input_tensors.size(); ++i) {
|
||||||
glBindBuffer(GL_COPY_READ_BUFFER,
|
glBindBuffer(GL_COPY_READ_BUFFER,
|
||||||
|
@ -200,8 +199,8 @@ absl::Status InferenceCalculatorGlImpl::Process(CalculatorContext* cc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_gpu_delegate_) {
|
if (use_gpu_delegate_) {
|
||||||
MP_RETURN_IF_ERROR(gpu_helper_.RunInGlContext(
|
MP_RETURN_IF_ERROR(
|
||||||
[this, &output_tensors]() -> ::mediapipe::Status {
|
gpu_helper_.RunInGlContext([this, &output_tensors]() -> absl::Status {
|
||||||
output_tensors->reserve(output_shapes_.size());
|
output_tensors->reserve(output_shapes_.size());
|
||||||
for (int i = 0; i < output_shapes_.size(); ++i) {
|
for (int i = 0; i < output_shapes_.size(); ++i) {
|
||||||
const auto& t = gpu_buffers_out_[i];
|
const auto& t = gpu_buffers_out_[i];
|
||||||
|
@ -250,7 +249,7 @@ absl::Status InferenceCalculatorGlImpl::SaveGpuCaches() {
|
||||||
absl::Status InferenceCalculatorGlImpl::Close(CalculatorContext* cc) {
|
absl::Status InferenceCalculatorGlImpl::Close(CalculatorContext* cc) {
|
||||||
MP_RETURN_IF_ERROR(SaveGpuCaches());
|
MP_RETURN_IF_ERROR(SaveGpuCaches());
|
||||||
if (use_gpu_delegate_) {
|
if (use_gpu_delegate_) {
|
||||||
MP_RETURN_IF_ERROR(gpu_helper_.RunInGlContext([this]() -> Status {
|
MP_RETURN_IF_ERROR(gpu_helper_.RunInGlContext([this]() -> absl::Status {
|
||||||
gpu_buffers_in_.clear();
|
gpu_buffers_in_.clear();
|
||||||
gpu_buffers_out_.clear();
|
gpu_buffers_out_.clear();
|
||||||
// Delegate must outlive the interpreter, hence the order is important.
|
// Delegate must outlive the interpreter, hence the order is important.
|
||||||
|
|
|
@ -367,7 +367,8 @@ absl::Status SceneCameraMotionAnalyzer::PopulateFocusPointFrames(
|
||||||
scene_summary, focus_point_frame_type, scene_frame_timestamps,
|
scene_summary, focus_point_frame_type, scene_frame_timestamps,
|
||||||
focus_point_frames);
|
focus_point_frames);
|
||||||
} else {
|
} else {
|
||||||
return absl::Status(StatusCode::kInvalidArgument, "Unknown motion type.");
|
return absl::Status(absl::StatusCode::kInvalidArgument,
|
||||||
|
"Unknown motion type.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ TEST(VisualScorerTest, ScoresSharpness) {
|
||||||
image_mat.setTo(cv::Scalar(0, 0, 0));
|
image_mat.setTo(cv::Scalar(0, 0, 0));
|
||||||
float score_rect = 0;
|
float score_rect = 0;
|
||||||
auto status = scorer.CalculateScore(image_mat, region, &score_rect);
|
auto status = scorer.CalculateScore(image_mat, region, &score_rect);
|
||||||
EXPECT_EQ(status.code(), StatusCode::kInvalidArgument);
|
EXPECT_EQ(status.code(), absl::StatusCode::kInvalidArgument);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(VisualScorerTest, ScoresColorfulness) {
|
TEST(VisualScorerTest, ScoresColorfulness) {
|
||||||
|
|
|
@ -257,19 +257,19 @@ struct First {
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct AddStatus {
|
struct AddStatus {
|
||||||
using type = StatusOr<T>;
|
using type = absl::StatusOr<T>;
|
||||||
};
|
};
|
||||||
template <class T>
|
template <class T>
|
||||||
struct AddStatus<StatusOr<T>> {
|
struct AddStatus<absl::StatusOr<T>> {
|
||||||
using type = StatusOr<T>;
|
using type = absl::StatusOr<T>;
|
||||||
};
|
};
|
||||||
template <>
|
template <>
|
||||||
struct AddStatus<Status> {
|
struct AddStatus<absl::Status> {
|
||||||
using type = Status;
|
using type = absl::Status;
|
||||||
};
|
};
|
||||||
template <>
|
template <>
|
||||||
struct AddStatus<void> {
|
struct AddStatus<void> {
|
||||||
using type = Status;
|
using type = absl::Status;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class R, class F, class... A>
|
template <class R, class F, class... A>
|
||||||
|
@ -280,7 +280,7 @@ struct CallAndAddStatusImpl {
|
||||||
};
|
};
|
||||||
template <class F, class... A>
|
template <class F, class... A>
|
||||||
struct CallAndAddStatusImpl<void, F, A...> {
|
struct CallAndAddStatusImpl<void, F, A...> {
|
||||||
Status operator()(const F& f, A&&... a) {
|
absl::Status operator()(const F& f, A&&... a) {
|
||||||
f(std::forward<A>(a)...);
|
f(std::forward<A>(a)...);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,14 +69,14 @@ StatusBuilder&& StatusBuilder::SetNoLogging() && {
|
||||||
return std::move(SetNoLogging());
|
return std::move(SetNoLogging());
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusBuilder::operator Status() const& {
|
StatusBuilder::operator absl::Status() const& {
|
||||||
if (!stream_ || stream_->str().empty() || no_logging_) {
|
if (!stream_ || stream_->str().empty() || no_logging_) {
|
||||||
return status_;
|
return status_;
|
||||||
}
|
}
|
||||||
return StatusBuilder(*this).JoinMessageToStatus();
|
return StatusBuilder(*this).JoinMessageToStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusBuilder::operator Status() && {
|
StatusBuilder::operator absl::Status() && {
|
||||||
if (!stream_ || stream_->str().empty() || no_logging_) {
|
if (!stream_ || stream_->str().empty() || no_logging_) {
|
||||||
return status_;
|
return status_;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ absl::Status StatusBuilder::JoinMessageToStatus() {
|
||||||
? absl::StrCat(stream_->str(), status_.message())
|
? absl::StrCat(stream_->str(), status_.message())
|
||||||
: absl::StrCat(status_.message(), stream_->str());
|
: absl::StrCat(status_.message(), stream_->str());
|
||||||
}
|
}
|
||||||
return Status(status_.code(), message);
|
return absl::Status(status_.code(), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mediapipe
|
} // namespace mediapipe
|
||||||
|
|
|
@ -92,8 +92,8 @@ class ABSL_MUST_USE_RESULT StatusBuilder {
|
||||||
return std::move(*this << msg);
|
return std::move(*this << msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
operator Status() const&;
|
operator absl::Status() const&;
|
||||||
operator Status() &&;
|
operator absl::Status() &&;
|
||||||
|
|
||||||
absl::Status JoinMessageToStatus();
|
absl::Status JoinMessageToStatus();
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ TEST(Status, OK) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(DeathStatus, CheckOK) {
|
TEST(DeathStatus, CheckOK) {
|
||||||
Status status(absl::StatusCode::kInvalidArgument, "Invalid");
|
absl::Status status(absl::StatusCode::kInvalidArgument, "Invalid");
|
||||||
ASSERT_DEATH(MEDIAPIPE_CHECK_OK(status), "Invalid");
|
ASSERT_DEATH(MEDIAPIPE_CHECK_OK(status), "Invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ const Packet& OutputStreamShard::Header() const {
|
||||||
// binary. This function can be defined in the .cc file because only two
|
// binary. This function can be defined in the .cc file because only two
|
||||||
// versions are ever instantiated, and all call sites are within this .cc file.
|
// versions are ever instantiated, and all call sites are within this .cc file.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
Status OutputStreamShard::AddPacketInternal(T&& packet) {
|
absl::Status OutputStreamShard::AddPacketInternal(T&& packet) {
|
||||||
if (IsClosed()) {
|
if (IsClosed()) {
|
||||||
return mediapipe::FailedPreconditionErrorBuilder(MEDIAPIPE_LOC)
|
return mediapipe::FailedPreconditionErrorBuilder(MEDIAPIPE_LOC)
|
||||||
<< "Packet sent to closed stream \"" << Name() << "\".";
|
<< "Packet sent to closed stream \"" << Name() << "\".";
|
||||||
|
@ -113,7 +113,7 @@ Status OutputStreamShard::AddPacketInternal(T&& packet) {
|
||||||
<< timestamp.DebugString();
|
<< timestamp.DebugString();
|
||||||
}
|
}
|
||||||
|
|
||||||
Status result = output_stream_spec_->packet_type->Validate(packet);
|
absl::Status result = output_stream_spec_->packet_type->Validate(packet);
|
||||||
if (!result.ok()) {
|
if (!result.ok()) {
|
||||||
return StatusBuilder(result, MEDIAPIPE_LOC).SetPrepend() << absl::StrCat(
|
return StatusBuilder(result, MEDIAPIPE_LOC).SetPrepend() << absl::StrCat(
|
||||||
"Packet type mismatch on calculator outputting to stream \"",
|
"Packet type mismatch on calculator outputting to stream \"",
|
||||||
|
@ -132,14 +132,14 @@ Status OutputStreamShard::AddPacketInternal(T&& packet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputStreamShard::AddPacket(const Packet& packet) {
|
void OutputStreamShard::AddPacket(const Packet& packet) {
|
||||||
Status status = AddPacketInternal(packet);
|
absl::Status status = AddPacketInternal(packet);
|
||||||
if (!status.ok()) {
|
if (!status.ok()) {
|
||||||
output_stream_spec_->TriggerErrorCallback(status);
|
output_stream_spec_->TriggerErrorCallback(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputStreamShard::AddPacket(Packet&& packet) {
|
void OutputStreamShard::AddPacket(Packet&& packet) {
|
||||||
Status status = AddPacketInternal(std::move(packet));
|
absl::Status status = AddPacketInternal(std::move(packet));
|
||||||
if (!status.ok()) {
|
if (!status.ok()) {
|
||||||
output_stream_spec_->TriggerErrorCallback(status);
|
output_stream_spec_->TriggerErrorCallback(status);
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,7 @@ const proto_ns::MessageLite& Packet::GetProtoMessageLite() const {
|
||||||
return *proto;
|
return *proto;
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusOr<std::vector<const proto_ns::MessageLite*>>
|
absl::StatusOr<std::vector<const proto_ns::MessageLite*>>
|
||||||
Packet::GetVectorOfProtoMessageLitePtrs() const {
|
Packet::GetVectorOfProtoMessageLitePtrs() const {
|
||||||
if (holder_ == nullptr) {
|
if (holder_ == nullptr) {
|
||||||
return absl::InternalError("Packet is empty.");
|
return absl::InternalError("Packet is empty.");
|
||||||
|
|
|
@ -174,7 +174,7 @@ class Packet {
|
||||||
// object type is a vector of MessageLite data, returns an error otherwise.
|
// object type is a vector of MessageLite data, returns an error otherwise.
|
||||||
// Note: This function is meant to be used internally within the MediaPipe
|
// Note: This function is meant to be used internally within the MediaPipe
|
||||||
// framework only.
|
// framework only.
|
||||||
StatusOr<std::vector<const proto_ns::MessageLite*>>
|
absl::StatusOr<std::vector<const proto_ns::MessageLite*>>
|
||||||
GetVectorOfProtoMessageLitePtrs() const;
|
GetVectorOfProtoMessageLitePtrs() const;
|
||||||
|
|
||||||
// Returns an error if the packet does not contain data of type T.
|
// Returns an error if the packet does not contain data of type T.
|
||||||
|
@ -394,7 +394,7 @@ class HolderBase {
|
||||||
// Returns a vector<MessageLite*> for the data in the holder, if the
|
// Returns a vector<MessageLite*> for the data in the holder, if the
|
||||||
// underlying object is a vector of protocol buffer objects, otherwise,
|
// underlying object is a vector of protocol buffer objects, otherwise,
|
||||||
// returns an error.
|
// returns an error.
|
||||||
virtual StatusOr<std::vector<const proto_ns::MessageLite*>>
|
virtual absl::StatusOr<std::vector<const proto_ns::MessageLite*>>
|
||||||
GetVectorOfProtoMessageLite() const = 0;
|
GetVectorOfProtoMessageLite() const = 0;
|
||||||
|
|
||||||
virtual bool HasForeignOwner() const { return false; }
|
virtual bool HasForeignOwner() const { return false; }
|
||||||
|
@ -424,7 +424,7 @@ struct is_proto_vector<std::vector<ItemT, Allocator>>
|
||||||
// Helper function to create and return a vector of pointers to proto message
|
// Helper function to create and return a vector of pointers to proto message
|
||||||
// elements of the vector passed into the function.
|
// elements of the vector passed into the function.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
StatusOr<std::vector<const proto_ns::MessageLite*>>
|
absl::StatusOr<std::vector<const proto_ns::MessageLite*>>
|
||||||
ConvertToVectorOfProtoMessageLitePtrs(const T* data,
|
ConvertToVectorOfProtoMessageLitePtrs(const T* data,
|
||||||
/*is_proto_vector=*/std::false_type) {
|
/*is_proto_vector=*/std::false_type) {
|
||||||
return absl::InvalidArgumentError(absl::StrCat(
|
return absl::InvalidArgumentError(absl::StrCat(
|
||||||
|
@ -433,7 +433,7 @@ ConvertToVectorOfProtoMessageLitePtrs(const T* data,
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
StatusOr<std::vector<const proto_ns::MessageLite*>>
|
absl::StatusOr<std::vector<const proto_ns::MessageLite*>>
|
||||||
ConvertToVectorOfProtoMessageLitePtrs(const T* data,
|
ConvertToVectorOfProtoMessageLitePtrs(const T* data,
|
||||||
/*is_proto_vector=*/std::true_type) {
|
/*is_proto_vector=*/std::true_type) {
|
||||||
std::vector<const proto_ns::MessageLite*> result;
|
std::vector<const proto_ns::MessageLite*> result;
|
||||||
|
@ -562,7 +562,7 @@ class Holder : public HolderBase {
|
||||||
// Returns a vector<MessageLite*> for the data in the holder, if the
|
// Returns a vector<MessageLite*> for the data in the holder, if the
|
||||||
// underlying object is a vector of protocol buffer objects, otherwise,
|
// underlying object is a vector of protocol buffer objects, otherwise,
|
||||||
// returns an error.
|
// returns an error.
|
||||||
StatusOr<std::vector<const proto_ns::MessageLite*>>
|
absl::StatusOr<std::vector<const proto_ns::MessageLite*>>
|
||||||
GetVectorOfProtoMessageLite() const override {
|
GetVectorOfProtoMessageLite() const override {
|
||||||
return ConvertToVectorOfProtoMessageLitePtrs(ptr_, is_proto_vector<T>());
|
return ConvertToVectorOfProtoMessageLitePtrs(ptr_, is_proto_vector<T>());
|
||||||
}
|
}
|
||||||
|
|
|
@ -496,7 +496,7 @@ TEST(PacketTest, PacketFromSerializedProto) {
|
||||||
original.add_value("foo");
|
original.add_value("foo");
|
||||||
std::string serialized = original.SerializeAsString();
|
std::string serialized = original.SerializeAsString();
|
||||||
|
|
||||||
StatusOr<Packet> maybe_packet = packet_internal::PacketFromDynamicProto(
|
absl::StatusOr<Packet> maybe_packet = packet_internal::PacketFromDynamicProto(
|
||||||
"mediapipe.SimpleProto", serialized);
|
"mediapipe.SimpleProto", serialized);
|
||||||
MP_ASSERT_OK(maybe_packet);
|
MP_ASSERT_OK(maybe_packet);
|
||||||
Packet packet = maybe_packet.value();
|
Packet packet = maybe_packet.value();
|
||||||
|
|
|
@ -670,7 +670,7 @@ absl::Status GraphProfiler::CaptureProfile(
|
||||||
previous_log_end_time_ = end_time;
|
previous_log_end_time_ = end_time;
|
||||||
|
|
||||||
// Record the latest CalculatorProfiles.
|
// Record the latest CalculatorProfiles.
|
||||||
Status status;
|
absl::Status status;
|
||||||
std::vector<CalculatorProfile> profiles;
|
std::vector<CalculatorProfile> profiles;
|
||||||
status.Update(GetCalculatorProfiles(&profiles));
|
status.Update(GetCalculatorProfiles(&profiles));
|
||||||
for (CalculatorProfile& p : profiles) {
|
for (CalculatorProfile& p : profiles) {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
namespace mediapipe {
|
namespace mediapipe {
|
||||||
|
|
||||||
StatusOr<std::string> GetDefaultTraceLogDirectory() {
|
absl::StatusOr<std::string> GetDefaultTraceLogDirectory() {
|
||||||
return std::string("/tmp");
|
return std::string("/tmp");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,11 @@ namespace mediapipe {
|
||||||
// Returns the path to the directory where trace logs will be stored by default.
|
// Returns the path to the directory where trace logs will be stored by default.
|
||||||
// If the function is unable to find an appropriate directory, it returns an
|
// If the function is unable to find an appropriate directory, it returns an
|
||||||
// error.
|
// error.
|
||||||
StatusOr<std::string> GetDefaultTraceLogDirectory();
|
absl::StatusOr<std::string> GetDefaultTraceLogDirectory();
|
||||||
|
|
||||||
// Given a log file path, this function provides an absolute path with which
|
// Given a log file path, this function provides an absolute path with which
|
||||||
// it can be accessed as a file. Enclosing directories are created as needed.
|
// it can be accessed as a file. Enclosing directories are created as needed.
|
||||||
StatusOr<std::string> PathToLogFile(const std::string& path);
|
absl::StatusOr<std::string> PathToLogFile(const std::string& path);
|
||||||
|
|
||||||
} // namespace mediapipe
|
} // namespace mediapipe
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,11 @@
|
||||||
|
|
||||||
namespace mediapipe {
|
namespace mediapipe {
|
||||||
|
|
||||||
StatusOr<std::string> GetDefaultTraceLogDirectory() {
|
absl::StatusOr<std::string> GetDefaultTraceLogDirectory() {
|
||||||
// The path to external storage directory on a device doesn't change when an
|
// The path to external storage directory on a device doesn't change when an
|
||||||
// application is running, hence can be stored as global state.
|
// application is running, hence can be stored as global state.
|
||||||
static const StatusOr<std::string>* kExternalStorageDirectory = [] {
|
static const absl::StatusOr<std::string>* kExternalStorageDirectory = [] {
|
||||||
StatusOr<std::string>* result = new StatusOr<std::string>();
|
absl::StatusOr<std::string>* result = new absl::StatusOr<std::string>();
|
||||||
bool has_jvm = java::HasJavaVM();
|
bool has_jvm = java::HasJavaVM();
|
||||||
if (!has_jvm) {
|
if (!has_jvm) {
|
||||||
*result = absl::InternalError("JavaVM not available.");
|
*result = absl::InternalError("JavaVM not available.");
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace mediapipe {
|
namespace mediapipe {
|
||||||
|
|
||||||
StatusOr<std::string> GetDefaultTraceLogDirectory() {
|
absl::StatusOr<std::string> GetDefaultTraceLogDirectory() {
|
||||||
return "/data/local/tmp";
|
return "/data/local/tmp";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
namespace mediapipe {
|
namespace mediapipe {
|
||||||
|
|
||||||
StatusOr<std::string> GetDefaultTraceLogDirectory() {
|
absl::StatusOr<std::string> GetDefaultTraceLogDirectory() {
|
||||||
// Get the Documents directory. iOS apps can write files to this directory.
|
// Get the Documents directory. iOS apps can write files to this directory.
|
||||||
NSURL* documents_directory_url = [[[NSFileManager defaultManager]
|
NSURL* documents_directory_url = [[[NSFileManager defaultManager]
|
||||||
URLsForDirectory:NSDocumentDirectory
|
URLsForDirectory:NSDocumentDirectory
|
||||||
|
|
|
@ -146,14 +146,14 @@ TEST(Reporter, PrintAllColumns) {
|
||||||
TEST(Reporter, CanReportBadColumns) {
|
TEST(Reporter, CanReportBadColumns) {
|
||||||
auto reporter = loadReporter({"profile_opencv_0.binarypb"});
|
auto reporter = loadReporter({"profile_opencv_0.binarypb"});
|
||||||
auto result = reporter->set_columns({"il[leg]al"});
|
auto result = reporter->set_columns({"il[leg]al"});
|
||||||
EXPECT_EQ(result.code(), StatusCode::kInvalidArgument);
|
EXPECT_EQ(result.code(), absl::StatusCode::kInvalidArgument);
|
||||||
EXPECT_EQ(result.message(), "Column 'il[leg]al' is invalid.\n");
|
EXPECT_EQ(result.message(), "Column 'il[leg]al' is invalid.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Reporter, CanReportNonMatchingColumns) {
|
TEST(Reporter, CanReportNonMatchingColumns) {
|
||||||
auto reporter = loadReporter({"profile_opencv_0.binarypb"});
|
auto reporter = loadReporter({"profile_opencv_0.binarypb"});
|
||||||
auto result = reporter->set_columns({"time_*", "il[leg]al"});
|
auto result = reporter->set_columns({"time_*", "il[leg]al"});
|
||||||
EXPECT_EQ(result.code(), StatusCode::kInvalidArgument);
|
EXPECT_EQ(result.code(), absl::StatusCode::kInvalidArgument);
|
||||||
EXPECT_EQ(result.message(), "Column 'il[leg]al' is invalid.\n");
|
EXPECT_EQ(result.message(), "Column 'il[leg]al' is invalid.\n");
|
||||||
// Should not affect active columns, which is currently still "*".
|
// Should not affect active columns, which is currently still "*".
|
||||||
auto report = reporter->Report();
|
auto report = reporter->Report();
|
||||||
|
@ -164,7 +164,7 @@ TEST(Reporter, CanReportNonMatchingColumns) {
|
||||||
TEST(Reporter, BadPatternsIgnored) {
|
TEST(Reporter, BadPatternsIgnored) {
|
||||||
auto reporter = loadReporter({"profile_opencv_0.binarypb"});
|
auto reporter = loadReporter({"profile_opencv_0.binarypb"});
|
||||||
auto result = reporter->set_columns({"time_mean", "il[leg]al", "^bad"});
|
auto result = reporter->set_columns({"time_mean", "il[leg]al", "^bad"});
|
||||||
EXPECT_EQ(result.code(), StatusCode::kInvalidArgument);
|
EXPECT_EQ(result.code(), absl::StatusCode::kInvalidArgument);
|
||||||
// Can report multiple errors at once, separated by newlines.
|
// Can report multiple errors at once, separated by newlines.
|
||||||
EXPECT_EQ(result.message(),
|
EXPECT_EQ(result.message(),
|
||||||
"Column 'il[leg]al' is invalid.\n"
|
"Column 'il[leg]al' is invalid.\n"
|
||||||
|
@ -177,7 +177,7 @@ TEST(Reporter, BadPatternsIgnored) {
|
||||||
TEST(Reporter, NonMatchingColumnsIgnored) {
|
TEST(Reporter, NonMatchingColumnsIgnored) {
|
||||||
auto reporter = loadReporter({"profile_opencv_0.binarypb"});
|
auto reporter = loadReporter({"profile_opencv_0.binarypb"});
|
||||||
auto result = reporter->set_columns({"koopa*"});
|
auto result = reporter->set_columns({"koopa*"});
|
||||||
EXPECT_EQ(result.code(), StatusCode::kInvalidArgument);
|
EXPECT_EQ(result.code(), absl::StatusCode::kInvalidArgument);
|
||||||
EXPECT_EQ(result.message(), "Column 'koopa*' did not match any columns.\n");
|
EXPECT_EQ(result.message(), "Column 'koopa*' did not match any columns.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -268,7 +268,7 @@ FieldData SerializeProtobufAny(const FieldData& data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the field index of an extension type in a repeated field.
|
// Returns the field index of an extension type in a repeated field.
|
||||||
StatusOr<int> FindExtensionIndex(const FieldData& message_data,
|
absl::StatusOr<int> FindExtensionIndex(const FieldData& message_data,
|
||||||
FieldPathEntry* entry) {
|
FieldPathEntry* entry) {
|
||||||
if (entry->field == nullptr || !IsProtobufAny(entry->field)) {
|
if (entry->field == nullptr || !IsProtobufAny(entry->field)) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -447,7 +447,7 @@ absl::Status GetNodeOptions(const FieldData& message_data,
|
||||||
std::string parent_type = options_field_util::ParseTypeUrl(
|
std::string parent_type = options_field_util::ParseTypeUrl(
|
||||||
std::string(message_data.message_value().type_url()));
|
std::string(message_data.message_value().type_url()));
|
||||||
FieldPath path;
|
FieldPath path;
|
||||||
Status status;
|
absl::Status status;
|
||||||
path = GetExtensionPath(parent_type, extension_type, kOptionsName, false);
|
path = GetExtensionPath(parent_type, extension_type, kOptionsName, false);
|
||||||
status = GetField(path, message_data, result);
|
status = GetField(path, message_data, result);
|
||||||
if (status.ok()) {
|
if (status.ok()) {
|
||||||
|
@ -467,7 +467,7 @@ absl::Status GetGraphOptions(const FieldData& message_data,
|
||||||
std::string parent_type = options_field_util::ParseTypeUrl(
|
std::string parent_type = options_field_util::ParseTypeUrl(
|
||||||
std::string(message_data.message_value().type_url()));
|
std::string(message_data.message_value().type_url()));
|
||||||
FieldPath path;
|
FieldPath path;
|
||||||
Status status;
|
absl::Status status;
|
||||||
path = GetExtensionPath(parent_type, extension_type, kOptionsName, false);
|
path = GetExtensionPath(parent_type, extension_type, kOptionsName, false);
|
||||||
status = GetField(path, message_data, result);
|
status = GetField(path, message_data, result);
|
||||||
if (status.ok()) {
|
if (status.ok()) {
|
||||||
|
|
|
@ -59,7 +59,7 @@ std::string MessageType(FieldData message) {
|
||||||
// Copy literal options from graph_options to node_options.
|
// Copy literal options from graph_options to node_options.
|
||||||
absl::Status CopyLiteralOptions(CalculatorGraphConfig::Node parent_node,
|
absl::Status CopyLiteralOptions(CalculatorGraphConfig::Node parent_node,
|
||||||
CalculatorGraphConfig* config) {
|
CalculatorGraphConfig* config) {
|
||||||
Status status;
|
absl::Status status;
|
||||||
FieldData graph_data = options_field_util::AsFieldData(*config);
|
FieldData graph_data = options_field_util::AsFieldData(*config);
|
||||||
FieldData parent_data = options_field_util::AsFieldData(parent_node);
|
FieldData parent_data = options_field_util::AsFieldData(parent_node);
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ absl::Status CopyLiteralOptions(CalculatorGraphConfig::Node parent_node,
|
||||||
absl::Status DefineGraphOptions(const CalculatorGraphConfig::Node& parent_node,
|
absl::Status DefineGraphOptions(const CalculatorGraphConfig::Node& parent_node,
|
||||||
CalculatorGraphConfig* config) {
|
CalculatorGraphConfig* config) {
|
||||||
MP_RETURN_IF_ERROR(CopyLiteralOptions(parent_node, config));
|
MP_RETURN_IF_ERROR(CopyLiteralOptions(parent_node, config));
|
||||||
return mediapipe::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace tool
|
} // namespace tool
|
||||||
|
|
|
@ -37,15 +37,15 @@ using FieldType = ::mediapipe::proto_ns::FieldDescriptorProto::Type;
|
||||||
class NightLightCalculator : public CalculatorBase {
|
class NightLightCalculator : public CalculatorBase {
|
||||||
public:
|
public:
|
||||||
static absl::Status GetContract(CalculatorContract* cc) {
|
static absl::Status GetContract(CalculatorContract* cc) {
|
||||||
return mediapipe::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::Status Open(CalculatorContext* cc) final {
|
absl::Status Open(CalculatorContext* cc) final {
|
||||||
return mediapipe::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::Status Process(CalculatorContext* cc) final {
|
absl::Status Process(CalculatorContext* cc) final {
|
||||||
return mediapipe::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -58,8 +58,8 @@ absl::Status CombinedStatus(const std::string& general_comment,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (error_code == StatusCode::kOk) return OkStatus();
|
if (error_code == absl::StatusCode::kOk) return absl::OkStatus();
|
||||||
Status combined = absl::Status(
|
absl::Status combined = absl::Status(
|
||||||
error_code,
|
error_code,
|
||||||
absl::StrCat(general_comment, "\n", absl::StrJoin(errors, "\n")));
|
absl::StrCat(general_comment, "\n", absl::StrJoin(errors, "\n")));
|
||||||
return combined;
|
return combined;
|
||||||
|
|
|
@ -149,7 +149,7 @@ absl::Status GpuResources::PrepareGpuNode(CalculatorNode* node) {
|
||||||
context->SetProfilingContext(
|
context->SetProfilingContext(
|
||||||
node->GetCalculatorState().GetSharedProfilingContext());
|
node->GetCalculatorState().GetSharedProfilingContext());
|
||||||
|
|
||||||
return OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: expose and use an actual ID instead of using the
|
// TODO: expose and use an actual ID instead of using the
|
||||||
|
|
|
@ -56,12 +56,12 @@ Detection TensorToDetection(
|
||||||
return detection;
|
return detection;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status TensorsToDetections(const ::tensorflow::Tensor& num_detections,
|
absl::Status TensorsToDetections(const ::tensorflow::Tensor& num_detections,
|
||||||
const ::tensorflow::Tensor& boxes,
|
const ::tensorflow::Tensor& boxes,
|
||||||
const ::tensorflow::Tensor& scores,
|
const ::tensorflow::Tensor& scores,
|
||||||
const ::tensorflow::Tensor& classes,
|
const ::tensorflow::Tensor& classes,
|
||||||
const std::map<int, std::string>& label_map,
|
const std::map<int, std::string>& label_map,
|
||||||
std::vector<Detection>* detections) {
|
std::vector<Detection>* detections) {
|
||||||
const ::tensorflow::Tensor empty_keypoints = ::tensorflow::Tensor(
|
const ::tensorflow::Tensor empty_keypoints = ::tensorflow::Tensor(
|
||||||
::tensorflow::DT_FLOAT, ::tensorflow::TensorShape({0, 0, 0}));
|
::tensorflow::DT_FLOAT, ::tensorflow::TensorShape({0, 0, 0}));
|
||||||
const ::tensorflow::Tensor empty_masks = ::tensorflow::Tensor(
|
const ::tensorflow::Tensor empty_masks = ::tensorflow::Tensor(
|
||||||
|
@ -71,15 +71,15 @@ Status TensorsToDetections(const ::tensorflow::Tensor& num_detections,
|
||||||
/*mask_threshold=*/0.0f, label_map, detections);
|
/*mask_threshold=*/0.0f, label_map, detections);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status TensorsToDetections(const ::tensorflow::Tensor& num_detections,
|
absl::Status TensorsToDetections(const ::tensorflow::Tensor& num_detections,
|
||||||
const ::tensorflow::Tensor& boxes,
|
const ::tensorflow::Tensor& boxes,
|
||||||
const ::tensorflow::Tensor& scores,
|
const ::tensorflow::Tensor& scores,
|
||||||
const ::tensorflow::Tensor& classes,
|
const ::tensorflow::Tensor& classes,
|
||||||
const ::tensorflow::Tensor& keypoints,
|
const ::tensorflow::Tensor& keypoints,
|
||||||
const ::tensorflow::Tensor& masks,
|
const ::tensorflow::Tensor& masks,
|
||||||
float mask_threshold,
|
float mask_threshold,
|
||||||
const std::map<int, std::string>& label_map,
|
const std::map<int, std::string>& label_map,
|
||||||
std::vector<Detection>* detections) {
|
std::vector<Detection>* detections) {
|
||||||
int num_boxes = -1;
|
int num_boxes = -1;
|
||||||
if (num_detections.dims() > 0 && num_detections.dim_size(0) != 0) {
|
if (num_detections.dims() > 0 && num_detections.dim_size(0) != 0) {
|
||||||
if (num_detections.dtype() != tf::DT_INT32) {
|
if (num_detections.dtype() != tf::DT_INT32) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user