Skip to content

Commit

Permalink
[q-implant-qparam-test] Introduce test cases (#11679)
Browse files Browse the repository at this point in the history
This introduces test cases for q-implant-qparam-test.

ONE-DCO-1.0-Signed-off-by: Seonguk Park [email protected]
  • Loading branch information
FantBlog authored Oct 6, 2023
1 parent bb0dc44 commit 52269cf
Show file tree
Hide file tree
Showing 23 changed files with 897 additions and 0 deletions.
38 changes: 38 additions & 0 deletions compiler/q-implant-qparam-test/qparam/Add_000/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from test_utils import TestCase
from test_utils import gen_random_tensor


class Add_000_Q8(TestCase):
def __init__(self):
self.name = _name_

def generate(self) -> dict:
json_content = dict()

# Generate ifm1
json_content['ifm1'] = gen_random_tensor(
"uint8", # dtype_str
(1), # scale_shape
(1), # zerop_shape
0) # quantized_dimension

# Generate ifm2
json_content['ifm2'] = gen_random_tensor(
"uint8", #dtype_str
(1), # scale_shape
(1), # zerop_shape
0) # quantized_dimension

# Generate ofm
json_content['ofm'] = gen_random_tensor(
"uint8", # dtype_str
(1), # scale_shape
(1), # zerop_shape
0) # quantized_dimension

return json_content


_name_ = 'Add_000_Q8'

_test_case_ = Add_000_Q8()
39 changes: 39 additions & 0 deletions compiler/q-implant-qparam-test/qparam/Add_001/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from test_utils import TestCase
from test_utils import gen_random_tensor


class Add_001_Q8(TestCase):
def __init__(self):
self.name = _name_

def generate(self) -> dict:
json_content = dict()

# Generate ifm1
json_content['ifm1'] = gen_random_tensor(
"uint8", # dtype_str
(1), # scale_shape
(1), # zerop_shape
0) # quantized_dimension

# Generate ifm2
json_content['ifm2'] = gen_random_tensor(
"uint8", #dtype_str
(1), # scale_shape
(1), # zerop_shape
0, # quantized_dimension
(1, 0, 1)) # value_shape

# Generate ofm
json_content['ofm'] = gen_random_tensor(
"uint8", # dtype_str
(1), # scale_shape
(1), # zerop_shape
0) # quantized_dimension

return json_content


_name_ = 'Add_001_Q8'

_test_case_ = Add_001_Q8()
39 changes: 39 additions & 0 deletions compiler/q-implant-qparam-test/qparam/Add_002/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from test_utils import TestCase
from test_utils import gen_random_tensor


class Add_002_Q8(TestCase):
def __init__(self):
self.name = _name_

def generate(self) -> dict:
json_content = dict()

# Generate ifm1
json_content['ifm1'] = gen_random_tensor(
"uint8", # dtype_str
(1), # scale_shape
(1), # zerop_shape
0) # quantized_dimension

# Generate ifm2
json_content['ifm2'] = gen_random_tensor(
"uint8", #dtype_str
(1), # scale_shape
(1), # zerop_shape
0, # quantized_dimension
(1, 2, 2, 3)) # value_shape

# Generate ofm
json_content['ofm'] = gen_random_tensor(
"uint8", # dtype_str
(1), # scale_shape
(1), # zerop_shape
0) # quantized_dimension

return json_content


_name_ = 'Add_002_Q8'

_test_case_ = Add_002_Q8()
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from test_utils import TestCase
from test_utils import gen_random_tensor


class AveragePool2D_000_Q8(TestCase):
def __init__(self):
self.name = _name_

def generate(self) -> dict:
json_content = dict()

# Generate ifm
json_content['ifm'] = gen_random_tensor(
"uint8", # dtype_str
(1), # scale_shape
(1), # zerop_shape
0) # quantized_dimension

# Generate ofm
json_content['ofm'] = gen_random_tensor(
"uint8", # dtype_str
(1), # scale_shape
(1), # zerop_shape
0) # quantized_dimension

return json_content


_name_ = 'AveragePool2D_000_Q8'

_test_case_ = AveragePool2D_000_Q8()
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from test_utils import TestCase
from test_utils import gen_random_tensor


class Concatenation_000_Q8(TestCase):
def __init__(self):
self.name = _name_

def generate(self) -> dict:
json_content = dict()

# Generate ifm1
json_content['ifm1'] = gen_random_tensor(
"uint8", # dtype_str
(1), # scale_shape
(1), # zerop_shape
0) # quantized_dimension

# Generate ifm2
json_content['ifm2'] = gen_random_tensor(
"uint8", # dtype_str
(1), # scale_shape
(1), # zerop_shape
0) # quantized_dimension

# Generate ofm
json_content['ofm'] = gen_random_tensor(
"uint8", # dtype_str
(1), # scale_shape
(1), # zerop_shape
0) # quantized_dimension

return json_content


_name_ = 'Concatenation_000_Q8'

_test_case_ = Concatenation_000_Q8()
47 changes: 47 additions & 0 deletions compiler/q-implant-qparam-test/qparam/Conv2D_000/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from test_utils import TestCase
from test_utils import gen_random_tensor


class Conv2D_000_Q8(TestCase):
def __init__(self):
self.name = _name_

def generate(self) -> dict:
json_content = dict()

# Generate ifm
json_content['ifm'] = gen_random_tensor(
"uint8", # dtype_str
(1), # scale_shape
(1), # zerop_shape
0) # quantized_dimension

# Generate ker
json_content['ker'] = gen_random_tensor(
"uint8", #dtype_str
(1), # scale_shape
(1), # zerop_shape
0, # quantized_dimension
(1, 1, 1, 2)) # value_shape (OHWI)

# Generate bias
json_content['bias'] = gen_random_tensor(
"int32", #dtype_str
(1), # scale_shape
(1), # zerop_shape
0, # quantized_dimension
(1)) # value_shape

# Generate ofm
json_content['ofm'] = gen_random_tensor(
"uint8", # dtype_str
(1), # scale_shape
(1), # zerop_shape
0) # quantized_dimension

return json_content


_name_ = 'Conv2D_000_Q8'

_test_case_ = Conv2D_000_Q8()
47 changes: 47 additions & 0 deletions compiler/q-implant-qparam-test/qparam/Conv2D_001/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from test_utils import TestCase
from test_utils import gen_random_tensor


class Conv2D_001_Q8(TestCase):
def __init__(self):
self.name = _name_

def generate(self) -> dict:
json_content = dict()

# Generate ifm
json_content['ifm'] = gen_random_tensor(
"uint8", # dtype_str
(1), # scale_shape
(1), # zerop_shape
0) # quantized_dimension

# Generate ker
json_content['ker'] = gen_random_tensor(
"uint8", #dtype_str
(1), # scale_shape
(1), # zerop_shape
0, # quantized_dimension
(1, 1, 1, 2)) # value_shape (OHWI)

# Generate bias
json_content['bias'] = gen_random_tensor(
"int32", #dtype_str
(1), # scale_shape
(1), # zerop_shape
0, # quantized_dimension
(1)) # value_shape

# Generate ofm
json_content['ofm'] = gen_random_tensor(
"uint8", # dtype_str
(1), # scale_shape
(1), # zerop_shape
0) # quantized_dimension

return json_content


_name_ = 'Conv2D_001_Q8'

_test_case_ = Conv2D_001_Q8()
47 changes: 47 additions & 0 deletions compiler/q-implant-qparam-test/qparam/Conv2D_002/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from test_utils import TestCase
from test_utils import gen_random_tensor


class Conv2D_002_Q8(TestCase):
def __init__(self):
self.name = _name_

def generate(self) -> dict:
json_content = dict()

# Generate ifm
json_content['ifm'] = gen_random_tensor(
"uint8", # dtype_str
(1), # scale_shape
(1), # zerop_shape
0) # quantized_dimension

# Generate ker
json_content['ker'] = gen_random_tensor(
"uint8", #dtype_str
(1), # scale_shape
(1), # zerop_shape
0, # quantized_dimension
(1, 1, 1, 1)) # value_shape (OHWI)

# Generate bias
json_content['bias'] = gen_random_tensor(
"int32", #dtype_str
(1), # scale_shape
(1), # zerop_shape
0, # quantized_dimension
(1)) # value_shape

# Generate ofm
json_content['ofm'] = gen_random_tensor(
"uint8", # dtype_str
(1), # scale_shape
(1), # zerop_shape
0) # quantized_dimension

return json_content


_name_ = 'Conv2D_002_Q8'

_test_case_ = Conv2D_002_Q8()
47 changes: 47 additions & 0 deletions compiler/q-implant-qparam-test/qparam/Conv2D_003/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from test_utils import TestCase
from test_utils import gen_random_tensor


class Conv2D_003_Q8(TestCase):
def __init__(self):
self.name = _name_

def generate(self) -> dict:
json_content = dict()

# Generate ifm
json_content['ifm'] = gen_random_tensor(
"uint8", # dtype_str
(1), # scale_shape
(1), # zerop_shape
0) # quantized_dimension

# Generate ker
json_content['ker'] = gen_random_tensor(
"uint8", #dtype_str
(1), # scale_shape
(1), # zerop_shape
0, # quantized_dimension
(1, 3, 3, 1)) # value_shape (OHWI)

# Generate bias
json_content['bias'] = gen_random_tensor(
"int32", #dtype_str
(1), # scale_shape
(1), # zerop_shape
0, # quantized_dimension
(1)) # value_shape

# Generate ofm
json_content['ofm'] = gen_random_tensor(
"uint8", # dtype_str
(1), # scale_shape
(1), # zerop_shape
0) # quantized_dimension

return json_content


_name_ = 'Conv2D_003_Q8'

_test_case_ = Conv2D_003_Q8()
Loading

0 comments on commit 52269cf

Please sign in to comment.