class SingleOpResolver : public OpResolver {
public:
SingleOpResolver(const BuiltinOperator op, TfLiteRegistration* registration)
- : op_(op), registration_(registration) {
- registration_->builtin_code = op;
- }
+ : op_(op), registration_(registration) {}
TfLiteRegistration* FindOp(BuiltinOperator op) const override {
if (op == op_) {
return registration_;
builtin_code);
status = kTfLiteError;
} else if (builtin_code != BuiltinOperator_CUSTOM) {
+ flatbuffer_op_index_to_registration_types_.push_back(builtin_code);
registration = op_resolver_.FindOp(builtin_code);
if (registration == nullptr) {
error_reporter_->Report("Didn't find op for builtin opcode '%s'\n",
} else {
const char* name = opcode->custom_code()->c_str();
registration = op_resolver_.FindOp(name);
+ flatbuffer_op_index_to_registration_types_.push_back(
+ BuiltinOperator_CUSTOM);
if (registration == nullptr) {
error_reporter_->Report("Didn't find custom op for name '%s'\n", name);
status = kTfLiteError;
continue;
}
- BuiltinOperator op_type = static_cast<BuiltinOperator>(reg->builtin_code);
+ auto op_type =
+ flatbuffer_op_index_to_registration_types_[op->opcode_index()];
if (op_type != BuiltinOperator_CUSTOM && op->custom_options()) {
error_reporter_->Report(
"Found builtin operator %s with custom options.\n",
ErrorReporter* error_reporter_;
std::vector<TfLiteRegistration*> flatbuffer_op_index_to_registration_;
+ std::vector<BuiltinOperator> flatbuffer_op_index_to_registration_types_;
const Allocation* allocation_ = nullptr;
};