aboutsummaryrefslogtreecommitdiff
path: root/reference_model/src/ops/tensor_ops.cc
AgeCommit message (Collapse)Author
2024-04-18[reference_model] Remove output_shape from transpose_conv2dSuraj Sudhir
Signed-off-by: Suraj Sudhir <suraj.sudhir@arm.com> Change-Id: Ib2b95e73b226d64c4db5ad1ed22c123e04d7e6f9
2024-04-18RFFT2D, refmodel. Correct code when size is oneDmitriy Smirnov
When width or height are one then H/2 or W/2 are not integral. Signed-off-by: Dmitriy Smirnov <dmitriy.smirnov@arm.com> Change-Id: I1a849bec7cbb1d55fd5f085ebe58be45ea0b508e
2024-03-20[ref model] Add acc_type to Conv OpsTai Ly
This patch implements changes required by the new acc_type field in ConvAttribute and TransposeConvAttribute Signed-off-by: Tai Ly <tai.ly@arm.com> Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com> Change-Id: Ib13dbeec4d8920e0ddbcca02b727e7277f2c8d62
2024-03-15Add missing FP8 definition and instantiation for FULLY_CONNNECTED opWon Jeon
Signed-off-by: Won Jeon <won.jeon@arm.com> Change-Id: I7efc03f16136b2b74f8dfef79a6e7e147c93f4ed
2024-02-27[reference_model] tosa.fb name changesTai Ly
This patch adjusts reference model for attribute name changes in tosa.fb schema, and for obsoleted slice/tile/reshape attributes also updated examples due to the breaking tosa flatbuffers changes Signed-off-by: Tai Ly <tai.ly@arm.com> Change-Id: I105eb99a4c35f289c5078aed0a7f9cbb6dfe9123
2024-02-21Add support for FP8 to reference modelWon Jeon
Signed-off-by: Won Jeon <won.jeon@arm.com> Change-Id: I99b70f94aff2ccd4af64875697e124eb60bc5b08
2024-02-08Main Compliance: RFFT2D supportJeremy Johnson
Correct ref model to produce imaginery values of zero as specification indicates at certain output positions. Fix up precise and abs modes for RFFT2D in ref model to produce correct results and bounds using abs weights. Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com> Change-Id: I33767e4219a260278f7933f28b1799223a95a3cc
2024-02-07Main Compliance: FFT2D supportJeremy Johnson
Improve access to DOT_PRODUCT generator index and location for debugging. Enable multiple result files for compliance and improve output. Fix up precise and abs modes for FFT2D in ref model to produce correct results and bounds using abs weights. Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com> Change-Id: Ide0c9f9f80397e5f1e07ca30a1036d6014b5784d
2023-11-22Correct Fully Connected Validation LogicJack Frankland
The bias operand of the fully connected operator must be a 1D tensor either equal to the output channel size or of size 1. Previously we asserted the former case, we now include the second case. Signed-off-by: Jack Frankland <jack.frankland@arm.com> Change-Id: I07dbc8a3aa1650703e5c50e1e7f36bb9539fd5db
2023-11-14[reference_model] Add local_bound supportTai Ly
Add support for local_bound attributes. Signed-off-by: Tai Ly <tai.ly@arm.com> Change-Id: Ie1acb65ca2495fb7d1512bf120568c695635d631
2023-10-23Fix AvgPool2D regressionJames Ward
Signed-off-by: James Ward <james.ward@arm.com> Change-Id: I414899d0f504af00da185e0fc4119f3bde2bae3a
2023-10-20Fix AVG_POOL2D bad_alloc with large kernel sizesJames Ward
- Nested looping instead of using Eigen extract_image_patches to avoid OOM errors Signed-off-by: James Ward <james.ward@arm.com> Change-Id: Id4d78d5b5dd04a00134f29b1d29f814195515b1f
2023-08-14Add support for bias broadcastingTai Ly
add support for bias broadcasting for operators: - conv2d - conv3d - depthwise_conv2d - transpose_conv2d - fully_connected could not add framework test for this because tf.nn.bias_add requires bias size to match channel dimension. manually tested reference model evaluation on tosa mlir with bias size of 1 Signed-off-by: Tai Ly <tai.ly@arm.com> Change-Id: I70d29d231a63fc03b10e3006cbd6b16b53cca1f2
2023-08-07Update formatting based on clang-format 14Eric Kunze
Signed-off-by: Eric Kunze <eric.kunze@arm.com> Change-Id: I22939e75a08349816a9c103eb7312edcec53855e
2023-07-25Run clang-format and update copyrightJerry Ge
- Also added run clang-format to pre-commit runs Signed-off-by: Jerry Ge <jerry.ge@arm.com> Change-Id: I4e59ac0afbaa30dce0773aa63d92a1a3b119e2f3
2023-05-18Add abs calculations under precise_modeTai Ly
This adds a second run of reference model under precise_mode when test_desc.json contains a "compliance" dictionary which contains a "mode" entry with value "dot product". In this second run, abs_mode will be set to true, which causes: 1. evaluation will take absolute values of inputs for these operators: conv2d, conv3d, depthwise_conv2d, fully_connected, matmul, transpose_conv2d, fft2d, rfft2d reduce_sum, avg_pool2d 2. output files will have prefix "bounds_" prepended to them Signed-off-by: Tai Ly <tai.ly@arm.com> Change-Id: I7070ecc7ead2d2ea3375c44663d653c6772b88e0
2023-05-10Refactor ref_model rank checking and add level check to argmaxJerry Ge
Signed-off-by: Jerry Ge <jerry.ge@arm.com> Change-Id: Iad035b31d5e5e83040068e6311501490765bfff7
2023-05-05[reference model] Add precise modeTai Ly
This adds --precise_mode=1 option to tosa_referece_model, which will cause reference model to convert all floating point tensors to FP64 tensors and compute all operators accordingly. Also adds optional -p arguments to test runners tosa_verif_run_tests.py and tosa_verif_framework_compiler_runner.py to run tests in precise mode Signed-off-by: Tai Ly <tai.ly@arm.com> Change-Id: I156055216ad61710096497a8fa1a653be2a602a3
2023-04-24AVG_POOL2D - Fix for stride renaming mistakeJeremy Johnson
Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com> Change-Id: I6deb355998ce88714b41eedc8170acbd7875f519
2023-04-20Add level checking to TOSA Ref modelJerry Ge
Signed-off-by: Jerry Ge <jerry.ge@arm.com> Change-Id: I5689d7c6b902a319a68fa4628b59e0bcc23aeca4
2023-02-10Add FFT2d to the reference modelLuke Hutton
Includes: * FFT2d reference implementation * Basic TOSA tests Change-Id: Ie79fcb713542345d550ec013646810c1e890e388 Signed-off-by: Luke Hutton <luke.hutton@arm.com>
2023-02-02Remove accumulator attributes from all but AVG_POOL2DJames Ward
Signed-off-by: James Ward <james.ward@arm.com> Change-Id: If67f503a1848967bc1671646c3011d055b622c52
2023-01-24Add RFFT2d to the reference modelLuke Hutton
Includes: * RFFT2d reference implementation * TFLite framework tests * Basic TOSA tests * Serialization submodule upgrade with support for FFT/RFFT Signed-off-by: Luke Hutton <luke.hutton@arm.com> Change-Id: I2a687e9cf87fb62a26160ea52439ba9830bea36e
2022-11-09Add BF16 support to reference modelJames Ward
* Upgrade Eigen to 3.4.0 (for bfloat16 support) and add work- arounds for reduce.any() and reduce.all() bugs (introduced between 3.3.7 and 3.4.0) * Truncation to bfloat16 now performed in eval() methods Signed-off-by: James Ward <james.ward@arm.com> Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com> Change-Id: If5f5c988d76d3d30790acf3b97081726b89205fe
2022-10-13Rename FLOAT type to FP32Jeremy Johnson
Update tensor operations naming to state input type as TxT in all cases. Effects CONV2D, CONV3D, DEPTHWISE_CONV2D, FULLY_CONNECTED, TRANSPOSE_CONV2D. Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com> Change-Id: Ic959acfcb3aa0a910b33b774a5a85fac08219205
2022-10-11Reference model changes for fp16 supportJames Ward
Change-Id: I72f21fcfa153046274969d327313e3349981dbe6 Signed-off-by: James Ward <james.ward@arm.com>
2022-08-29Update framework test generator to support TF/TFL conv3d.TatWai Chong
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>
2022-08-26Align padding for transpose_conv2d to match specEric Kunze
Increasing out pad values now leads to increasing pad. Reference model changes, and test generator changes to match specification definition Change-Id: I4f3ebfbca5048354fb15bedc7ab640ff28ed853a Signed-off-by: Eric Kunze <eric.kunze@arm.com> Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com>
2022-06-17Fix reference model use of weight zero pointv0.30.0v0.30Eric Kunze
In the case of an int16xint8 test, the zero point was not being subtracted from the weights. Signed-off-by: Eric Kunze <eric.kunze@arm.com> Change-Id: Ic77119b200b952715870abc11d09d1a646da86b1
2022-06-15Remove quantization info from serialization attributesEric Kunze
Any needed information moves into the attributes for each operator. New serialization library version removes teh quantization information attributes from the schema Signed-off-by: Eric Kunze <eric.kunze@arm.com> Change-Id: Icf6165687ab1fd34a01f64c01b0b92b2820e72fa
2022-06-13Update transpose_conv2d to align with TOSA specTatWai Chong
Rename outpad to out_pad, and also fix the dilation in the generator. Change-Id: I4c1599871f0d0b41856e819d8c644a85ca6d8267 Signed-off-by: TatWai Chong <tatwai.chong@arm.com>
2022-06-07Remove dilation from transpose_conv2d opEric Kunze
It is not in the spec and is being removed from serialization Change-Id: I82a102de37d8eb75210088dfda2df9b2fadb9c74 Signed-off-by: Eric Kunze <eric.kunze@arm.com>
2022-06-07Align the serialization schema with TOSA 0.24.0 specificationTatWai Chong
The operators are pool, conv, reshape, slice, transpose, and table. Signed-off-by: TatWai Chong <tatwai.chong@arm.com> Change-Id: I13f8d626df59be14361068222746347ba69d2fb5
2022-05-16Initialize accumulator with bias value for CONV3DEric Kunze
Bias was mistakenly unused previously. Signed-off-by: Eric Kunze <eric.kunze@arm.com> Change-Id: If776e923f7b3cd442c7f147fcbd22a214c37fd36
2022-05-16Adjust divisor calculationEric Kunze
Fixes issue where pad_left < stride would cause padding values to be missed Signed-off-by: Eric Kunze <eric.kunze@arm.com> Change-Id: I2ba0d0969ce1f00e2cb3ca1ab293c5e15a0c7749
2022-04-28Update tensor ops ERROR_IF criteriaJeremy Johnson
Update to ref model to check ERROR_IF criteria for pooling and convolution ops to match specification Update to tosa_verif_build_tests to produce valid test ranges and new ERROR_IF tests Plus update pooling ops big kernel to 9 (from 6) for better testing coverage and set dilation to 1 and add out_pad bottom & right for transpose_conv2d to match specification Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com> Change-Id: Ic5759872d40ae8d3f3d07043d9a0f2fa0244d72e
2022-02-01Rework divisor calculation for AVGPOOL2DEric Kunze
Previous code assumed symmetric padding when calculating the divisor for the average pool, and had issues with extra padding. The padding now follows the definition from the specification. Extra padding to the right/bottom is ignored when calculating the average pool divisor. Change-Id: Ib05e2346c6e9d55b6fef5294322e58ee18ef4928
2021-11-11More ERROR_IF to check attribute for convolution opsKevin Cheng
Signed-off-by: Kevin Cheng <kevin.cheng@arm.com> Change-Id: I49d498dd3d4c069d8d1db07310f939268b9df4b7
2021-11-01Fix for tensor_ops.ccKevin Cheng
- MATMUL: only check a_zp/b_zp valid when this->qinfo exists - Fix typo in debug message Signed-off-by: Kevin Cheng <kevin.cheng@arm.com> Change-Id: I2cedcb25e4f57fcaec2caa1b850ea1232a023340
2021-10-21Fix pool2d generation and check to match specificationJeremy Johnson
Change output size error_if check in ref model to match specification. Remove size check from test generation as output shape is always correctly calculated. Change-Id: I5be64f31e6448b47e80fc0a4af11bb312f366a26 Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com>
2021-10-18More ERROR_IF supportsKevin Cheng
- Also delay tensor allocation after operator being validated ERROR_IF can be caught first before 0 or negative dimension set the graph_status to UNPREDICTABLE - Rescale, Argmax, FullyConnected, Matmul, Pad, Reshape, Slice, Transpose, Clamp, Concat, Equal, Greater, GreaterEqual, Table Signed-off-by: Kevin Cheng <kevin.cheng@arm.com> Change-Id: I4e1b3e5794fe195ce1a37e28443ae584645a3b91
2021-10-13Catch ERROR_IF on AVG_POOL2D and MAX_POOL2DKevin Cheng
Signed-off-by: Kevin Cheng <kevin.cheng@arm.com> Change-Id: I0947f136e768605f997fcaf74c6b9a7e62e748a4
2021-09-16Implement Conv3D kernel.Kevin Cheng
Signed-off-by: Kevin Cheng <kevin.cheng@arm.com> Change-Id: Ic16e918b1a2423ad563684e29ce70d9efdbf9c02
2021-09-15Rename attribute: Pool2d, Conv2d, TransposeConv2d -> Pool, Conv, TransposeConvKevin Cheng
Signed-off-by: Kevin Cheng <kevin.cheng@arm.com> Change-Id: I466dd1dcf5230e8e07df202ba88515e775e04a1e
2021-08-20Replace node level check ASSERT_MSG_NODE()/FATAL_ERROR_NODE() with REQUIRE() ↵Kevin Cheng
or ERROR_IF() - Adding return code enum class: {VALID, UNPREDICTABLE, ERROR} - Runtime errors (e.g. memory allocation failure) will abort immediately, or will return one of the three return codes Part of the codes are re-written to pass REQUIRE() to the top-level (e.g. apply_scale_32/16()) - Update setExpectedFailure() to setExpectedReturnCode() on test generation script - Update test regression script to interface with reference model change Signed-off-by: Kevin Cheng <kevin.cheng@arm.com> Change-Id: Ia063c936bcb2a54d6e379a5bb6801aa72d1186f1
2021-06-09adding batch dimension to MatMul.Kevin Cheng
Signed-off-by: Kevin Cheng <kevin.cheng@arm.com> Change-Id: I83f75dd5beb60fe7ca2d573ea0f81bac4cd62a07
2021-04-27Replace serialization/ and verif/ with MLPlatform's serialization_lib submoduleKevin Cheng
- Remove Usage and Format - Run black on verif/*.py scripts Signed-off-by: Kevin Cheng <kevin.cheng@arm.com> Change-Id: Ie81515891eb0039540f614894f4b6b0e0e78ba74
2021-02-01Remove AINT8Kevin Cheng
- Updated C and Py serialization libraries, updated licence files - Removed AINT8 from TOSA reference tests Signed-off-by: Kevin Cheng <kevin.cheng@arm.com> Signed-off-by: Jared Smolens <jared.smolens@arm.com> Change-Id: I860bfeaad5a075e50f569c8f6861927ebacf1378
2020-10-19Update apply_scale_32()Kevin Cheng
Signed-off-by: Kevin Cheng <kevin.cheng@arm.com> Change-Id: Ida8e3a17d74e5d6379b2244896ddf9e295d0ecc9
2020-10-14Initial checkin of TOSA reference_model and testsEric Kunze
Change-Id: I2f8e7fa63e2ae40203e57d2cc8814bde3b312cb6 Signed-off-by: Eric Kunze <eric.kunze@arm.com>