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

feat(example): Add a python example to codegen whole gemm. #20

Merged
merged 14 commits into from
Sep 20, 2024

Conversation

KuangjuX
Copy link
Member

@KuangjuX KuangjuX commented Sep 20, 2024

resolved #16.

@KuangjuX KuangjuX requested a review from haruhi55 September 20, 2024 08:26
@@ -0,0 +1,163 @@
'''
Whole GEMM is an example of GEMM that utilized all mempry hierarchies

Choose a reason for hiding this comment

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

a typo here. "that utilizes all memory hierarchies"

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed.


GemmNode = pythriller.PyNode.gemm(NodeA, NodeB, NodeAcc)
GemmNode = Node.gemm(NodeA, NodeB, NodeAcc)

Choose a reason for hiding this comment

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

I just have some questions due to my curiosity.

  1. Does Tensor(data) also represent a node in the graph, functioning similarly to a "buffer"?

  2. Intuitively, gemm is an operation with input and output. How does it differentiate between the input and output?

Copy link
Member Author

@KuangjuX KuangjuX Sep 20, 2024

Choose a reason for hiding this comment

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

  1. A Tensor is essentially a Buffer, which I have renamed:
#[pyclass(unsendable, module = "buffer", name = "Tensor")]
pub struct PyBuffer(pub Rc<Buffer>);
  1. gemm takes three parameters: a and b as inputs, and c as the output:
    #[staticmethod]
    fn gemm(a: PyRef<PyNode>, b: PyRef<PyNode>, c: PyRef<PyNode>) -> Self {
        let access_map = AccessMap::new(0, vec![]);

        let node_a = Rc::clone(&a.0);
        let node_b = Rc::clone(&b.0);
        let node_c = Rc::clone(&c.0);

        let gemm = Gemm::new(vec![node_a, node_b], node_c, Rc::new(access_map));

        let node = ThrillerNode::new(ThrillerNodeInner::Op(Box::new(gemm)));

        PyNode(Rc::new(RefCell::new(node)))
    }

Choose a reason for hiding this comment

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

I see. Thank you.

EdgeB_GEMM = pythriller.PyEdge(NodeB, GemmNode)
EdgeGemm_Acc = pythriller.PyEdge(GemmNode, NodeAcc)
EdgeA_Gemm = Edge(NodeA, GemmNode)
EdgeB_GEMM = Edge(NodeB, GemmNode)

Choose a reason for hiding this comment

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

EdgeA_gemm and EdgeB_GEMM have different naming style, is this intentional?

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed.

Copy link

@haruhi55 haruhi55 left a comment

Choose a reason for hiding this comment

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

LGTM

@KuangjuX KuangjuX merged commit 5b0977d into TiledTensor:main Sep 20, 2024
4 checks passed
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.

Add a Python example for whole GEMM.
2 participants