mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-23 22:08:08 -05:00
* rawcpu * add should work when we respect shapetracker * now that's true * still have to handle shapetracker * copyin * Fix mypy
27 lines
459 B
C++
27 lines
459 B
C++
class CBuffer {
|
|
public:
|
|
CBuffer(int size_, void* dat = NULL) {
|
|
size = size_;
|
|
buf = (float*)malloc(size*4);
|
|
}
|
|
|
|
void copyin(void *dat) {
|
|
memcpy(buf, dat, size*4);
|
|
}
|
|
|
|
void add(CBuffer *x, CBuffer *y) {
|
|
for (int i = 0; i < size; i++) {
|
|
buf[i] = x->buf[i] + y->buf[i];
|
|
}
|
|
}
|
|
|
|
void mul(CBuffer *x, CBuffer *y) {
|
|
for (int i = 0; i < size; i++) {
|
|
buf[i] = x->buf[i] * y->buf[i];
|
|
}
|
|
}
|
|
|
|
float *buf;
|
|
int size;
|
|
};
|