예제 #1
0
    def sample(self, model: clgen.Model) -> None:
        """
        Sample CLgen model.

        Parameters
        ----------
        model : clgen.Model
            CLgen model.
        """
        cache = self.cache(model)

        # create samples database if it doesn't exist
        if not cache.get("kernels.db"):
            tmp_kernels_db = cache.keypath("kernels.tmp.db")
            dbutil.create_db(tmp_kernels_db)
            cache["kernels.db"] = tmp_kernels_db

        # producer-consumer queue
        queue = Queue(maxsize=128)

        log.info("sampling", self)

        sampler = SampleProducer(model, self.start_text, queue,
                                 **self.kernel_opts)
        sampler.start()

        consumer = SampleConsumer(cache["kernels.db"], sampler, self, cache,
                                  queue, **self.sampler_opts)
        consumer.start()

        sampler.join()
        consumer.join()

        clgen.explore(cache["kernels.db"])
예제 #2
0
def test_explore():
    c = clgen.Corpus.from_json({
        "language":
        "opencl",
        "path":
        tests.data_path("tiny", "corpus", exists=False)
    })
    clgen.explore(c.contentcache["kernels.db"])
예제 #3
0
파일: cli.py 프로젝트: yasutakawada/clgen
 def _main(db_file: BinaryIO):
     clgen.explore(db_file.name)
예제 #4
0
def test_explore_gh():
    db_path = tests.archive("tiny-gh.db")
    assert (fs.exists(db_path))

    clgen.explore(db_path)