Ignore:
Timestamp:
Feb 25, 2018, 12:38:51 PM (14 months ago)
Author:
cameron
Message:

Grapheme Cluster Break kernel

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/grep_kernel.cpp

    r5872 r5881  
    137137    Var * const required = getOutputStreamVar("nonFinal");
    138138    pb.createAssign(pb.createExtract(required, pb.getInteger(0)), nonFinal);
    139     pb.createAssign(pb.createExtract(getOutputStreamVar("linebreak"), pb.getInteger(0)), pb.createOr(LineBreak, unterminatedLineAtEOF, "EOL"));
     139    pb.createAssign(pb.createExtract(getOutputStreamVar("UnicodeLB"), pb.getInteger(0)), pb.createOr(LineBreak, unterminatedLineAtEOF, "EOL"));
    140140}
    141141
     
    146146// output
    147147{Binding{kb->getStreamSetTy(1), "nonFinal", FixedRate()},
    148  Binding{kb->getStreamSetTy(1), "linebreak", FixedRate(), Add1()}}) {
     148 Binding{kb->getStreamSetTy(1), "UnicodeLB", FixedRate(), Add1()}}) {
    149149
    150150}
     
    194194// Helper to compute stream set inputs to pass into PabloKernel constructor.
    195195inline std::vector<Binding> icGrepInputs(const std::unique_ptr<kernel::KernelBuilder> & b,
     196                                         const std::vector<std::string> & externals,
    196197                                         const std::vector<cc::Alphabet *> & alphabets) {
    197198    std::vector<Binding> streamSetInputs = {
    198199        Binding{b->getStreamSetTy(8), "basis"},
    199         Binding{b->getStreamSetTy(1, 1), "linebreak"},
    200         Binding{b->getStreamSetTy(1, 1), "required"}
    201200    };
     201    for (auto & e : externals) {
     202        streamSetInputs.push_back(Binding{b->getStreamSetTy(1, 1), e});
     203    }
    202204    for (const auto & alphabet : alphabets) {
    203205        unsigned basis_size = cast<cc::MultiplexedAlphabet>(alphabet)->getMultiplexedCCs().size();
     
    207209}
    208210
    209 ICGrepKernel::ICGrepKernel(const std::unique_ptr<kernel::KernelBuilder> & b, RE * const re, std::vector<cc::Alphabet *> alphabets)
     211ICGrepKernel::ICGrepKernel(const std::unique_ptr<kernel::KernelBuilder> & b, RE * const re, std::vector<std::string> externals, std::vector<cc::Alphabet *> alphabets)
    210212: ICGrepSignature(re)
    211213, PabloKernel(b, "ic" + sha1sum(mSignature),
    212214// inputs
    213 icGrepInputs(b, alphabets),
     215icGrepInputs(b, externals, alphabets),
    214216// output
    215217{Binding{b->getStreamSetTy(1, 1), "matches", FixedRate(), Add1()}})
     218, mExternals(externals)
    216219, mAlphabets(alphabets) {
    217 
    218220}
    219221
     
    226228    cc::Parabix_CC_Compiler ccc(getEntryScope(), getInputStreamSet("basis"));
    227229    RE_Compiler re_compiler(this, ccc);
     230    for (auto & e : mExternals) {
     231        re_compiler.addPrecompiled(e, pb.createExtract(getInputStreamVar(e), pb.getInteger(0)));
     232    }
    228233    for (auto a : mAlphabets) {
    229234        auto mpx_basis = getInputStreamSet(a->getName() + "_basis");
Note: See TracChangeset for help on using the changeset viewer.