-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize the time cost to go into training #410
Changes from 22 commits
772dd5a
9132604
00539da
523a24a
f72eae9
ec6a3b5
50dff0b
fc941ef
5998960
6224db4
250f6d0
5b6165b
40385c8
7b3fbc8
a8ab4b8
e5ab252
6c9676d
c7c8db5
1775ae2
aa7803a
a529104
e3ee6c7
960b1c6
48a2be7
2641855
c960e1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import { DataProcessType, ArgsType, UniDataset } from '@pipcook/pipcook-core' | ||
import { DataProcessType, ArgsType, Sample, Metadata } from '@pipcook/pipcook-core' | ||
|
||
const templateDataProcess: DataProcessType = async (data: UniDataset, args: ArgsType): Promise<UniDataset> => { | ||
return {} as UniDataset; | ||
const templateDataProcess: DataProcessType = async (data: Sample, metadata: Metadata, args: ArgsType): Promise<void> => { | ||
} | ||
|
||
export default templateDataProcess; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { DatasetProcessType, ArgsType, UniDataset } from '@pipcook/pipcook-core' | ||
|
||
const templateDatasetProcess: DatasetProcessType = async (dataset: UniDataset, args: ArgsType): Promise<void> => { | ||
// Do some process to the whole dataset | ||
}; | ||
|
||
export default templateDatasetProcess; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,17 +93,28 @@ async function emitStart(message: PluginMessage): Promise<void> { | |
if (pkg.pipcook.category === 'dataProcess') { | ||
// in "dataProcess" plugin, we need to do process them in one by one. | ||
const [ dataset, args ] = pluginArgs.map(deserializeArg) as [ UniDataset, any ]; | ||
const loaders = [ dataset.trainLoader, dataset.validationLoader, dataset.testLoader ] | ||
[ dataset.trainLoader, dataset.validationLoader, dataset.testLoader ] | ||
.filter((loader: DataLoader) => loader != null) | ||
.map(async (loader: DataLoader) => { | ||
const len = await loader.len(); | ||
// FIXME(Yorkie): in parallel? | ||
for (let i = 0; i < len; i++) { | ||
const sample = await loader.getItem(i); | ||
await fn(sample, dataset.metadata, args); | ||
} | ||
.forEach(async (loader: DataLoader) => { | ||
process.nextTick(async () => { | ||
const len = await loader.len(); | ||
loader.processIndex = 0; | ||
for (let i = 0; i < len; i++) { | ||
let sample = await loader.getItem(i); | ||
sample = await fn(sample, dataset.metadata, args); | ||
await loader.setItem(i, sample); | ||
loader.processIndex = i + 1; | ||
loader.notifyProcess(); | ||
} | ||
}); | ||
}); | ||
await Promise.all(loaders); | ||
recv(PluginOperator.WRITE); | ||
return; | ||
} | ||
|
||
if (pkg.pipcook.category === 'datasetProcess') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we move the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, have remove this |
||
const [ dataset, args ] = pluginArgs.map(deserializeArg) as [ UniDataset, any ]; | ||
await fn(dataset, args); | ||
recv(PluginOperator.WRITE); | ||
return; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And a unit tests for this class is required :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint problem has been fixed. I will add a unit test ASAP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit test has been added. Please have a check pls :)