示例#1
0
文件: test.py 项目: tallurips91/FINN
    def test_cycles_per_layer(self):
        l = CaffeLoader(
            None,
            "./FINN/inputs/dorefanet-pruned-without-extra-messages.prototxt")
        net = nn.NN(l)
        dev = device.Device('XLNX:KU115.json')
        perfmodel = pm.PerfModel(net, dev)
        fps = perfmodel.maximise_fps()
        for idx, layer in enumerate(net.layers):
            in_chans = net.layers[idx].getInputSize()
            out_chans = net.layers[idx].getOutputSize()
            out_dim = net.layers[idx].get_out_dim()

            if isinstance(in_chans, tuple):
                print in_chans
                in_chans = in_chans[0]
            if isinstance(out_chans, tuple):
                print out_chans
                out_chans = out_chans[0]
            if isinstance(out_dim, tuple):
                print out_dim
                out_dim = out_dim[0]

            print perfmodel.SIMD[idx], in_chans
            print perfmodel.PE[idx], out_chans
            print perfmodel.MMV[idx], out_dim
            self.assertLessEqual(perfmodel.SIMD[idx], in_chans)
            self.assertLessEqual(perfmodel.PE[idx], out_chans)
            self.assertLessEqual(perfmodel.MMV[idx], out_dim)
示例#2
0
文件: test.py 项目: tallurips91/FINN
 def test_simd_pe_mmv_constraints(self):
     l = CaffeLoader(None, "./FINN/inputs/sfc.prototxt")
     net = nn.NN(l)
     dev = device.Device('XLNX:KU115.json')
     perfmodel = pm.PerfModel(net, dev)
     fps = perfmodel.maximise_fps()
     for idx, layer in enumerate(net.layers):
         self.assertLessEqual(perfmodel.SIMD[idx], layer.getInputSize())
         self.assertLessEqual(perfmodel.PE[idx], layer.getOutputSize())
         self.assertLessEqual(perfmodel.MMV[idx], layer.get_out_dim())
示例#3
0
文件: test.py 项目: tallurips91/FINN
 def test_cycles_per_op(self):
     l = CaffeLoader("./FINN/inputs/sfc.caffemodel",
                     "./FINN/inputs/sfc.prototxt")
     net = nn.NN(l)
     dev = device.Device('XLNX:VU9P.json')
     perfmodel = pm.PerfModel(net, dev)
     ops = perfmodel.network_utilisation()
     num_matrix_layers = net.count_matrix_layers()
     self.assertEqual(ops['luts'],
                      2 * num_matrix_layers * dev.lut_cost_per_op())
示例#4
0
 def setUp(self):
     nname = "lenet-hwgq-w1a2"
     proto = FINN_ROOT + "/inputs/%s.prototxt" % nname
     weights = FINN_ROOT + "/inputs/%s.caffemodel" % nname
     l = CaffeLoader(weights, proto)
     self.net = nn.NN(l)
     self.streamlined_net = nn.NN(
         layers=transform.makeCromulent(self.net.layers))
     # use the first numImagesToTest of the test set for verification
     self.numImagesToTest = 10
     # expected number of successful predictions
     self.ok_golden = 10
     # expected number of unsuccessful predictions
     self.nok_golden = 0
示例#5
0
 def setUp(self):
     self.nname = "caffenet-hwgq-w1a2"
     proto = config.FINN_ROOT + "/inputs/%s.prototxt" % self.nname
     weights = config.FINN_ROOT + "/inputs/%s.caffemodel" % self.nname
     # download weights if not already on disk
     weights_url = "http://www.svcl.ucsd.edu/projects/hwgq/AlexNet_HWGQ.caffemodel"
     if not os.path.exists(weights):
         print("Downloading HWGQ CaffeNet weights")
         urlretrieve(weights_url, weights)
     l = CaffeLoader(weights, proto)
     self.net = nn.NN(l)
     # use the first numImagesToTest of the test set for verification
     self.numImagesToTest = 10
     # expected number of successful predictions
     self.ok_golden = 7
     # expected number of unsuccessful predictions
     self.nok_golden = 3
示例#6
0
 def setUp(self):
     nname = "lfc-w1a1"
     proto = FINN_ROOT + "/inputs/%s.prototxt" % nname
     weights = FINN_ROOT + "/inputs/%s.caffemodel" % nname
     l = CaffeLoader(weights, proto)
     self.net = nn.NN(l)
     frequency = 300
     self.dev = device.Device('XLNX:VU9P.json', frequency)
     self.streamlined_net = copy.deepcopy(self.net)
     print self.streamlined_net.layers
     self.streamlined_net.layers = transform.makeCromulent(
         self.streamlined_net.layers)
     print self.streamlined_net.layers
     # use the first numImagesToTest of the test set for verification
     self.numImagesToTest = 1000
     # expected number of successful predictions
     self.ok_golden = 967
     # expected number of unsuccessful predictions
     self.nok_golden = 33
示例#7
0
def demo_hwgq_import():
    l = CaffeLoader(None, "inputs/sfc.prototxt")
    net = FINN.core.nn.NN(l)
    dev = device.Device('XLNX:KU115.json')
    perf = perf_model.PerfModel(net, dev)

    perf.print_folding_factors()
    perf.print_hardware_cost()

    for idx, val in enumerate(perf.SIMD):
        perf.SIMD[idx] = 5
        #perf.PE[idx]  = 10
    perf.print_folding_factors()
    perf.print_hardware_cost()

    for idx, val in enumerate(perf.SIMD):
        perf.SIMD[idx] = 20
        #perf.PE[idx]  = 100
    perf.print_folding_factors()
    perf.print_hardware_cost()
示例#8
0
#       derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import FINN.core.perf_model as pm
import FINN.core.device as device
import FINN.core.nn as nn
from FINN.frontend.caffeloader import CaffeLoader

print "Hardware model"

frequency = 200
#dev = device.Device('XLNX:PYNQ-Z1.json', frequency)
dev = device.Device('XLNX:VU9P.json', frequency)
net = nn.NN(CaffeLoader(None, './FINN/inputs/lfc-w1a1.prototxt'))
perfmodel = pm.PerfModel(net, dev)
fps = perfmodel.maximise_fps()
print "Network Utilization"

print perfmodel.network_utilisation()['luts']/dev.luts*100
print perfmodel.network_utilisation()['brams']/dev.brams*100
示例#9
0
 def setUp(self):
     l = CaffeLoader("inputs/sfc.caffemodel", "inputs/sfc.prototxt")
     self.net = nn.NN(l)