0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-02 03:32:52 +01:00
construct/include/ircd/gpt/pipe/desc.h

78 lines
1.8 KiB
C
Raw Normal View History

2021-04-02 22:01:38 +02:00
// Matrix Construct
//
// Copyright (C) Matrix Construct Developers, Authors & Contributors
// Copyright (C) 2016-2021 Jason Volk <jason@zemos.net>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file.
#pragma once
#define HAVE_IRCD_GPT_PIPE_DESC_H
/// Pipe descriptor
struct ircd::gpt::pipe::desc
{
struct layer;
2022-06-20 03:59:29 +02:00
// Model descriptor
2021-04-02 22:01:38 +02:00
pipe::model *model;
2022-06-20 03:59:29 +02:00
// Code descriptor
2021-04-02 22:01:38 +02:00
pipe::code *code;
2022-06-20 03:59:29 +02:00
// Memories
2021-04-02 22:01:38 +02:00
cl::data
2022-06-20 03:59:29 +02:00
opts, // [root] options page
ctrl, // [root] control page
master, // [root] single allocation for additional buffers:
2022-06-20 03:59:29 +02:00
state, // [-sub] projection (layers * tokens * embed * 3 * float)
accum, // [-sub] accumulator (tokens * embed * float)
logit, // [-sub] result logit vector (50257 * float)
2022-06-20 03:59:29 +02:00
attns, // [-sub] result attention softmax
frame[8]; // [root] result stream
2021-04-02 22:01:38 +02:00
2022-06-20 03:59:29 +02:00
// Programs
2021-04-02 22:01:38 +02:00
cl::kern
2022-06-20 03:59:29 +02:00
alloc,
enter,
2021-04-02 22:01:38 +02:00
lm_embed,
lm_norm,
lm_logit,
lm_logsm,
2021-04-17 20:59:30 +02:00
lm_select,
2022-06-20 03:59:29 +02:00
lm_prop_embed,
lm_prop_norm,
leave[8];
/// Coil pack
std::unique_ptr<struct desc::layer> layer[12];
2021-04-02 22:01:38 +02:00
2022-06-20 03:59:29 +02:00
/// Attention projection for first N tokens already contained in `state`.
uint cached {0};
2021-04-02 22:01:38 +02:00
2022-06-20 03:59:29 +02:00
desc(const gpt::opts *const &,
gpt::ctrl *const &,
pipe::model &model,
pipe::code &code);
2021-04-02 22:01:38 +02:00
};
2022-06-20 03:59:29 +02:00
/// Pipe descriptor: coil layer
2021-04-02 22:01:38 +02:00
struct ircd::gpt::pipe::desc::layer
{
cl::data
2022-06-20 03:59:29 +02:00
state, // [-sub] qry/key/val projection (tokens * embed * 3 * float)
attns; // [-sub] attn softmax result (((tokens * tokens) / 2) * 12 * float)
2021-04-17 20:59:30 +02:00
cl::kern
2022-06-20 03:59:29 +02:00
attn,
ffnn,
prop_attn,
prop_ffnn;
2021-04-02 22:01:38 +02:00
2022-06-20 03:59:29 +02:00
layer(pipe::desc &,
const gpt::opts *const &,
const uint laynum);
2021-04-02 22:01:38 +02:00
};