iree: Not able to fold set_encoding(constant) -> constant in data tiling path

Coming from https://github.com/iree-org/iree/pull/11284, the set_encoding(constant) is not folded into a constant. This happens automatically in legacy mmt4d path because the set_encoding op is expand_reshape + transpose. The fusion on tensors can fold expand_reshape(constant) into a constant; a pattern transposes the constant.

If we can fold set_encoding(constant) -> constant, we can save ~360 flow.dispatch calls for FP32 mobilebert. There are ~2700 kernel launches in total, which means that we can save ~13% of kernel launch.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 45 (29 by maintainers)

Commits related to this issue

Most upvoted comments

Could we discuss this on GVC sometime… They might be a different solution than what is being discussed here.

We’ll need to fix it properly (no flag) but I don’t think we need to do that all in one step to start - I say go for the workaround and we make sure we’re tracking removing it as part of the larger data tiling work.

I got an idea to unblock the actual users while we figure this out. Current users have dimensions that are static and are multiples of sufficiently large powers of two that they could use a flag of the form --iree-flow-data-tiling-assume-all-tile-sizes-divide=16 that would allow SetEncoding to eschew padding.

The fix in CPUMaterializeEncodingPass is to have a place where the presence of a target attribute overrides what is specified in the hal.executable.variant

This should be working like this already: we should always use the HALExecutableTargetAttr::lookup helper, which should check for a target attribute first before walking up to the enclosing variant.