Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ARITH] Allow Analyzer to MarkGlobalNonNegValue #15193

Merged
merged 1 commit into from
Jul 3, 2023

Conversation

tqchen
Copy link
Member

@tqchen tqchen commented Jul 2, 2023

This PR introduces an utility function MarkGlobalPositiveValue. This function allows analyzer to mark buffer shapes in function arguments as positive globally and opens doors for more symbolic simplification.

@tvm-bot
Copy link
Collaborator

tvm-bot commented Jul 2, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

@tqchen tqchen force-pushed the arith-global-positive branch from f171197 to e6d2e92 Compare July 2, 2023 16:04
@tqchen tqchen changed the title [ARITH] Allow Analyzer to MarkGlobalPositiveValue [ARITH] Allow Analyzer to MarkGlobalNonNegValue Jul 2, 2023
@tqchen tqchen force-pushed the arith-global-positive branch from e6d2e92 to f815742 Compare July 2, 2023 16:05
This PR introduces an utility function MarkGlobalNonNegValue.
This function allows analyzer to mark buffer shapes in function arguments
as positive globally and opens doors for more symbolic simplification.
@tqchen tqchen force-pushed the arith-global-positive branch from f815742 to 68d038b Compare July 2, 2023 18:51
@junrushao junrushao merged commit fb64be3 into apache:main Jul 3, 2023
junrushao added a commit to junrushao/tvm that referenced this pull request Jul 3, 2023
This PR enhance the arithmetic analysis used in compute-at to further
help symbolic bound simplification.

Previously, when a variable `n` appears in the shape of an input buffer
`T.Buffer((n * 32), "float32")`, we could safely assume that `n` is
nonnegative as it is part of the shape. This could help us simplify some
bounds during scheduling as well as lowering.

For example, for integers `n` and `bx` where `bx` has a symbolic bound
`[0, 32 * n)`, if `n` is nonnegative, we could simplify the following
expressions to True:

```
0 <= floordiv(bx, n) < 32
0 <= floormod(bx, n) < n
```

This PR depends on apache#15193 to provide an interface that hints analyzer.
junrushao pushed a commit to junrushao/tvm that referenced this pull request Jul 3, 2023
This PR introduces an utility function MarkGlobalNonNegValue.
This function allows analyzer to mark buffer shapes in function arguments
as positive globally and opens doors for more symbolic simplification.
junrushao added a commit to junrushao/tvm that referenced this pull request Jul 3, 2023
This PR enhance the arithmetic analysis used in compute-at to further
help symbolic bound simplification.

Previously, when a variable `n` appears in the shape of an input buffer
`T.Buffer((n * 32), "float32")`, we could safely assume that `n` is
nonnegative as it is part of the shape. This could help us simplify some
bounds during scheduling as well as lowering.

For example, for integers `n` and `bx` where `bx` has a symbolic bound
`[0, 32 * n)`, if `n` is nonnegative, we could simplify the following
expressions to True:

```
0 <= floordiv(bx, n) < 32
0 <= floormod(bx, n) < n
```

This PR depends on apache#15193 to provide an interface that hints analyzer.
junrushao added a commit to junrushao/tvm that referenced this pull request Jul 3, 2023
This PR enhance the arithmetic analysis used in compute-at to further
help symbolic bound simplification.

Previously, when a variable `n` appears in the shape of an input buffer
`T.Buffer((n * 32), "float32")`, we could safely assume that `n` is
nonnegative as it is part of the shape. This could help us simplify some
bounds during scheduling as well as lowering.

For example, for integers `n` and `bx` where `bx` has a symbolic bound
`[0, 32 * n)`, if `n` is nonnegative, we could simplify the following
expressions to True:

```
0 <= floordiv(bx, n) < 32
0 <= floormod(bx, n) < n
```

This PR depends on apache#15193 to provide an interface that hints analyzer.
tqchen pushed a commit that referenced this pull request Jul 3, 2023
This PR enhance the arithmetic analysis used in compute-at to further
help symbolic bound simplification.

Previously, when a variable `n` appears in the shape of an input buffer
`T.Buffer((n * 32), "float32")`, we could safely assume that `n` is
nonnegative as it is part of the shape. This could help us simplify some
bounds during scheduling as well as lowering.

For example, for integers `n` and `bx` where `bx` has a symbolic bound
`[0, 32 * n)`, if `n` is nonnegative, we could simplify the following
expressions to True:

```
0 <= floordiv(bx, n) < 32
0 <= floormod(bx, n) < n
```

This PR depends on #15193 to provide an interface that hints analyzer.
junrushao added a commit to junrushao/tvm that referenced this pull request Jul 4, 2023
This PR enhances Decode-GEMV rule with the following changes:
- Normalize the GEMV iter domain to S-R-C via transform-block-layout.
  This would help with further analysis and scheduling, in cases for
  example, when there was no spatial loop in the original reduction
  block.
- Get rid of the ad hoc iter type analysis, including the logic calling
  into a TVM packed func `tir.schedule.GetLoopIterType` using
  `tvm._ffi.get_global_func`.
- Split out the logic for two separate cases of scheduling, where the
  innermost dimension is spatial or reduction.
- Introduces `suggest_threads_per_block` to guess the threads to be
  allocated each threadblock. This helps avoid the previous case where
  dlight allocates 256 threads for a workload whose degree of parallelism
  is only 128.
- Misc improvements.

This rest of the changes are split out to separate PRs that are already
merged to main.
- [x] Pass the hints to arithmetic analyzer that shape variables should
be positive ones (apache#15210)
- [x] Eliminate unnecessary block predicate generation - should be
provable via affine analysis (apache#15193)
- [x] Shrink local memory allocation if only one element `X[threadIdx.x]`
is used (apache#15207)
junrushao added a commit to junrushao/tvm that referenced this pull request Jul 4, 2023
This PR enhances Decode-GEMV rule with the following changes:
- Normalize the GEMV iter domain to S-R-C via transform-block-layout.
  This would help with further analysis and scheduling, in cases for
  example, when there was no spatial loop in the original reduction
  block.
- Get rid of the ad hoc iter type analysis, including the logic calling
  into a TVM packed func `tir.schedule.GetLoopIterType` using
  `tvm._ffi.get_global_func`.
- Split out the logic for two separate cases of scheduling, where the
  innermost dimension is spatial or reduction.
- Introduces `suggest_threads_per_block` to guess the threads to be
  allocated each threadblock. This helps avoid the previous case where
  dlight allocates 256 threads for a workload whose degree of parallelism
  is only 128.
- Misc improvements.

This rest of the changes are split out to separate PRs that are already
merged to main.
- [x] Pass the hints to arithmetic analyzer that shape variables should
be positive ones (apache#15210)
- [x] Eliminate unnecessary block predicate generation - should be
provable via affine analysis (apache#15193)
- [x] Shrink local memory allocation if only one element `X[threadIdx.x]`
is used (apache#15207)
junrushao added a commit to junrushao/tvm that referenced this pull request Jul 4, 2023
This PR enhances Decode-GEMV rule with the following changes:
- Normalize the GEMV iter domain to S-R-C via transform-block-layout.
  This would help with further analysis and scheduling, in cases for
  example, when there was no spatial loop in the original reduction
  block.
- Get rid of the ad hoc iter type analysis, including the logic calling
  into a TVM packed func `tir.schedule.GetLoopIterType` using
  `tvm._ffi.get_global_func`.
- Split out the logic for two separate cases of scheduling, where the
  innermost dimension is spatial or reduction.
- Introduces `suggest_threads_per_block` to guess the threads to be
  allocated each threadblock. This helps avoid the previous case where
  dlight allocates 256 threads for a workload whose degree of parallelism
  is only 128.
- Misc improvements.

This rest of the changes are split out to separate PRs that are already
merged to main.
- [x] Pass the hints to arithmetic analyzer that shape variables should
be positive ones (apache#15210)
- [x] Eliminate unnecessary block predicate generation - should be
provable via affine analysis (apache#15193)
- [x] Shrink local memory allocation if only one element `X[threadIdx.x]`
is used (apache#15207)
junrushao added a commit to junrushao/tvm that referenced this pull request Jul 4, 2023
This PR enhances Decode-GEMV rule with the following changes:
- Normalize the GEMV iter domain to S-R-C via transform-block-layout.
  This would help with further analysis and scheduling, in cases for
  example, when there was no spatial loop in the original reduction
  block.
- Get rid of the ad hoc iter type analysis, including the logic calling
  into a TVM packed func `tir.schedule.GetLoopIterType` using
  `tvm._ffi.get_global_func`.
- Split out the logic for two separate cases of scheduling, where the
  innermost dimension is spatial or reduction.
- Introduces `suggest_threads_per_block` to guess the threads to be
  allocated each threadblock. This helps avoid the previous case where
  dlight allocates 256 threads for a workload whose degree of parallelism
  is only 128.
- Misc improvements.

This rest of the changes are split out to separate PRs that are already
merged to main.
- [x] Pass the hints to arithmetic analyzer that shape variables should
be positive ones (apache#15210)
- [x] Eliminate unnecessary block predicate generation - should be
provable via affine analysis (apache#15193)
- [x] Shrink local memory allocation if only one element `X[threadIdx.x]`
is used (apache#15207)
junrushao added a commit to junrushao/tvm that referenced this pull request Jul 5, 2023
This PR enhances Decode-GEMV rule with the following changes:
- Normalize the GEMV iter domain to S-R-C via transform-block-layout.
  This would help with further analysis and scheduling, in cases for
  example, when there was no spatial loop in the original reduction
  block.
- Get rid of the ad hoc iter type analysis, including the logic calling
  into a TVM packed func `tir.schedule.GetLoopIterType` using
  `tvm._ffi.get_global_func`.
- Split out the logic for two separate cases of scheduling, where the
  innermost dimension is spatial or reduction.
- Introduces `suggest_threads_per_block` to guess the threads to be
  allocated each threadblock. This helps avoid the previous case where
  dlight allocates 256 threads for a workload whose degree of parallelism
  is only 128.
- Misc improvements.

This rest of the changes are split out to separate PRs that are already
merged to main.
- [x] Pass the hints to arithmetic analyzer that shape variables should
be positive ones (apache#15210)
- [x] Eliminate unnecessary block predicate generation - should be
provable via affine analysis (apache#15193)
- [x] Shrink local memory allocation if only one element `X[threadIdx.x]`
is used (apache#15207)
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