Beispiel #1
0
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',
        np.transpose(ncc.run_tflite(np.transpose(input, [0, 2, 3, 1])),
                     [0, 3, 1, 2]))
Beispiel #2
0
def init_values():
    input = [
        normalize(
            plt.imread(dir_prefix + '/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)
Beispiel #3
0
def test_add(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)
Beispiel #4
0
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)
Beispiel #5
0
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)
Beispiel #6
0
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))
Beispiel #7
0
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]))