Add Int4 and UInt4 support for Cast #24973
implement TensorCaster specializations for int4/uint4
2ac57eb7
Create unit tests
e8dc543a
update shape inside tests
a4dc2303
fix bug in tests
6d0c0339
update test names
49792061
Add CastTo/FromString and TensorCasterNoSat specializations
6e34f5b6
fix warning
61d50d8c
apply lintrunner
24874115
output low nibble first
e2f6f028
Update to use Rv10 instead of Rv9 (breaks build)
4ffef5f7
more than 1 partial specialization
e0079c0a
cannot convert OldType to NewType
6157a9df
remove macros, expand specializations
8cd52370
merge together similar specializations
5e23ee2c
remove unused aliases
9d50386e
clean up template specializations
8474ca73
reuse existing aliases, refactor for consistency
1ddcb968
fix multiple partial specializations issue for MLFloat16
1d02ca1d
clean up std::string specializtions
406666fc
Add specializations for Int4x2 -> UInt4x2 and UInt4x2 -> Int4x2
13a9c179
more concise Int4ElementConverter
bcb24127
more concise ToInt4ElementConverter
cb205e5d
merge a few TensorCaster specializations
1e8f6809
merge a few more TensorCaster specializations
2d1ca00b
styling suggestions, lint
18b3b11c
update iterations over the input
8ceae1b6
update iteration
bb806e43
Update opset in unit tests to support int4
68259740
amarin16
marked this pull request as ready for review 1 year ago
Add unit tests
b9807628
add more unit tests
207e5df0
update string implementation and add tests
8ab01619
lint
c81c5021
add MLFloat16 tests
7e4ce012
update iteration, add test for odd elements
6ec215c8
add specialization from float to MLFloat16
b39a4f43
try to fix pipeline errors
351626ef
lint
3b84c142
Try [[noreturn]] to fix pipelines
b5ecbf9a
supress 4702 warning
b19df98a
try pipeline fix
77b1916b
lint
83819568
disable warning
3d9be2fe
move pragma statements
9ce545aa
update pragma
082ae757
Merge branch 'main' into dev/emarin/cast_int4
234e7f04
Update docs for Cast
c70e7f3a
Update onnx patch
950a8e32
update patch
41af71b6
update patch
5b794763
keep binskim.patch in sync with onnx.patch
b39c660a
update patches
10b2eea2
exclude onnx tests in TestCase.cc
c89e11f3
remove patch fixes
da7e4448
merge main
408ae63b
Add newline at end of patch files
be31bdd2
explicitly mention next onnx version in skipped tests
ea2956c3
use std::is_floating_point_v
989719a1
use constants for min anx max (u)int4 values
e2be2442
use constexpr if to merge specializations
c7c05faa
use constexpr if to merge specializations for Int4
39321998
remove extra line
5e00b26f
remove anonymous namespace
af00c7df
update IsOrtFloat8Type usage
fe03e231
update cast between int4x2 and uint4x2 and tests, add Int4x2ToUInt64 …
d382f2c9
Update cast down implementation and tests
82b1fb5c
Fix pipeline issue
f1f4e2e8
fix pipeline issue
2b4c325c
debug pipeline issue
18521cc9
rename
de3c01be
remove debugging tests
0dfb771e
lint
338c4408
Merge branch 'main' into dev/emarin/cast_int4
1a22e4ba
Update TensorCasterNoSat for Int4/UInt4, add tests with saturate = false
6d76f96f
Add comments, extract common logic into lambda
6cbeea49
extract FromInt4Converter into separate struct, rename converter
ed92b066
add IsOrtInt4Type, use UnpackedType, merge specializations
fad04455
specialize ToInt4Converter for bool, merge TensorCaster from bool spe…
343a22c3
refactor ToInt4Converter, merge TensorCaster to Int4 specializations
195780ed
enforce float 8 DstType for TensorCasterNoSat
506a48b7
refactor ToInt4Converter, merge specializations
bc9edef1
Refactor ToInt4Converter, merge specializations
4d652f04
rename type, update comments
27a448af
small refactor
fa705d63
update comments, test values
4a65285d
Add 2 tests
226c6dc3
merge int4 -> string specialization with int4 -> numeric
6d97d37a
reuse ToInt4Converter inside string specializations
be6c1767
Merge string -> int4 and string -> uint4 specializations
003adaeb
parse string as double, add test
27040c1f
Merge string -> int4 with numeric -> int4 specializations
9a64f1cc
Add test
416635f8
tianleiwu
approved these changes
on 2025-07-22
amarin16
merged
51b678f8
into main 323 days ago
amarin16
deleted the dev/emarin/cast_int4 branch 323 days ago
Assignees
No one assigned
Login to write a write a comment.
Login via GitHub