Ejemplo n.º 1
0
def get_label(fname):
    f = open(fname, 'rb')
    rbyte = f.read()
    f.close()

    score_list = []
    for i in range(10):
        byte = b''
        byte += convert_to_bytes(rbyte[i * 4])
        byte += convert_to_bytes(rbyte[i * 4 + 1])
        byte += convert_to_bytes(rbyte[i * 4 + 2])
        byte += convert_to_bytes(rbyte[i * 4 + 3])
        score_list.append(struct.unpack('f', byte))

    return score_list.index(max(score_list))
Ejemplo n.º 2
0
##
# SPDX-License-Identifier: LGPL-2.1-only
#
# Copyright (C) 2018 Samsung Electronics
#
# @file checkLabel.py
# @brief Check the result label of tensorflow-lite model
# @author HyoungJoo Ahn <*****@*****.**>

import sys
import os
import struct
import string

sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
from test_utils import convert_to_bytes, read_file

bytearr = read_file(sys.argv[1])
softmax = []
for i in range(10):
    byte = b''
    byte += convert_to_bytes(bytearr[i * 4])
    byte += convert_to_bytes(bytearr[i * 4 + 1])
    byte += convert_to_bytes(bytearr[i * 4 + 2])
    byte += convert_to_bytes(bytearr[i * 4 + 3])
    softmax.append(struct.unpack('f', byte))

pred = softmax.index(max(softmax))
answer = int(sys.argv[2].strip())
exit(pred != answer)
Ejemplo n.º 3
0
#!/usr/bin/env python

##
# SPDX-License-Identifier: LGPL-2.1-only
#
# Copyright (C) 2019 Samsung Electronics
#
# @file checkLabel.py
# @brief Check the result label of pytorch model
# @author Parichay Kapoor <*****@*****.**>

import sys
import os
import string

sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
from test_utils import convert_to_bytes, read_file


# Verify that the output of test case verifies the filename of the input
onehot = read_file(sys.argv[1])
onehot = [convert_to_bytes(x) for x in onehot]
idx = onehot.index(max(onehot))

label = str(idx)

answer = sys.argv[2].split('/')[-1].split('.')[0].strip()
exit(label != answer)
Ejemplo n.º 4
0
            file.write(s[sink0_1])
            file.write(s[sink1_0])
            file.write(s[sink1_1])

if target == -1 or target == 10:
    buf = bmp.gen_BMP_random('RGB', 100, 100, 'testcase')[0]
    bmp.write('testcase.golden', buf)
    bmp.gen_BMP_stream('testsequence', 'testcase_stream.golden', 1)
if target == -1 or target == 11:
    buf = bmp.gen_BMP_random('RGB', 100, 100, 'testcase')[0]
    bmp.write('testcase_0_0.golden', buf)

    s = b''
    for y in range(0, 100):
        for x in range(0, 100):
            s += convert_to_bytes(buf[y * 100 + x])
    bmp.write('testcase_1_0.golden', s)

    s = b''
    for i in range(1, 3):
        for y in range(0, 100):
            for x in range(0, 100):
                s += convert_to_bytes(buf[y * 100 + x + i * 100 * 100])
    bmp.write('testcase_1_1.golden', s)

    for i in range(0, 3):
        s = b''
        for y in range(0, 100):
            for x in range(0, 100):
                s += convert_to_bytes(buf[y * 100 + x + i * 100 * 100])
        bmp.write('testcase_2_' + str(i) + '.golden', s)