Skip to content

Commit

Permalink
[docs] Extend landing page with installation instructions (#1494)
Browse files Browse the repository at this point in the history
- Add ONNX Script installation instructions via link to Github Repo
- Add type annotations for match_condition
  • Loading branch information
shubhambhokare1 authored May 4, 2024
1 parent e0a7c9a commit d91b253
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 6 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ myst:

# ONNX Script

For instructions on how to install **ONNX Script** refer to [ONNX Script Github Repo](https://github.com/microsoft/onnxscript)


## Overview

{{ onnxscript }} enables developers to naturally author ONNX functions and
Expand Down Expand Up @@ -36,7 +39,8 @@ ONNX models and functions:
Note that the runtime is intended to help understand and debug function definitions.
Performance is not a goal here.

### Example

## Example

The following toy example illustrates how to use onnxscript.

Expand Down Expand Up @@ -96,6 +100,7 @@ result = MatmulAdd(x, wt, bias)
```{toctree}
:maxdepth: 1
Overview <self>
tutorial/index
api/index
intermediate_representation/index
Expand Down
10 changes: 6 additions & 4 deletions docs/tutorial/rewriter/examples/broadcast_matmul.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ def matmul_pattern(op, input_a: ir.Value, input_b: ir.Value, **_):
# =====================


def check_if_need_reshape(input_a, input_b, shape_c, **_) -> bool:
def check_if_need_reshape(
input_a: ir.Value, input_b: ir.Value, shape_c: ir.Value, **_
) -> bool:
"""If matmul broadcasting is enough, then we don't need the reshapes.
To validate this, we need to check the following:
Expand All @@ -89,7 +91,7 @@ def check_if_need_reshape(input_a, input_b, shape_c, **_) -> bool:
shape_c.shape,
)
return False
shape_c = shape_c.tolist()
shape_c_list = shape_c.tolist()

# NOTE: When there is a subset match with a pattern. The MatchResult won't have the shape
# information. So, we need to check if the shape is None and return False.
Expand Down Expand Up @@ -161,10 +163,10 @@ def check_if_need_reshape(input_a, input_b, shape_c, **_) -> bool:
broadcast_matmul_output_shape = broadcast_matmul_output_shape[:-1]
if mimic_matmul_broadcast_behavior and dim_a == 2:
broadcast_matmul_output_shape.pop(-2)
if shape_c != broadcast_matmul_output_shape:
if shape_c_list != broadcast_matmul_output_shape:
logger.info(
"Final output shape is not the same. Expected %s vs actual %s",
shape_c,
shape_c_list,
broadcast_matmul_output_shape,
)
return False
Expand Down

0 comments on commit d91b253

Please sign in to comment.