• 大小: 23.11MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-06-28
  • 语言: 其他
  • 标签: 咖啡2  Caffe2  

资源简介

咖啡2 Caffe2 Github20170803

资源截图

代码片段和文件信息

#!/usr/bin/env python

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from hypothesis import given
import hypothesis.strategies as st
from multiprocessing import Process Queue

import numpy as np
import os
import pickle
import tempfile
import shutil

from caffe2.python import core workspace dyndep
import caffe2.python.hypothesis_test_util as hu

dyndep.InitOpsLibrary(“@/caffe2/caffe2/distributed:file_store_handler_ops“)
dyndep.InitOpsLibrary(“@/caffe2/caffe2/distributed:redis_store_handler_ops“)
dyndep.InitOpsLibrary(“@/caffe2/caffe2/distributed:store_ops“)
dyndep.InitOpsLibrary(“@/caffe2/caffe2/contrib/gloo:gloo_ops“)
dyndep.InitOpsLibrary(“@/caffe2/caffe2/contrib/gloo:gloo_ops_gpu“)

op_engine = ‘GLOO‘


class TemporaryDirectory:
    def __enter__(self):
        self.tmpdir = tempfile.mkdtemp()
        return self.tmpdir

    def __exit__(self type value traceback):
        shutil.rmtree(self.tmpdir)


class TestCase(hu.HypothesisTestCase):
    test_counter = 0
    sync_counter = 0

    def run_test_locally(self fn device_option=None **kwargs):
        # Queue for assertion errors on subprocesses
        queue = Queue()

        # Capture any exception thrown by the subprocess
        def run_fn(*args **kwargs):
            try:
                with core.DeviceScope(device_option):
                    fn(*args **kwargs)
                    workspace.ResetWorkspace()
            except Exception as ex:
                queue.put(ex)

        # Start N processes in the background
        procs = []
        for i in range(kwargs[‘comm_size‘]):
            kwargs[‘comm_rank‘] = i
            proc = Process(
                target=run_fn
                kwargs=kwargs)
            proc.start()
            procs.append(proc)

        # Test complete join background processes
        while len(procs) > 0:
            proc = procs.pop(0)
            while proc.is_alive():
                proc.join(1)

                # Raise exception if we find any.
                # Note that the following is executed ALSO after
                # the last process was joined so if ANY exception
                # was raised it will be re-raised here.
                if not queue.empty():
                    raise queue.get()

    def run_test_distributed(self fn device_option=None **kwargs):
        comm_rank = os.getenv(‘COMM_RANK‘)
        self.assertIsNotNone(comm_rank)
        comm_size = os.getenv(‘COMM_SIZE‘)
        self.assertIsNotNone(comm_size)
        kwargs[‘comm_rank‘] = int(comm_rank)
        kwargs[‘comm_size‘] = int(comm_size)
        with core.DeviceScope(device_option):
            fn(**kwargs)
            workspace.ResetWorkspace()

    def create_common_world(self comm_rank comm_size tmpdir=None):
        store_handler = “store_handler“

        # If REDIS_HOST is set use RedisStoreHandler for rendezvous.
        redis_host = os

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-07-24 00:21  caffe2-master\
     文件      101792  2017-07-24 00:21  caffe2-master\.Doxyfile
     文件      108213  2017-07-24 00:21  caffe2-master\.Doxyfile-c
     文件      107563  2017-07-24 00:21  caffe2-master\.Doxyfile-python
     文件         934  2017-07-24 00:21  caffe2-master\.gitignore
     文件        1964  2017-07-24 00:21  caffe2-master\.gitmodules
     文件         705  2017-07-24 00:21  caffe2-master\.travis.yml
     目录           0  2017-07-24 00:21  caffe2-master\.travis\
     文件        1206  2017-07-24 00:21  caffe2-master\.travis\build.sh
     文件        7093  2017-07-24 00:21  caffe2-master\.travis\install.sh
     文件        1024  2017-07-24 00:21  caffe2-master\.travis\setup.sh
     文件         457  2017-07-24 00:21  caffe2-master\.travis\test.sh
     文件        3916  2017-07-24 00:21  caffe2-master\CMakeLists.txt
     文件        5790  2017-07-24 00:21  caffe2-master\LICENSE
     文件         527  2017-07-24 00:21  caffe2-master\Makefile
     文件        1988  2017-07-24 00:21  caffe2-master\PATENTS
     文件        1693  2017-07-24 00:21  caffe2-master\README.md
     文件        1499  2017-07-24 00:21  caffe2-master\appveyor.yml
     目录           0  2017-07-24 00:21  caffe2-master\caffe\
     目录           0  2017-07-24 00:21  caffe2-master\caffe\proto\
     文件         385  2017-07-24 00:21  caffe2-master\caffe\proto\CMakeLists.txt
     文件       57546  2017-07-24 00:21  caffe2-master\caffe\proto\caffe.proto
     目录           0  2017-07-24 00:21  caffe2-master\caffe2\
     文件       10157  2017-07-24 00:21  caffe2-master\caffe2\CMakeLists.txt
     目录           0  2017-07-24 00:21  caffe2-master\caffe2\binaries\
     文件         902  2017-07-24 00:21  caffe2-master\caffe2\binaries\CMakeLists.txt
     文件        2777  2017-07-24 00:21  caffe2-master\caffe2\binaries\convert_caffe_image_db.cc
     文件        1305  2017-07-24 00:21  caffe2-master\caffe2\binaries\convert_db.cc
     文件        4687  2017-07-24 00:21  caffe2-master\caffe2\binaries\convert_encoded_to_raw_leveldb.cc
     文件        4981  2017-07-24 00:21  caffe2-master\caffe2\binaries\core_overhead_benchmark.cc
     文件        2743  2017-07-24 00:21  caffe2-master\caffe2\binaries\db_throughput.cc
............此处省略1151个文件信息

评论

共有 条评论