TinyChatEngine
Loading...
Searching...
No Matches
matmul_metal_int4_imp.h
1#pragma once
2
3#include <unordered_map>
4
5#include "Foundation/Foundation.hpp"
6#include "Metal/Metal.hpp"
7#include "include/opParams.h"
8
9typedef struct {
10 float *A, *C, *scales, *offset;
11 unsigned char *B;
13
15 public:
16 static MTL::Device *_mDevice;
17
18 // The compute pipeline generated from the compute kernel in the .metal shader file.
19 static MTL::ComputePipelineState *_mMatmulFunctionPSO;
20
21 // The command queue used to pass commands to the device.
22 static MTL::CommandQueue *_mCommandQueue;
23
24 // Buffers to hold data.
25 static MTL::Buffer *_mBufferA;
26 static MTL::Buffer *_mBufferB;
27 static MTL::Buffer *_mBufferScales;
28 static MTL::Buffer *_mBufferResult;
29 static MTL::Buffer *_mParams;
30
31 static std::unordered_map<void *, MTL::Buffer *> _mumap;
32
33 static bool has_init;
34 static void init();
35 static void run(MetalMatMulParams param, MetalMatmulBuffers *bufferParams);
36 static void *allocateSharedMem(size_t size);
37
38 static MetalMatMulParams *_mParamsPtr;
39 static void sendComputeCommand();
40 static void encodeCommand(MTL::ComputeCommandEncoder *computeEncoder);
41 static MTL::Buffer *getBufferfromPtr(void *ptr);
42};
Definition matmul_metal_int4_imp.h:14
Definition opParams.h:3
Definition matmul_metal_int4_imp.h:9