cruise-automation / mlir-tcp

Tensor Compute Primitives: Mid-level Intermediate Representation for Machine Learning Programs
Other
35 stars 7 forks source link

Add ops for rounding #66

Closed navahgar closed 5 months ago

navahgar commented 5 months ago

This PR adds two Tcp ops for rounding.

tcp.round - rounds the input value, with halfway cases rounded away from zero. tcp.round_even - rounds in the input value, with halfway cases rounded to the nearest even integer.

This PR includes the following:

Since torch.round rounds halfway cases to even, it maps directly to tcp.round_even. There is no direct way to represent the other case (rounding away from zero) in PyTorch.

The AOT test for tcp.round_even is through torch.round, whereas the AOT test for tcp.round is from a Tcp IR representation.