Support zero-sized tensor and check for omitted input in CpuExecutor.
Zero-sized tensors are only supported internally to the driver, or reported in output shapes. It is illegal to pre-specify a zero-sized tensor as model input or output. To summarize the meanings of dimension = 0: - Dimension = 0 for model input: dynamic input and must be fully-specified at execution time - Dimension = 0 for internal operand / model output: unknown, to be deduced from execution - Dimension = 0 from getOutputOperandDimensions: * If NO_ERROR, it is a zero-sized output * If OUTPUT_INSUFFICIENT_SIZE, it is unknown Add two additional fields in OperationRegistration: - allowOmittedOperand, if false, CpuExecutor will enforce inputs/outputs are not null - allowZeroSizedInput, if false, CpuExecutor will enforce every dimension of inputs not being 0 The current implementation is assuming that none of the operations with the old switch statement path support zero-sized input. Only the operations with OperationResolver can support zero-sized input tensor. All the operations with OperationResolver are reporting false for allowZeroSizedInput. Will enable this on a small subset of operations with separate CLs. Bug: 126737477 Test: NeuralNetworksTest_static Change-Id: Ia94d67e4c8c6a49b543d29ebb3b31d509ece0970 Merged-In: Ia94d67e4c8c6a49b543d29ebb3b31d509ece0970 (cherry picked from commit 5750766c)
Loading
Please sign in to comment