Project import generated by Copybara.

GitOrigin-RevId: bb059a0721c92e8154d33ce8057b3915a25b3d7d
This commit is contained in:
MediaPipe Team
2021-12-13 15:56:02 -08:00
committed by jqtang
parent cf101e62a9
commit e6c19885c6
96 changed files with 554 additions and 486 deletions
+1 -5
View File
@@ -162,7 +162,6 @@ cc_test(
visibility = ["//mediapipe/framework:mediapipe_internal"],
deps = [
":executor_util",
"//mediapipe/framework/deps:message_matchers",
"//mediapipe/framework/port:gtest_main",
"//mediapipe/framework/port:parse_text_proto",
],
@@ -302,7 +301,6 @@ mediapipe_cc_test(
"//mediapipe/framework:calculator_framework",
"//mediapipe/framework:calculator_runner",
"//mediapipe/framework:validated_graph_config",
"//mediapipe/framework/deps:message_matchers",
"//mediapipe/framework/port:gtest_main",
"//mediapipe/framework/port:parse_text_proto",
"//mediapipe/framework/port:status",
@@ -449,6 +447,7 @@ cc_library(
"//mediapipe/framework/port:status",
"//mediapipe/framework/port:statusor",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/container:btree",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/strings",
],
@@ -613,7 +612,6 @@ cc_test(
deps = [
":validate_name",
"//mediapipe/framework:calculator_cc_proto",
"//mediapipe/framework/deps:message_matchers",
"//mediapipe/framework/port:gtest_main",
"@com_google_absl//absl/strings",
],
@@ -736,7 +734,6 @@ cc_test(
"//mediapipe/framework:packet_type",
"//mediapipe/framework:status_handler",
"//mediapipe/framework:subgraph",
"//mediapipe/framework/deps:message_matchers",
"//mediapipe/framework/port:gtest_main",
"//mediapipe/framework/port:logging",
"//mediapipe/framework/port:parse_text_proto",
@@ -885,7 +882,6 @@ cc_test(
"//mediapipe/framework:calculator_framework",
"//mediapipe/framework:subgraph",
"//mediapipe/framework:test_calculators",
"//mediapipe/framework/deps:message_matchers",
"//mediapipe/framework/port:gtest_main",
"//mediapipe/framework/port:logging",
"//mediapipe/framework/port:parse_text_proto",
@@ -14,7 +14,6 @@
#include "mediapipe/framework/tool/executor_util.h"
#include "mediapipe/framework/deps/message_matchers.h"
#include "mediapipe/framework/port/gmock.h"
#include "mediapipe/framework/port/gtest.h"
#include "mediapipe/framework/port/parse_text_proto.h"
@@ -17,7 +17,7 @@
#include "absl/strings/string_view.h"
#include "mediapipe/framework/calculator_framework.h"
#include "mediapipe/framework/deps/message_matchers.h"
#include "mediapipe/framework/port/gmock.h"
#include "mediapipe/framework/port/gtest.h"
#include "mediapipe/framework/port/parse_text_proto.h"
#include "mediapipe/framework/port/status_matchers.h"
@@ -18,7 +18,6 @@
#include "absl/strings/str_cat.h"
#include "mediapipe/framework/calculator.pb.h"
#include "mediapipe/framework/calculator_framework.h"
#include "mediapipe/framework/deps/message_matchers.h"
#include "mediapipe/framework/graph_service_manager.h"
#include "mediapipe/framework/packet.h"
#include "mediapipe/framework/packet_set.h"
@@ -15,7 +15,6 @@
#include "absl/strings/str_replace.h"
#include "mediapipe/framework/calculator.pb.h"
#include "mediapipe/framework/calculator_framework.h"
#include "mediapipe/framework/deps/message_matchers.h"
#include "mediapipe/framework/port/gmock.h"
#include "mediapipe/framework/port/gtest.h"
#include "mediapipe/framework/port/logging.h"
+7 -10
View File
@@ -215,19 +215,16 @@ std::string TagMap::ShortDebugString() const {
return output;
}
bool TagMap::HasTag(const std::string& tag) const {
return mapping_.find(tag) != mapping_.end();
bool TagMap::HasTag(const absl::string_view tag) const {
return mapping_.contains(tag);
}
int TagMap::NumEntries(const std::string& tag) const {
int TagMap::NumEntries(const absl::string_view tag) const {
const auto it = mapping_.find(tag);
if (it == mapping_.end()) {
return 0;
}
return it->second.count;
return it != mapping_.end() ? it->second.count : 0;
}
CollectionItemId TagMap::GetId(const std::string& tag, int index) const {
CollectionItemId TagMap::GetId(const absl::string_view tag, int index) const {
const auto it = mapping_.find(tag);
if (it == mapping_.end()) {
return CollectionItemId::GetInvalid();
@@ -248,11 +245,11 @@ std::pair<std::string, int> TagMap::TagAndIndexFromId(
return {"", -1};
}
CollectionItemId TagMap::BeginId(const std::string& tag) const {
CollectionItemId TagMap::BeginId(const absl::string_view tag) const {
return GetId(tag, 0);
}
CollectionItemId TagMap::EndId(const std::string& tag) const {
CollectionItemId TagMap::EndId(const absl::string_view tag) const {
const auto it = mapping_.find(tag);
if (it == mapping_.end()) {
return CollectionItemId::GetInvalid();
+11 -7
View File
@@ -20,6 +20,8 @@
#include <vector>
#include "absl/base/macros.h"
#include "absl/container/btree_map.h"
#include "absl/strings/string_view.h"
#include "mediapipe/framework/collection_item_id.h"
#include "mediapipe/framework/port/canonical_errors.h"
#include "mediapipe/framework/port/core_proto_inc.h"
@@ -72,7 +74,9 @@ class TagMap {
}
// Returns a reference to the mapping from tag to tag data.
const std::map<std::string, TagData>& Mapping() const { return mapping_; }
const absl::btree_map<std::string, TagData>& Mapping() const {
return mapping_;
}
// Returns the vector of names (indexed by CollectionItemId).
const std::vector<std::string>& Names() const { return names_; }
@@ -91,16 +95,16 @@ class TagMap {
// The following functions are directly utilized by collection.h see
// that file for comments.
bool HasTag(const std::string& tag) const;
bool HasTag(absl::string_view tag) const;
int NumEntries() const { return num_entries_; }
int NumEntries(const std::string& tag) const;
CollectionItemId GetId(const std::string& tag, int index) const;
int NumEntries(absl::string_view tag) const;
CollectionItemId GetId(absl::string_view tag, int index) const;
std::set<std::string> GetTags() const;
std::pair<std::string, int> TagAndIndexFromId(CollectionItemId id) const;
CollectionItemId BeginId() const { return CollectionItemId(0); }
CollectionItemId EndId() const { return CollectionItemId(num_entries_); }
CollectionItemId BeginId(const std::string& tag) const;
CollectionItemId EndId(const std::string& tag) const;
CollectionItemId BeginId(absl::string_view tag) const;
CollectionItemId EndId(absl::string_view tag) const;
private:
// Use static factory function TagMap::Create().
@@ -122,7 +126,7 @@ class TagMap {
// The total number of entries under all tags.
int num_entries_;
// Mapping from tag to tag data.
std::map<std::string, TagData> mapping_;
absl::btree_map<std::string, TagData> mapping_;
// The names of the data (indexed by CollectionItemId).
std::vector<std::string> names_;
};
+6 -5
View File
@@ -37,7 +37,6 @@
#include "mediapipe/framework/tool/proto_util_lite.h"
using mediapipe::proto_ns::Descriptor;
using mediapipe::proto_ns::DescriptorPool;
using mediapipe::proto_ns::DynamicMessageFactory;
using mediapipe::proto_ns::EnumDescriptor;
using mediapipe::proto_ns::EnumValueDescriptor;
@@ -1666,7 +1665,6 @@ TemplateParser::Parser::Parser()
allow_partial_(false),
allow_case_insensitive_field_(false),
allow_unknown_field_(false),
allow_unknown_extension_(true),
allow_unknown_enum_(false),
allow_field_number_(false),
allow_relaxed_whitespace_(false),
@@ -1685,10 +1683,11 @@ bool TemplateParser::Parser::Parse(io::ZeroCopyInputStream* input,
: ParserImpl::FORBID_SINGULAR_OVERWRITES;
int recursion_limit = std::numeric_limits<int>::max();
bool allow_unknown_extension = false;
MediaPipeParserImpl parser(
output->GetDescriptor(), input, error_collector_, finder_,
parse_info_tree_, overwrites_policy, allow_case_insensitive_field_,
allow_unknown_field_, allow_unknown_extension_, allow_unknown_enum_,
allow_unknown_field_, allow_unknown_extension, allow_unknown_enum_,
allow_field_number_, allow_relaxed_whitespace_, allow_partial_,
recursion_limit);
return MergeUsingImpl(input, output, &parser);
@@ -1703,11 +1702,12 @@ bool TemplateParser::Parser::ParseFromString(const std::string& input,
bool TemplateParser::Parser::Merge(io::ZeroCopyInputStream* input,
Message* output) {
int recursion_limit = std::numeric_limits<int>::max();
bool allow_unknown_extension = false;
MediaPipeParserImpl parser(
output->GetDescriptor(), input, error_collector_, finder_,
parse_info_tree_, ParserImpl::ALLOW_SINGULAR_OVERWRITES,
allow_case_insensitive_field_, allow_unknown_field_,
allow_unknown_extension_, allow_unknown_enum_, allow_field_number_,
allow_unknown_extension, allow_unknown_enum_, allow_field_number_,
allow_relaxed_whitespace_, allow_partial_, recursion_limit);
return MergeUsingImpl(input, output, &parser);
}
@@ -1737,11 +1737,12 @@ bool TemplateParser::Parser::ParseFieldValueFromString(
const std::string& input, const FieldDescriptor* field, Message* output) {
io::ArrayInputStream input_stream(input.data(), input.size());
int recursion_limit = std::numeric_limits<int>::max();
bool allow_unknown_extension = false;
ParserImpl parser(
output->GetDescriptor(), &input_stream, error_collector_, finder_,
parse_info_tree_, ParserImpl::ALLOW_SINGULAR_OVERWRITES,
allow_case_insensitive_field_, allow_unknown_field_,
allow_unknown_extension_, allow_unknown_enum_, allow_field_number_,
allow_unknown_extension, allow_unknown_enum_, allow_field_number_,
allow_relaxed_whitespace_, allow_partial_, recursion_limit);
return parser.ParseField(field, output);
}
@@ -37,10 +37,6 @@ class TemplateParser {
Parser();
~Parser();
void set_allow_unknown_extension(bool allow_unknown_extension) {
allow_unknown_extension_ = allow_unknown_extension;
}
// Like TextFormat::Parse().
bool Parse(proto_ns::io::ZeroCopyInputStream* input,
proto_ns::Message* output);
@@ -103,7 +99,6 @@ class TemplateParser {
bool allow_partial_;
bool allow_case_insensitive_field_;
bool allow_unknown_field_;
bool allow_unknown_extension_;
bool allow_unknown_enum_;
bool allow_field_number_;
bool allow_relaxed_whitespace_;
+1 -1
View File
@@ -56,7 +56,7 @@ absl::Status GetTagAndNameInfo(
}
info->names.push_back(name);
}
if (info->tags.size() > 0 && info->names.size() != info->tags.size()) {
if (!info->tags.empty() && info->names.size() != info->tags.size()) {
info->tags.clear();
info->names.clear();
return absl::InvalidArgumentError(absl::StrCat(
@@ -17,7 +17,6 @@
#include "absl/strings/str_cat.h"
#include "absl/strings/substitute.h"
#include "mediapipe/framework/calculator.pb.h"
#include "mediapipe/framework/deps/message_matchers.h"
#include "mediapipe/framework/port/gmock.h"
#include "mediapipe/framework/port/gtest.h"
#include "mediapipe/framework/port/status_matchers.h"