tenstorrent / tt-metal

:metal: TT-NN operator library, and TT-Metalium low level kernel programming model.
Apache License 2.0
303 stars 26 forks source link

Binary op blockers #9702

Open VirdhatchaniKN opened 1 week ago

VirdhatchaniKN commented 1 week ago

Blocker issues discussed :

Binary Bitwise ops


Op Requirement :

Issues :

Unary ops implemented #9437 , #9436 These ops were directly implemented using their respective operators ( ~ , & , | ) . But the same method cannot be used in binary as these operators are not available outside the kernel.

Binary Shift operators


Op Requirement :

Issues :

Initial Implementation done in #8636 This implementation requires the involvement of a lot of ops, which may lead to performance issues.

LCM, GCD


Op Requirement :

Issues :

Implementing one of these ops, can make it easier for the other implementation as their are dependant .We have come up two approaches for GCD

  1. Using for loop

    def custom_gcd(a, b):
    def gcd(x, y):
        min_val = x if x < y else y
        for i in range(min_val, 0, -1):
            if x % i == 0 and y % i == 0:
                return i
        return 1
    
    return np.array([gcd(int(x), int(y)) for x, y in zip(a, b)])
  2. Recursive method

    def custom_gcd(a, b):
    def gcd(x, y):
        if y == 0:
            return x
        else:
            return gcd(y, x % y)
    
    return np.array([gcd(x, y) for x, y in zip(a, b)])
  3. Nested for loops

But these methods would involve repetitive loops/calling of a function.

umadevimcw commented 1 week ago

@rtawfik01 We are in need of your inputs on above mentioned ops