def test_mul(input): ncc.clear() ncc.save_input_array('test', input) onnx_importer.utils.save(module, torch.from_numpy(input)) ncc.save_expect_array('test', onnx_importer.utils.run(input)) onnx_importer.utils.compile(['--inference-type', 'float']) ncc.infer(['--dataset-format', 'raw']) ncc.close_to('test', 0)
def init_values(): input = [ normalize( plt.imread( '../examples/20classes_yolo/k210/kpu_20classes_example/dog.bmp' )) ] expect = ncc.run_tflite(input) expect = np.transpose(expect, [0, 3, 1, 2]) ncc.save_expect_array('test', expect) input = np.transpose(input, [0, 3, 1, 2]) ncc.save_input_array('test', input)
def test_matmul_quant(input): ncc.clear() ncc.save_input_array('test', input) onnx_importer.utils.save(module, torch.from_numpy(input)) ncc.save_expect_array('test', onnx_importer.utils.run(input)) onnx_importer.utils.compile(['--inference-type', 'uint8', '-t', 'cpu', '--dataset', ncc.input_dir + '/test.bin', '--dataset-format', 'raw', '--input-type', 'float']) ncc.infer(['--dataset-format', 'raw']) ncc.close_to('test', 0.005)
def test_clip_k210_onnx_9(input): ncc.clear() ncc.save_input_array('test', input) onnx_importer.utils.save(module, torch.from_numpy(input), opset_version=9) ncc.save_expect_array('test', onnx_importer.utils.run(input)) onnx_importer.utils.compile(['--inference-type', 'uint8', '-t', 'k210', '--dataset', ncc.input_dir + '/test.bin', '--dataset-format', 'raw', '--input-type', 'float']) ncc.infer(['--dataset-format', 'raw']) ncc.close_to('test', 0.05)
def init_values(): input = np.asarray([1, -2, 3, 4, -9, 0], dtype=np.float32).reshape([1, 2, -1]) ncc.save_input_array('test', input) ncc.save_expect_array('test', ncc.run_tflite(input))
def init_values(): input = np.arange(1, 16 + 1, dtype=np.float32).reshape([1, 1, 4, 4]) ncc.save_input_array('test', input) ncc.save_expect_array('test', ncc.run_tflite(np.transpose(input, [0, 2, 3, 1])))
def init_values(): input = np.asarray([1.], dtype=np.float32) ncc.save_input_array('test', input) ncc.save_expect_array('test', ncc.run_tflite(input[0]))