markovPredictGPU function
Predicts the next state probabilities given a batch of histories.
Implementation
GPUTensor<Matrix> markovPredictGPU(
GPUTensor<Matrix> historyBatch, // Shape: [batch_size, order]
GPUTensor<Matrix> probTable, // Shape: [num_histories, num_states]
int numStates,
CommandBuffer tape) {
int batchSize = historyBatch.shape[0];
int order = historyBatch.shape[1];
GPUTensor<Matrix> outProbs = GPUTensor<Matrix>.empty(<int>[batchSize, numStates]);
tape.putInt(OP_MARKOV_PREDICT);
tape.putString(historyBatch.id);
tape.putString(probTable.id);
tape.putString(outProbs.id);
tape.putInt(order);
tape.putInt(numStates);
outProbs.creator = GPUNode(
<GPUTensor>[historyBatch, probTable],
(CommandBuffer bTape) {}, // Empty backward pass
opName: 'markovPredictGPU'
);
return outProbs;
}