Allow non-standard output shape
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 333
- Forks
- 150
- Avg merge
- 4d 19h
- Merged PRs (30d)
- 54
Description
When the final output is a non-standard shape, the compile passes will add a contiguous_kernel to make it into a standard shape.
Following python script can reproduce this issue:
import migraphx
p = migraphx.program()
mm = p.get_main_module()
mgx_shape = migraphx.shape(lens=[2, 1, 4], type='float_type')
inp = mm.add_parameter('x', mgx_shape)
out = mm.add_instruction(migraphx.op('multibroadcast', out_lens=[2, 4, 4]),
[inp])
mm.add_return([out])
print("Uncompiled Program: ")
print(p)
p.compile(migraphx.get_target('gpu'), offload_copy=False)
print("Compiled Program: ")
print(p)
Output:
Uncompiled Program:
module: "main"
x = @param:x -> float_type, {2, 1, 4}, {4, 4, 1}
main:@1 = multibroadcast[out_lens={2, 4, 4}](x) -> float_type, {2, 4, 4}, {4, 0, 1}
main:@2 = @return(main:@1)
Compiled Program:
module: "main"
main:@0 = check_context::migraphx::version_1::gpu::context -> float_type, {}, {}
main:@1 = hip::hip_allocate_memory[shape=float_type, {0}, {1},id=main:scratch] -> float_type, {0}, {1}
main:#output_0 = @param:main:#output_0 -> float_type, {2, 4, 4}, {16, 4, 1}
x = @param:x -> float_type, {2, 1, 4}, {4, 4, 1}
main:@4 = multibroadcast[out_lens={2, 4, 4}](x) -> float_type, {2, 4, 4}, {4, 0, 1}
main:@5 = gpu::code_object[code_object=13640,symbol_name=contiguous_kernel,global=1024,local=1024,](main:@4,main:#output_0) -> float_type, {2, 4, 4}, {16, 4, 1}
main:@6 = @return(main:@5)
When integrating with PyTorch, some pipelines require the accelerator to output non-standard shapes. In the able example the compiled program should output float_type, {2, 4, 4}, {4, 0, 1} to be compatible.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the Python reproducer with the GPU target and compare the uncompiled and compiled shapes. Trace the compile passes that introduce contiguous_kernel and the output parameter; the fix is done when the compiled program preserves the non-standard output shape {2, 4, 4}, {4, 0, 1} and remains compatible with the reported PyTorch pipeline.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- backend, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100