diff options
author | TatWai Chong <tatwai.chong@arm.com> | 2022-07-25 04:01:58 +0000 |
---|---|---|
committer | TatWai Chong <tatwai.chong@arm.com> | 2022-08-29 10:43:53 -0700 |
commit | fd62905d807b5976bea28b6d766e614c076faacf (patch) | |
tree | 09ac9ebad511a49a80888e81ec2cde5ec54696b9 /verif/frameworks/test_builder.py | |
parent | c1a978391b16dbbe634bc3338562066a75a6c678 (diff) | |
download | reference_model-fd62905d807b5976bea28b6d766e614c076faacf.tar.gz |
Update framework test generator to support TF/TFL conv3d.
Add a new attribute `rank` to indicate the testing dimension range of
input tensor. Also fix a minor bug in the existing conv3d simulation.
And relax rescale operator in the reference model to support 5-D input.
Change-Id: Ib42fe513831dc83eb7f9af07e011787a6c752704
Signed-off-by: TatWai Chong <tatwai.chong@arm.com>
Diffstat (limited to 'verif/frameworks/test_builder.py')
-rw-r--r-- | verif/frameworks/test_builder.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/verif/frameworks/test_builder.py b/verif/frameworks/test_builder.py index 84e4d46..0468518 100644 --- a/verif/frameworks/test_builder.py +++ b/verif/frameworks/test_builder.py @@ -479,6 +479,47 @@ class TBuilder: ) return bias_add_op + class Conv3d: + def __init__(self, weight, strides, padding, dilations, name): + self.weight = weight + self.strides = strides + self.padding = padding + self.dilations = dilations + self.result_name = name + + def eval(self, input): + return tf.nn.conv3d( + input, + self.weight, + self.strides, + self.padding, + data_format="NDHWC", + dilations=self.dilations, + name=self.result_name, + ) + + class Conv3dWithBias: + def __init__(self, weight, bias, strides, padding, dilations, name): + self.weight = weight + self.bias = bias + self.strides = strides + self.padding = padding + self.dilations = dilations + self.result_name = name + + def eval(self, input): + conv3d_op = tf.nn.conv3d( + input, + self.weight, + self.strides, + self.padding, + data_format="NDHWC", + dilations=self.dilations, + name="conv3d", + ) + bias_add_op = tf.nn.bias_add(conv3d_op, self.bias, name=self.result_name) + return bias_add_op + class DepthwiseConv2d: def __init__(self, weight, strides, padding, dilations, name): self.weight = weight |