Exemplo n.º 1
0
                  post_scale[1], 1, 0)
    gemx.execute()
    gemx.clearInstrBuf()
    gemx.getMat(mat_C[0])
    gemx.getMat(mat_C[1])
    gemx.getMat(mat_C[2])
    gemx.getMat(mat_C[3])
    test.multiply_and_cmp(mat_C[3], mat_A[3], mat_C[2], mat_bias[3], m_size[3],
                          n_size[3], post_scale)


if __name__ == '__main__':
    np.random.seed(123)  # for reproducibility
    test = FcnTest()
    args, xclbin_opts = gemx.processCommandLine()
    gemx.createFCNHandle(args, xclbin_opts)
    if xclbin_opts["GEMX_dataType"] == "short":
        for j in range(1, 3):
            for k in range(1, 8):
                for i in range(int(xclbin_opts["GEMX_numKernels"])):
                    for m, n in ([0, 0], [1, 0]):
                        test.test_basic_randint(i, xclbin_opts, [j, k], [m, n],
                                                2048)

        test.test_basic_size(512, 512, 512, xclbin_opts)

        size = 256
        while size < 8192:
            test_perf_fcn(size, size, size,
                          xclbin_opts)  # run performance measurement
            size = size * 2
Exemplo n.º 2
0
    parser.add_argument('--gemxlib',
                        required=True,
                        help='file path to GEMX host code shared library')
    parser.add_argument('--engine',
                        default='fcn',
                        choices=['fcn', 'uspmv'],
                        help='choose fcn, uspmv engine')
    parser.add_argument('--train',
                        default=False,
                        help='set to True if retrain the model')
    args = parser.parse_args()
    xclbin_prop = gemx.parse_cfg(args.cfg)

    #load xclbin
    if args.engine == 'fcn':
        gemx.createFCNHandle(args, xclbin_prop)
    else:
        gemx.createUSPMVHandle(args, xclbin_prop)

    (x_train, y_train), (x_test, y_test) = reuters.load_data(num_words=1000,
                                                             test_split=0.2)
    tokenizer = Tokenizer(num_words=1000)
    num_classes = np.max(y_train) + 1

    model = create_keras_model(num_classes)
    model.load_weights(args.model)

    if args.train:
        train(model, x_train, y_train, x_test, y_test)

    x_test = tokenizer.sequences_to_matrix(x_test, mode='binary')