aboutsummaryrefslogtreecommitdiff
path: root/reference_model/src/ops/type_conversion.cc
AgeCommit message (Collapse)Author
2024-05-17Add missing signed/unsigned data types of input/output for RESCALE opWon Jeon
Signed-off-by: Won Jeon <won.jeon@arm.com> Change-Id: I1498313f56626011d39f765fed71f82be53b3d8d
2024-04-19Update float8 header and namespaceWon Jeon
Signed-off-by: Won Jeon <won.jeon@arm.com> Change-Id: I75840f6b4ff11a63c4c874f8ded23afb5a71ad55
2024-04-15[ref model] fix const/pad/clamp attribute serializationTai Ly
This changes to use native type serialization and deserialization for pad_const, clamp min_val/max_val and const data attribute values whereby fp16 values are stored as 2 bytes each, fp8 values are stored in 1 byte each, etc. Signed-off-by: Tai Ly <tai.ly@arm.com> Change-Id: Ia95d320fe8c546ce1d1ccc035d6e9bcaadcc9ca3
2024-04-08Fix the wrong QMax and QMin type assignment in rescale opTatWai Chong
Signed integer type is used to retain QMax and QMin no matter what the value of `output_unsigned` is, but the value of QMax and QMin are unsigned integer when output_unsigned is true. Also add a handful of arithmetic helpers to align the pseudo code. Change-Id: Ie3cd444a290ddae08884186cd4b349a88acad032 Signed-off-by: TatWai Chong <tatwai.chong@arm.com>
2024-04-08Modify Rescale signedness check to look at attributesEric Kunze
Also simplify the check to align the pesudo code structure. Signed-off-by: Eric Kunze <eric.kunze@arm.com> Signed-off-by: TatWai Chong <tatwai.chong@arm.com> Change-Id: I6023046026d2784dedd963b2b4d34a1117d45c23
2024-03-28Take into account of `output_unsigned` in rescale operationTatWai Chong
Set QMin and QMax based on the value of attribute `output_unsigned`. Change-Id: I7f21f3edd7311295285fb3988b3c800de114777a Signed-off-by: TatWai Chong <tatwai.chong@arm.com>
2024-03-06[ref model] Change RescaleOp attrs to inputsTai Ly
This patch implements changes required for RescaleOp's multiplier and shift changing from attributes to inputs Signed-off-by: Tai Ly <tai.ly@arm.com> Change-Id: I178919727e3220c749dad0ebce141e695868fee0
2024-02-21Add support for FP8 to reference modelWon Jeon
Signed-off-by: Won Jeon <won.jeon@arm.com> Change-Id: I99b70f94aff2ccd4af64875697e124eb60bc5b08
2024-01-03Fix Cast Float to Int overflowsJerry Ge
- For Casting from Float to Integers, if the input float is greater than INT_MAX, an overflow will happen when calling rint which causes the clipplings to be ineffectives - Moved all the range checks and clippings before rint to avoid this issue Signed-off-by: Jerry Ge <jerry.ge@arm.com> Change-Id: Ic189d59685b6d36464e3ef26766665148a660a14
2023-12-15Fix Cast FP32 to Int32 OverflowJerry Ge
- With input of 2147483648.00, the output overflows to -2147483648 - The root cause is the following: - std::rint still returns float, the existing implementation is forcing a cast from that float to int32_t - when the input is over INT32_MAX, the output right after rint will overflow which casues the clipplings later to be ineffective - Instead, perform the range check before rint Signed-off-by: Jerry Ge <jerry.ge@arm.com> Change-Id: Ib5a8cfd98aea17e326f8b11097beeb2d2b3efac9
2023-09-08Support new RESCALE attributesEric Kunze
input_unsigned and output_unsigned were added to the specification. Older TOSA files with uint data types are still supported. Signed-off-by: Eric Kunze <eric.kunze@arm.com> Change-Id: I125886ffc92975d99971e56e2075dd5d96bdbdc4
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-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-20Add level checking to TOSA Ref modelJerry Ge
Signed-off-by: Jerry Ge <jerry.ge@arm.com> Change-Id: I5689d7c6b902a319a68fa4628b59e0bcc23aeca4
2023-03-03Update CAST fp to int roundingEric Kunze
Use rint() instead of round() to get round to nearest even behavior Signed-off-by: Eric Kunze <eric.kunze@arm.com> Change-Id: I45957be0e863de2207850b023626a7c0ea11e5eb
2023-01-31Create MI tests for Type Conversion: CASTJames Ward
* Add exclusion regex's to conformance generation Signed-off-by: James Ward <james.ward@arm.com> Change-Id: I15bef7451efd5662065060242d35bd7fa3381487
2023-01-18Update for RESCALE spec apply_add clarificationJeremy Johnson
Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com> Change-Id: I6958904c2c8932e9fe03b3092672d62a06e96ee6
2022-11-18Zero point addition in RESCALE should be int32Eric Kunze
Clipping to the output range is done post zero point addition. Signed-off-by: Eric Kunze <eric.kunze@arm.com> Change-Id: I5271a08fb2f6f9804fb1af3c6945131f948f452a
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-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-05-26Add support for uint16_t to RESCALEJeremy Johnson
Update ref-model RESCALE op to support UINT16 conversions Add testing for RESCALE UINT16 and ERROR_IFs Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com> Change-Id: Ic6e6e53de1f0b054bedb9e6ba3856e7475498aba
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-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-04-30Support 16-bit RescaleKevin Cheng
Signed-off-by: Kevin Cheng <kevin.cheng@arm.com> Change-Id: Ifc80b83c1abcd08e1b7f8e50f647b74c861bc933
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-11-12Implement and add unit tests for MUL and ARITHMETIC_RIGHT_SHIFTKevin Cheng
add .clang-format Add expected failure for RESIZE and RESCALE unit tests Signed-off-by: Kevin Cheng <kevin.cheng@arm.com> Change-Id: I33c8afdc8998e8518f2b0e5fabddd36ce3aa2ee9
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>