Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_pth.h
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 *
17 * SPDX-License-Identifier: Apache-2.0
18 */
19
46
47#ifndef __NILOREA_PTH__
48#define __NILOREA_PTH__
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
58
59#include <stddef.h>
60#include <stdint.h>
61
63#define N_PTH_MAX_DIMS 8
64
66typedef struct N_PTH_TENSOR {
68 char* name;
70 int dims;
74 float* data;
76 size_t count;
78
80typedef struct N_PTH {
84 size_t count;
85} N_PTH;
86
92N_PTH* n_pth_load(const char* path);
93
98const N_PTH_TENSOR* n_pth_find(const N_PTH* pth, const char* name);
99
102void n_pth_free(N_PTH** pth);
103
107
108#ifdef __cplusplus
109}
110#endif
111
112#endif
size_t count
how many
Definition n_pth.h:76
int dims
how many dimensions
Definition n_pth.h:70
char * name
its path, the dictionary keys joined by dots; owned
Definition n_pth.h:68
N_PTH_TENSOR * tensors
the tensors, in the order the file lists them
Definition n_pth.h:82
int64_t shape[8]
their sizes
Definition n_pth.h:72
float * data
its values, contiguous, row major; owned
Definition n_pth.h:74
size_t count
how many
Definition n_pth.h:84
void n_pth_free(N_PTH **pth)
release a checkpoint's tensors
Definition n_pth.c:784
const N_PTH_TENSOR * n_pth_find(const N_PTH *pth, const char *name)
find a tensor by its path
Definition n_pth.c:776
N_PTH * n_pth_load(const char *path)
read every tensor of a checkpoint
Definition n_pth.c:738
#define N_PTH_MAX_DIMS
Most dimensions a tensor read may have.
Definition n_pth.h:63
A checkpoint's tensors.
Definition n_pth.h:80
One tensor of a checkpoint.
Definition n_pth.h:66