mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 00:21:07 +01:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/13660 Any change in server side quantized operator was triggering ios-sanity-check with more than 5 hours testing time. I suspect this was because the operator code was synced with xplat directory. This diff moves server side quantized operators to caffe2/caffe2/quantization/server to avoid this issue. Reviewed By: hx89 Differential Revision: D12955420 fbshipit-source-id: b6c824b9de5e2a696f8c748e1b2c77d81d46746b
35 lines
914 B
Python
35 lines
914 B
Python
from __future__ import absolute_import
|
|
from __future__ import division
|
|
from __future__ import print_function
|
|
from __future__ import unicode_literals
|
|
import numpy as np
|
|
from caffe2.python import core, workspace
|
|
from caffe2.quantization.server import dnnlowp_pybind11
|
|
|
|
net = core.Net("test_net")
|
|
|
|
X = np.array([[1, 2], [3, 4]]).astype(np.float32)
|
|
W = np.array([[5, 6], [7, 8]]).astype(np.float32)
|
|
b = np.array([0, 1]).astype(np.float32)
|
|
|
|
workspace.FeedBlob("X", X)
|
|
workspace.FeedBlob("W", W)
|
|
workspace.FeedBlob("b", b)
|
|
|
|
Y = net.FC(["X", "W", "b"], ["Y"])
|
|
|
|
dnnlowp_pybind11.ObserveMinMaxOfOutput("test_net.minmax", 1)
|
|
workspace.CreateNet(net)
|
|
workspace.RunNet(net)
|
|
print(workspace.FetchBlob("Y"))
|
|
|
|
workspace.ResetWorkspace()
|
|
|
|
workspace.FeedBlob("X", X)
|
|
workspace.FeedBlob("W", W)
|
|
workspace.FeedBlob("b", b)
|
|
|
|
dnnlowp_pybind11.ObserveHistogramOfOutput("test_net.hist", 1)
|
|
workspace.CreateNet(net)
|
|
workspace.RunNet(net)
|