-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Closed
Description
Some operators have relatively complicated initialization to parse configurations. For example, in ChunkEvalutor, the initialization is as following:
virtual void init(const EvaluatorConfig& config) {
Evaluator::init(config);
if (config.chunk_scheme() == "IOB") {
numTagTypes_ = 2;
tagBegin_ = 0;
tagInside_ = 1;
tagEnd_ = -1;
tagSingle_ = -1;
} else if (config.chunk_scheme() == "IOE") {
numTagTypes_ = 2;
tagBegin_ = -1;
tagInside_ = 0;
tagEnd_ = 1;
tagSingle_ = -1;
} else if (config.chunk_scheme() == "IOBES") {
numTagTypes_ = 4;
tagBegin_ = 0;
tagInside_ = 1;
tagEnd_ = 2;
tagSingle_ = 3;
} else if (config.chunk_scheme() == "plain") {
numTagTypes_ = 1;
tagBegin_ = -1;
tagInside_ = -1;
tagEnd_ = -1;
tagSingle_ = -1;
} else {
LOG(FATAL) << "Unknown chunk scheme: " << config.chunk_scheme();
}
CHECK(config.has_num_chunk_types()) << "Missing num_chunk_types in config";
otherChunkType_ = numChunkTypes_ = config.num_chunk_types();
// the chunks of types in excludedChunkTypes_ will not be counted
auto& tmp = config.excluded_chunk_types();
excludedChunkTypes_.insert(tmp.begin(), tmp.end());
}Some fields like tagBegin_, tagInside_ need to be initialized according to the scheme configuration and will be used when computing. Is there any way to initialize by configurations in OpKernel and use the initialized values in compute rather than put the initialization in compute.
Metadata
Metadata
Assignees
Labels
No labels