Skip to content

Commit 403d175

Browse files
committed
Reorganize project structure
1 parent aa910b4 commit 403d175

File tree

14 files changed

+293
-314
lines changed

14 files changed

+293
-314
lines changed

src/models.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,13 @@ import {
4242
Callable,
4343
isIntegralNumber,
4444
isTypedArray,
45-
} from './utils.js';
45+
} from './utils/core.js';
4646

4747
import {
4848
getModelFile,
4949
getModelJSON,
5050
} from './utils/hub.js';
5151

52-
import {
53-
Sampler,
54-
} from './samplers.js';
55-
5652
import {
5753
LogitsProcessorList,
5854
GenerationConfig,
@@ -61,13 +57,15 @@ import {
6157
ForcedEOSTokenLogitsProcessor,
6258
WhisperTimeStampLogitsProcessor,
6359
NoRepeatNGramLogitsProcessor,
64-
RepetitionPenaltyLogitsProcessor
65-
} from './generation.js';
60+
RepetitionPenaltyLogitsProcessor,
61+
62+
Sampler,
63+
} from './utils/generation.js';
6664

6765
import {
6866
Tensor,
6967
cat
70-
} from './tensor_utils.js';
68+
} from './utils/tensor.js';
7169

7270
import { executionProviders, ONNX } from './backends/onnx.js';
7371
const { InferenceSession, Tensor: ONNXTensor } = ONNX;

src/pipelines.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,6 @@
1313
* @module pipelines
1414
*/
1515

16-
import {
17-
Callable,
18-
isString,
19-
} from "./utils.js";
20-
import {
21-
softmax,
22-
max,
23-
getTopItems,
24-
cos_sim,
25-
dot
26-
} from './math_utils.js';
27-
import {
28-
read_audio
29-
} from './audio_utils.js';
3016
import {
3117
AutoTokenizer,
3218
PreTrainedTokenizer,
@@ -50,8 +36,23 @@ import {
5036
Processor
5137
} from './processors.js';
5238

53-
import { Tensor } from './tensor_utils.js';
54-
import { CustomImage } from './image_utils.js';
39+
40+
import {
41+
Callable,
42+
isString,
43+
} from './utils/core.js';
44+
import {
45+
softmax,
46+
max,
47+
getTopItems,
48+
cos_sim,
49+
dot
50+
} from './utils/maths.js';
51+
import {
52+
read_audio
53+
} from './utils/audio.js';
54+
import { Tensor } from './utils/tensor.js';
55+
import { CustomImage } from './utils/image.js';
5556

5657
/**
5758
* Prepare images for further tasks.

src/processors.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
import {
2323
Callable,
24-
} from './utils.js';
24+
} from './utils/core.js';
2525

2626
import {
2727
getModelJSON,
@@ -31,12 +31,12 @@ import {
3131
max,
3232
softmax,
3333
FFT
34-
} from './math_utils.js';
34+
} from './utils/maths.js';
3535

3636

37-
import { Tensor, transpose, cat, interpolate } from './tensor_utils.js';
37+
import { Tensor, transpose, cat, interpolate } from './utils/tensor.js';
3838

39-
import { CustomImage } from './image_utils.js';
39+
import { CustomImage } from './utils/image.js';
4040

4141

4242
/**

src/samplers.js

Lines changed: 0 additions & 254 deletions
This file was deleted.

src/tokenizers.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ import {
2525
reverseDictionary,
2626
escapeRegExp,
2727
isIntegralNumber,
28-
} from './utils.js';
28+
} from './utils/core.js';
2929

3030
import {
3131
getModelJSON,
3232
} from './utils/hub.js';
3333

34-
import { min } from './math_utils.js';
35-
import { Tensor } from './tensor_utils.js';
34+
import { min } from './utils/maths.js';
35+
import { Tensor } from './utils/tensor.js';
3636

3737
/**
3838
* @typedef {import('./utils/hub.js').PretrainedOptions} PretrainedOptions

src/transformers.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ export * from './models.js';
2020
export * from './tokenizers.js';
2121
export * from './processors.js';
2222

23-
export * from './audio_utils.js';
24-
export * from './tensor_utils.js';
25-
export * from './math_utils.js';
23+
export * from './utils/audio.js';
24+
export * from './utils/tensor.js';
25+
export * from './utils/maths.js';

0 commit comments

Comments
 (0)