Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

neilisaac / torch   python

Repository URL to install this package:

/ python / test / fakefp16_transform_test.py





import unittest
from caffe2.python.fakefp16_transform_lib import fakeFp16FuseOps
from caffe2.python import core

class Transformer(unittest.TestCase):
    def test_fuse(self):
        net_swish = core.Net("test_swish")
        net_swish_init = core.Net("test_swish_init")

        deq = core.CreateOperator("Int8DequantizeNNPI", ["Xq"], ["X"])
        swish = core.CreateOperator("SwishFakeFp16NNPI", ["X"], ["Y"])
        quant = core.CreateOperator("Int8QuantizeNNPI", ["Y"], ["Y_q"])
        net_swish.Proto().op.extend(
            [
                deq, swish, quant
            ]
        )
        print(net_swish.Proto())
        out_net = fakeFp16FuseOps(net_swish.Proto())
        assert(len(out_net.op) == 1)