MCPcopy
hub / github.com/onnx/onnx / export_uint4

Method export_uint4

onnx/backend/test/case/node/quantizelinear.py:216–245  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

214
215 @staticmethod
216 def export_uint4() -> None:
217 node = onnx.helper.make_node(
218 "QuantizeLinear",
219 inputs=["x", "y_scale", "y_zero_point"],
220 outputs=["y"],
221 axis=0,
222 )
223
224 x = np.array(
225 [
226 [0.0, 2.5, 4.8, 8.6],
227 [-30, -20, 6, 9],
228 [12, 15, 16, 40],
229 ]
230 ).astype(np.float32)
231
232 y_scale = np.asarray([2.0, 3.0, 4.0], dtype=np.float32)
233 y_zero_point = make_tensor(
234 "y_zero_point", TensorProto.UINT4, y_scale.shape, np.ones_like(y_scale)
235 )
236 y = make_tensor(
237 "y", TensorProto.UINT4, x.shape, [1, 2, 3, 5, 0, 0, 3, 4, 4, 5, 5, 11]
238 )
239
240 expect(
241 node,
242 inputs=[x, y_scale, y_zero_point],
243 outputs=[y],
244 name="test_quantizelinear_uint4",
245 )
246
247 @staticmethod
248 def export_int4() -> None:

Callers

nothing calls this directly

Calls 3

make_tensorFunction · 0.90
expectFunction · 0.90
make_nodeMethod · 0.80

Tested by

no test coverage detected