18 #include "scanner/util/common.h" 19 #include "scanner/util/profiler.h" 41 : name_(name), variadic_inputs_(
false), can_stencil_(
false),
42 has_bounded_state_(
false), warmup_(0), has_unbounded_state_(
false) {}
45 if (input_columns_.size() > 0) {
46 LOG(FATAL) <<
"Op " << name_ <<
" cannot have both fixed and variadic " 49 variadic_inputs_ =
true;
54 ColumnType type = ColumnType::Bytes) {
55 if (variadic_inputs_) {
56 LOG(FATAL) <<
"Op " << name_ <<
" cannot have both fixed and variadic " 59 input_columns_.push_back(std::make_tuple(name, type));
63 OpBuilder& frame_input(
const std::string& name) {
64 return input(name, ColumnType::Video);
67 OpBuilder& output(
const std::string& name,
68 ColumnType type = ColumnType::Bytes,
69 std::string type_name =
"") {
70 output_columns_.push_back(std::make_tuple(name, type, type_name));
74 OpBuilder& frame_output(
const std::string& name) {
75 return output(name, ColumnType::Video);
78 OpBuilder& stencil(
const std::vector<int>& stencil = {0}) {
80 preferred_stencil_ = stencil;
84 OpBuilder& bounded_state(i32 warmup = 0) {
85 if (has_unbounded_state_) {
86 LOG(FATAL) <<
"Attempted to specify Op " << name_
87 <<
" has bounded state but Op was already declared to have " 90 has_bounded_state_ =
true;
96 if (has_bounded_state_) {
97 LOG(FATAL) <<
"Attempted to specify Op " << name_
98 <<
" has unbounded state but Op was already declared to have " 101 has_unbounded_state_ =
true;
105 OpBuilder& protobuf_name(std::string protobuf_name) {
106 protobuf_name_ = protobuf_name;
110 OpBuilder& stream_protobuf_name(std::string protobuf_name) {
111 stream_protobuf_name_ = protobuf_name;
117 bool variadic_inputs_;
118 std::vector<std::tuple<std::string, ColumnType>> input_columns_;
119 std::vector<std::tuple<std::string, ColumnType, std::string>> output_columns_;
121 std::vector<int> preferred_stencil_ = {0};
122 bool has_bounded_state_;
124 bool has_unbounded_state_;
125 std::string protobuf_name_;
126 std::string stream_protobuf_name_;
130 #define REGISTER_OP(name__) REGISTER_OP_HELPER(__COUNTER__, name__) 132 #define REGISTER_OP_HELPER(uid__, name__) REGISTER_OP_UID(uid__, name__) 134 #define REGISTER_OP_UID(uid__, name__) \ 135 static ::scanner::internal::OpRegistration op_registration_##uid__ \ 136 __attribute__((unused)) = ::scanner::internal::OpBuilder(#name__)
Definition: database.cpp:36