code: def testInt8Conversion(self):
      model = model_helper.ModelHelper(name="fp32_int8_conversion_test")
      model.FloatToFused8BitRowwiseQuantized("x", "x_8bit")
      model.Fused8BitRowwiseQuantizedToFloat("x_8bit", "x_recovered")
      workspace.FeedBlob(
          "x", np.random.rand(100, 150).astype(np.float32)
      )
      self.InferTensorRunAndCompare(model)
      x = workspace.FetchBlob("x")
      x_recovered = workspace.FetchBlob("x_recovered")
      # TODO: find a tighter bound
      assert np.allclose(x, x_recovered, atol=1e-2)
  
      model = model_helper.ModelHelper(name="fp32_int8_conversion_test")
      model.FloatToFused8BitRowwiseQuantizedHalfScaleBias("x", "x_8bit")
      model.Fused8BitRowwiseQuantizedHalfScaleBiasToFloat(
          "x_8bit", "x_recovered"
      )
      workspace.FeedBlob(
          "x", np.random.rand(100, 150).astype(np.float32)
      )
      self.InferTensorRunAndCompare(model)
      x = workspace.FetchBlob("x")
      x_recovered = workspace.FetchBlob("x_recovered")
      # TODO: find a tighter bound
      assert np.allclose(x, x_recovered, atol=1e-2)
  
imports: import numpy
  import unittest
  from caffe2.proto import caffe2_pb2
  from caffe2.python import core, workspace, test_util, model_helper, brew, build
label_desc: Use image node_id 28 for calling the TestShapeInference obj's underlying member method code with example usage: obj.testInt8Conversion() without return types