From c23fc3b03ce7173ba5616234ed7b84fad61941e8 Mon Sep 17 00:00:00 2001 From: Jeremy Johnson Date: Mon, 30 May 2022 16:51:21 +0100 Subject: Remove RESHAPE -1 dimensions support Signed-off-by: Jeremy Johnson Change-Id: I098daf49c92da12c07143cdd23ac9bb58acebbb9 --- reference_model/src/ops/data_layout.cc | 36 ++-------------------------------- verif/generator/tosa_arg_gen.py | 5 ----- verif/generator/tosa_test_gen.py | 15 -------------- 3 files changed, 2 insertions(+), 54 deletions(-) diff --git a/reference_model/src/ops/data_layout.cc b/reference_model/src/ops/data_layout.cc index 387152f..24c86ed 100644 --- a/reference_model/src/ops/data_layout.cc +++ b/reference_model/src/ops/data_layout.cc @@ -236,8 +236,6 @@ OpReshape::~OpReshape() template int OpReshape::checkTensorAttributes() { - uint32_t minusOneCount = 0; - if (validateRequiredOperands()) return 1; @@ -258,21 +256,8 @@ int OpReshape::checkTensorAttributes() for (uint32_t d = 0; d < OutRank; d++) { - if (attribute->shape()[d] == -1) - { - minusOneCount++; - } - else - { - ERROR_IF(attribute->shape()[d] != outputs[0]->getShape()[d], - "OpReshape: new_shape doesn't match output shape"); - } - } - - if (minusOneCount > 1) - { - printNodeValidationError("OpReshape: new shape has more than one -1 dimension"); - return 1; + ERROR_IF(attribute->shape()[d] != outputs[0]->getShape()[d], + "OpReshape: new_shape doesn't match output shape"); } in = dynamic_cast*>(inputs[0]); @@ -284,27 +269,10 @@ int OpReshape::checkTensorAttributes() template int OpReshape::eval() { - uint32_t remainingSize = in->getElementCount(); - - // If there is a -1 dimension, find the remainder in one pass over the output shape - for (int32_t d = 0; d < OutRank; d++) - { - if (attribute->shape()[d] != -1) - { - remainingSize = remainingSize / attribute->shape()[d]; - } - } - for (int32_t d = 0; d < OutRank; d++) { array_shape[d] = attribute->shape()[OutRank - 1 - d]; out_reverser[d] = OutRank - 1 - d; - - // Jam in the remainder here - if (array_shape[d] == -1) - { - array_shape[d] = remainingSize; - } } for (int32_t d = 0; d < InRank; d++) diff --git a/verif/generator/tosa_arg_gen.py b/verif/generator/tosa_arg_gen.py index a741efb..b5e68dd 100644 --- a/verif/generator/tosa_arg_gen.py +++ b/verif/generator/tosa_arg_gen.py @@ -1513,11 +1513,6 @@ class TosaArgGen: ) newShape.append(remainingElements) - # Toss in a -1 sometimes - minusOne = testGen.randInt(0, newRank * 4) - if minusOne < newRank: - newShape[minusOne] = -1 - # Check for duplicates found = False for name, other_shape in arg_list: diff --git a/verif/generator/tosa_test_gen.py b/verif/generator/tosa_test_gen.py index c9c6d7e..fc2e476 100644 --- a/verif/generator/tosa_test_gen.py +++ b/verif/generator/tosa_test_gen.py @@ -4288,21 +4288,6 @@ class OutputShaper: def reshapeOp(ser, rng, a, shape, error_name=None): output_shape = shape.copy() - totalElements = 1 - for i in a.shape: - totalElements *= i - - # If there are any -1 elements, figure out what that dimension must be - totalOutputElements = 1 - for i in output_shape: - if i != -1: - totalOutputElements *= i - - # And fill it in - for i in range(len(output_shape)): - if output_shape[i] == -1: - output_shape[i] = totalElements // totalOutputElements - if error_name == ErrorIf.TensorSizeInputOutputMismatch: for i in range(len(output_shape)): output_shape[i] = output_shape[i] + rng.integers(1, 10) -- cgit v1.2.1