Skip to content

The output of the MaxPooling contains -INF #10120

Closed

Description

@sun2011yao

What happened?

HI, excuse me. I met a problem. MaxPooling results are wrong, contains -INF. I ran the mlir file below

"builtin.module"() ({ "func.func"() ({ ^bb0(%arg0: !iree_input.buffer_view): %0 = "mhlo.constant"() {value = dense<0xFF800000> : tensor<f32>} : () -> tensor<f32> %1 = "iree_input.cast.buffer_view_to_tensor"(%arg0) : (!iree_input.buffer_view) -> tensor<1x28x28x480xf32> %2 = "mhlo.reduce_window"(%1, %0) ({ ^bb0(%arg1: tensor<f32>, %arg2: tensor<f32>): %4 = "mhlo.maximum"(%arg1, %arg2) : (tensor<f32>, tensor<f32>) -> tensor<f32> "mhlo.return"(%4) : (tensor<f32>) -> () }) {padding = dense<[[0, 0], [0, 1], [0, 1], [0, 0]]> : tensor<4x2xi64>, window_dimensions = dense<[1, 3, 3, 1]> : tensor<4xi64>, window_strides = dense<[1, 2, 2, 1]> : tensor<4xi64>, lowering_config = #iree_codegen.lowering_config<tile_sizes= [[1, 1, 32, 4, 4]]>} : (tensor<1x28x28x480xf32>, tensor<f32>) -> tensor<1x14x14x480xf32> %3 = "iree_input.cast.tensor_to_buffer_view"(%2) : (tensor<1x14x14x480xf32>) -> !iree_input.buffer_view "func.return"(%3) : (!iree_input.buffer_view) -> () }) {function_type = (!iree_input.buffer_view) -> !iree_input.buffer_view, iree.abi = "{\22a\22:[[\22named\22,\22x\22,[\22ndarray\22,\22f32\22,4,1,28,28,480]]],\22r\22:[[\22sdict\22,[\22output_0\22,[\22ndarray\22,\22f32\22,4,1,14,14,480]]]],\22v\22:1}", sym_name = "serving_default"} : () -> () }) : () -> ()

Steps to reproduce your issue

  1. iree-compile maxpooling.mlir
    --mlir-disable-threading
    --mlir-elide-elementsattrs-if-larger=10
    -iree-input-type=mhlo
    -iree-hal-target-backends=cuda
    --iree-hal-cuda-llvm-target-arch=sm_80
    -iree-mlir-to-vm-bytecode-module
    --mlir-print-ir-after-change
    --mlir-print-ir-before-all
    --mlir-print-ir-after-all
    -o maxpooling.vmfb

  2. iree-run-module --print_max_element_count=1000000 --module_file=maxpooling.vmfb --device=cuda --entry_function=serving_default --function_input="1x28x28x480xf32=[[[[-1.f]]]]"

  3. output contains -INF values

What component(s) does this issue relate to?

MLIR, Compiler

Version information

No response

Additional context

Looks like the problem is that tilesize is not divisible? If change input shape to 28x28x640(tilesize=[1,1,64]), the result looks normal

Activity

  1. moved this to Done in IREEon Aug 17, 2022
  2. jpienaar commented on Aug 17, 2022

    @jpienaar
    Member

    Could you also add the input tensor program here?

  3. moved this from Done to Not Started in IREEon Aug 17, 2022
  4. sun2011yao commented on Aug 17, 2022

    @sun2011yao
    Author

    2. iree-run-module --print_max_element_count=1000000 --module_file=maxpooling.vmfb --device=cuda --entry_function=serving_default --function_input="1x28x28x480xf32=[[[[-1.f]]]]"

    Here is the specified input

  5. jpienaar commented on Aug 17, 2022

    @jpienaar
    Member

    I meant the input program at purely tensor level before it gets to buffer.

    %0 = "mhlo.constant"() {value = dense<0xFF800000> : tensor} : () -> tensor

    does not have valid types being used. It would need at least element types.

  6. sun2011yao commented on Aug 18, 2022

    @sun2011yao
    Author

    "builtin.module"() ({ "func.func"() ({ ^bb0(%arg0: !iree_input.buffer_view): %0 = "mhlo.constant"() {value = dense<0xFF800000> : tensor<f32>} : () -> tensor<f32> %1 = "iree_input.cast.buffer_view_to_tensor"(%arg0) : (!iree_input.buffer_view) -> tensor<1x28x28x480xf32> %2 = "mhlo.reduce_window"(%1, %0) ({ ^bb0(%arg1: tensor<f32>, %arg2: tensor<f32>): %4 = "mhlo.maximum"(%arg1, %arg2) : (tensor<f32>, tensor<f32>) -> tensor<f32> "mhlo.return"(%4) : (tensor<f32>) -> () }) {padding = dense<[[0, 0], [0, 1], [0, 1], [0, 0]]> : tensor<4x2xi64>, window_dimensions = dense<[1, 3, 3, 1]> : tensor<4xi64>, window_strides = dense<[1, 2, 2, 1]> : tensor<4xi64>, lowering_config = #iree_codegen.lowering_config<tile_sizes= [[1, 1, 32, 4, 4]]>} : (tensor<1x28x28x480xf32>, tensor<f32>) -> tensor<1x14x14x480xf32> %3 = "iree_input.cast.tensor_to_buffer_view"(%2) : (tensor<1x14x14x480xf32>) -> !iree_input.buffer_view "func.return"(%3) : (!iree_input.buffer_view) -> () }) {function_type = (!iree_input.buffer_view) -> !iree_input.buffer_view, iree.abi = "{\22a\22:[[\22named\22,\22x\22,[\22ndarray\22,\22f32\22,4,1,28,28,480]]],\22r\22:[[\22sdict\22,[\22output_0\22,[\22ndarray\22,\22f32\22,4,1,14,14,480]]]],\22v\22:1}", sym_name = "serving_default"} : () -> () }) : () -> ()

    Sorry, there was a problem with the mlir file uploaded before, I updated the file

  7. jpienaar commented on Aug 18, 2022

    @jpienaar
    Member
    ../iree-build/tools/iree-compile /tmp/10120.mlir --mlir-disable-threading -iree-input-type=mhlo -iree-hal-target-backends=llvm-cpu -iree-mlir-to-vm-bytecode-module -o maxpooling.vmfb
    ../iree-build/tools/iree-run-module --print_max_element_count=1000000 --module_file=maxpooling.vmfb --entry_function=serving_default --function_input="1x28x28x480xf32=[[[[-1.f]]]]"

    returns all -1. So maybe something on GPU. I don't have a GPU, but will tag GPU codegen to triage.

    (tested at 9cdcc05)

  8. added
    codegen
    on Aug 18, 2022
  9. sun2011yao commented on Aug 18, 2022

    @sun2011yao
    Author
    ../iree-build/tools/iree-compile /tmp/10120.mlir --mlir-disable-threading -iree-input-type=mhlo -iree-hal-target-backends=llvm-cpu -iree-mlir-to-vm-bytecode-module -o maxpooling.vmfb
    ../iree-build/tools/iree-run-module --print_max_element_count=1000000 --module_file=maxpooling.vmfb --entry_function=serving_default --function_input="1x28x28x480xf32=[[[[-1.f]]]]"

    returns all -1. So maybe something on GPU. I don't have a GPU, but will tag GPU codegen to triage.

    (tested at 9cdcc05)

    OK, i ran it on an A100

  10. added
    codegen/nvvm
    on Aug 18, 2022
  11. self-assigned this
    on Aug 18, 2022
  12. allieculp commented on Aug 18, 2022

    @allieculp

    @ThomasRaoux Please help review this new issue and add priority!

  13. ThomasRaoux commented on Aug 19, 2022

    @ThomasRaoux
    Contributor

    We were missing some barriers for some cases. Sent a PR to fix it: #10137

  14. Repository owner moved this from Not Started to Done in IREEon Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🐞codegencodegen/nvvm

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions