コード例 #1
0
ファイル: benchmark_uspmv.py プロジェクト: saadmahboob/gemx
                     required=False,
                     default=[100, 128, 12800, 25, 100, 2500, 5, 25, 125])
 parser.add_argument('--vectors',
                     required=False,
                     type=int,
                     help='number of vectors',
                     default=300)
 parser.add_argument('--mtx',
                     required=False,
                     help='path to mtx file',
                     nargs="+",
                     default='none')
 args = parser.parse_args()
 xclbin_opt = gemx.parse_cfg(args.cfg)
 if args.engine == 'spmv':
     gemx.createUSPMVHandle(args, xclbin_opt)
 else:
     gemx.createFCNHandle(args, xclbin_opt)
 A_buf = []
 B_buf = []
 C_buf = []
 bias_buf = []
 number_runs = args.vectors
 stage_size = 1
 if args.mtx == 'none':
     num_matrix = len(args.matrix) / 3
 else:
     num_matrix = len(args.mtx)
 if args.engine == 'spmv':
     min_row = int(xclbin_opt["GEMX_uspmvInterleaves"]) * int(
         xclbin_opt["GEMX_ddrWidth"])
コード例 #2
0
                        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')

    cpu_out = mlp_common.predict_cpu(model, x_test)