Kotlin / multik

Multidimensional array library for Kotlin
https://kotlin.github.io/multik/
Apache License 2.0
649 stars 39 forks source link

Add LogicalOr and LogicalAnd #48

Closed zaleslaw closed 3 years ago

zaleslaw commented 3 years ago

Hi, I'm going to implement the postprocessing for the YOLOv4 model in the KotlinDL library, but it requires many different analogs of the NumPy functions.

Could you please add the analog of the np.logical_or and np.logical_and functions?

devcrocod commented 3 years ago

This means that needs to support boolean arrays.

devcrocod commented 3 years ago

In the yolo model, this is used to get masks by which arrays are subsequently taken.

mask = np.logical_and(scale_mask, score_mask)
coors, scores, classes = pred_coor[mask], scores[mask], classes[mask]

There is no such thing in multik either. I need to think about the api.

breandan commented 3 years ago

Related to #37, it would be nice to have a Kotlin API for something like this: https://github.com/JetBrains-Research/spbla

breandan commented 3 years ago

@devcrocod I have been doing some experiments with abstract algebras using type classes. Although I am still unhappy with the amount of indirection, our implementation currently supports various semirings. Perhaps you can borrow some ideas:

https://github.com/breandan/kaliningraph/blob/master/src/commonMain/kotlin/ai/hypergraph/kaliningraph/tensor/Tensor.kt

devcrocod commented 3 years ago

It looks very cool. thanks