Skip to content

Conversation

@chentong319
Copy link
Collaborator

  1. Add two new options: shapeInformationUB and shapeInformationLB. They are in the similar format to shapeInformation but specify the upper bound and lower bound of the dimensions of input. One use case is the max sequence length. Another possible use case is minimum batch size.
  2. Insert runtime check on the actual inputs if the UB or LB is specified.
  3. I tested cases. Not sure how to add such runtime test cases which may generate assertion error into our test set.

Signed-off-by: Tong Chen <[email protected]>
@chentong319 chentong319 requested a review from tungld December 9, 2025 14:16
Copy link
Member

@tungld tungld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to put upper and lower bounds into the argument attributes when importing a model and then to the input signature when lowering onnx.EntryPoint to krnl.entry_point.

For example, the input argument is like this:

func.func @main_graph(%arg0: tensor<?xf32> {onnx.name = "x", 
   onnx.dim_params = "0:a", onnx.dim_lbs="0:5", onnx.dim_ubs="0:50"}

When lowering onnx.EntryPoint to krnl, krnl.entry_pointwe will have this json info for input signature:

{"type" : "f32" , "dims" : [-1] , "lbs": [5], "ubs": [50], "name": "x"}

We can even replace "dims": [-1] by "dims": ['a'].


switch (boundType) {
case 0: // UB
noLessOrFailed(module, rewriter, loc,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look like this should be for LB.

"verifyInputTensors failed: the upper bound for the input " +
std::to_string(inputID) + " of dimension " +
std::to_string(dimID) +
" is set by --shapeInformationLB as " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shapeInformationUB?

noGreaterOrFailed(module, rewriter, loc,
create.llvm.constant(int64Ty, static_cast<int64_t>(bound)),
actualDim,
"verifyInputTensors failed: the upper bound for the input " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "the upper bound" -> "the lower bound"

@chentong319
Copy link
Collaborator Author

Yes, we can transfer the UB and LB info to function op. Then we support information coming from command line and from model (.mlir or .onnx).

@chentong319
Copy link
Collaborator Author

To avoid the confusion of UB or LB, I introduced a enumerate type.

@tungld
Copy link
Member

tungld commented Dec 12, 2025

Yes, we can transfer the UB and LB info to function op. Then we support information coming from command line and from model (.mlir or .onnx).

@chentong319 please let us know if you plan to implement this here or in another PR. Thanks!

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.

3 participants