Giter VIP home page Giter VIP logo

einop_chad's Introduction

Einop Chad

One chad op to rule them all

Almost exactly like Einop but it also supports einsum and pack.

Installation


git clone https://github.com/SalamanderXing/einop_chad

cd einop_chad

pip install einop_chad

Usage

Einsum

import numpy as np # or torch, tensorflow, JAX ...
from einop import einop

a = np.random.uniform(size=(10, 20))
b = np.random.uniform(size=(20, 15))

y = einop(a, b, "a b, b c -> a c") # matrix multiplication

assert y.shape == (10, 15)

Pack

import numpy as np
from einop import einop

a = np.random.uniform(size=(10, 15))
b = np.random.uniform(size=(20, 15))
c = np.random.uniform(size=(30, 15))

y = einop((a, b, c) "* a") # concatenate along axis 0

assert y.shape == (10 + 20 + 30, 15)

Rearrange

x = np.random.randn(100, 5, 3)

einop(x, 'i j k -> k i j').shape
>>> (3, 100, 5)

Reduction

x = np.random.randn(100, 5, 3)

einop(x, 'i j k -> i j', reduction='sum').shape
>>> (100, 5)

Repeat

x = np.random.randn(100, 5, 3)

einop(x, 'i j k -> i j k l', l=10).shape
>>> (100, 5, 3, 10)

einop_chad's People

Contributors

cgarciae avatar github-actions[bot] avatar salamanderxing avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.