Skip to content

fix: Map each parameter of a block default expression to the argument at its position - #163

Open
georgeguimaraes wants to merge 1 commit into
elixir-nx:mainfrom
georgeguimaraes:fix/block-default-params
Open

georgeguimaraes wants to merge 1 commit into
elixir-nx:mainfrom
georgeguimaraes:fix/block-default-params

Conversation

@georgeguimaraes

Copy link
Copy Markdown
Member

expand_block_via_default/4 zipped the parameters that the default expression reaches with all block arguments. When the default function ignores an argument, the expression does not reach its parameter. So every later parameter read the argument before its own. For example, with fn _struct, _a, b -> Nx.multiply(b, 2) end, the compiled block multiplied a in place of b.

Each parameter now reads the argument at its own position, which is the first argument of the parameter node. The option lists after the tensor arguments are not arguments of the program, so the map leaves them out.

The new test uses a block that no lowering recognizes, so it lowers through its default function. It fails without the fix.

… at its position

expand_block_via_default/4 zipped the parameters that the default expression reaches with all block arguments. When the default function ignores an argument, every parameter after it read the argument before its own. Each parameter now reads the argument at its position. The option lists after the tensor arguments are not arguments of the program.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant