TinyChatEngine
Loading...
Searching...
No Matches
MetalMatmulInt4.hpp
1#pragma once
2
3#include "Foundation/Foundation.hpp"
4#include "Metal/Metal.hpp"
5#include "opParams.h"
6
8 public:
9 MTL::Device *_mDevice;
10
11 // The compute pipeline generated from the compute kernel in the .metal shader file.
12 MTL::ComputePipelineState *_mMatmulFunctionPSO;
13
14 // The command queue used to pass commands to the device.
15 MTL::CommandQueue *_mCommandQueue;
16
17 // Buffers to hold data.
18 MTL::Buffer *_mBufferA;
19 MTL::Buffer *_mBufferB;
20 MTL::Buffer *_mBufferScales;
21 MTL::Buffer *_mBufferResult;
22 MTL::Buffer *_mParams;
23
24 // Matmul params
25 MetalMatMulParams *_mParamsPtr;
26
27 MetalMatmulInt4(MTL::Device *device, MetalMatMulParams param);
29
30 void prepareData();
31 void sendComputeCommand();
32 void verifyResults();
33
34 private:
35 void encodeCommand(MTL::ComputeCommandEncoder *computeEncoder);
36 void generateRandomFloatData(MTL::Buffer *buffer, int length);
37 void generateRandomIn4Data(MTL::Buffer *buffer, int length);
38};
Definition MetalMatmulInt4.hpp:7
Definition opParams.h:3