Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/util/src/vector/Tensor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export const TensorType = {
export type TensorType = (typeof TensorType)[keyof typeof TensorType];

/**
* Vector schema for representing vectors as arrays of numbers
* Tensor schema for representing tensors as arrays of numbers
* @param annotations - Additional annotations for the schema
* @returns The vector schema
* @returns The tensor schema
*/
export const TensorSchema = (annotations: Record<string, unknown> = {}) =>
({
Expand All @@ -33,24 +33,24 @@ export const TensorSchema = (annotations: Record<string, unknown> = {}) =>
type: "string",
enum: Object.values(TensorType),
title: "Type",
description: "The type of the vector",
description: "The type of the tensor",
},
data: TypedArraySchema({
title: "Data",
description: "The data of the vector",
description: "The data of the tensor",
}),
shape: {
type: "array",
items: { type: "number" },
title: "Shape",
description: "The shape of the vector (dimensions)",
description: "The shape of the tensor (dimensions)",
minItems: 1,
default: [1],
},
normalized: {
type: "boolean",
title: "Normalized",
description: "Whether the vector data is normalized",
description: "Whether the tensor data is normalized",
default: false,
},
},
Expand All @@ -59,4 +59,4 @@ export const TensorSchema = (annotations: Record<string, unknown> = {}) =>
...annotations,
}) as const satisfies JsonSchema;

export type Vector = FromSchema<ReturnType<typeof TensorSchema>, TypedArraySchemaOptions>;
export type Tensor = FromSchema<ReturnType<typeof TensorSchema>, TypedArraySchemaOptions>;