Open YellowHCH opened 2 years ago
Hi @gadagashwini ! Could you look at this issue. Thank you!
HI @YellowHCH, As per the https://github.com/tensorflow/tensorflow/blob/master/tensorflow/compiler/mlir/tosa/transforms/legalize_common.cc#L2461-L2467
// FloorMod lowering:
// (1/rhs * lhs) - floor(1/rhs * lhs)
As per the doc https://tensorflow.google.cn/api_docs/python/tf/raw_ops/FloorMod?version=nightly
floormod(x, y) = x - floor(x / y) * y
Both are same. Thank you!
Hi @gadagashwini I noticed that there is a TF FloorMod reference implement here: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/kernels/internal/reference/floor_mod.h#L29
In my point of view,floormod(x, y) = x - floor(x / y) * y
is equivalent to the implementation of above, but not equivalent to (1/rhs * lhs) - floor(1/rhs * lhs)
, seems it missing a multiplier rhs
i means rhs * ( (1/rhs * lhs) - floor(1/rhs * lhs) )
Please correct me if I'm wrong. thanks!
This issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Thank you.
Closing as stale. Please reopen if you'd like to work on this further.
Hi @YellowHCH, rhs
is missing.Thank you
Thanks for opening the issue.
The implemenatation of raw_ops.floor_div as mentioned in the document is right way and it internally callsgen_math_ops
code file, which does not use the logic of https://github.com/tensorflow/tensorflow/blob/master/tensorflow/compiler/mlir/tosa/transforms/legalize_common.cc#L2461-L2467,
However, I have created a PR to changed the implementation of mlir/tosa floor_div.
Sounds like this issue was resolved, please reopen if not.
Hello
Click to expand!
### Issue Type Bug ### Source source ### Tensorflow Version 2.9.1 ### Custom Code No ### OS Platform and Distribution Linux Ubuntu 20.04 ### Mobile device _No response_ ### Python version 3.9 ### Bazel version 5.1 ### GCC/Compiler version 9 ### CUDA/cuDNN version _No response_ ### GPU model and memory _No response_ ### Current Behaviour? ```shell from source code: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/compiler/mlir/tosa/transforms/legalize_common.cc#L2457 floormod(x, y) = x / y - floor(x / y) from doc:https://tensorflow.google.cn/api_docs/python/tf/raw_ops/FloorMod?version=nightly floormod(x, y) = x - floor(x / y) * y I wonder if I misunderstood ``` ### Standalone code to reproduce the issue ```shell tosa ir I get: ' module attributes {tf.versions = {bad_consumers = [], min_consumer = 0 : i32, producer = 561 : i32}, tf_saved_model.semantics} { func.func @serving_default(%arg0: tensor<11x10xf32> {tf_saved_model.index_path = ["model_input1"]}, %arg1: tensor