Skip to content

Commit

Permalink
fix: scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
load1n9 committed Oct 19, 2023
1 parent 62ac81b commit f607e46
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 12 deletions.
28 changes: 24 additions & 4 deletions src/backends/cpu/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ import { dlopen, FetchOptions } from "../../../deps.ts";
import { CPUBackend } from "./backend.ts";
import { NoBackendError } from "../../core/api/error.ts";
import { BackendLoader, Engine } from "../../core/engine.ts";
import { Backend, BackendType, Cost, NetworkConfig } from "../../core/types.ts";
import {
Backend,
BackendType,
Cost,
NetworkConfig,
SchedulerType,
} from "../../core/types.ts";
import { Sequential } from "../../core/mod.ts";

const options: FetchOptions = {
name: "netsaur",
url: new URL(import.meta.url).protocol !== "file:"
? new URL(
"https://github.com/denosaurs/netsaur/releases/download/0.2.13/",
"https://github.com/denosaurs/netsaur/releases/download/0.2.14/",
import.meta.url,
)
: "./target/release/",
Expand Down Expand Up @@ -78,14 +84,28 @@ export class CPUBackendLoader implements BackendLoader {

load(buffer: Uint8Array): Sequential {
this.backend = CPUBackend.load(buffer, CPUInstance.library!);
const net = new Sequential({ size: [0], layers: [], cost: Cost.MSE });
const net = new Sequential({
size: [0],
layers: [],
cost: Cost.MSE,
scheduler: {
type: SchedulerType.None,
},
});
this.backend = undefined;
return net;
}

loadFile(path: string): Sequential {
this.backend = CPUBackend.loadFile(path, CPUInstance.library!);
const net = new Sequential({ size: [0], layers: [], cost: Cost.MSE });
const net = new Sequential({
size: [0],
layers: [],
cost: Cost.MSE,
scheduler: {
type: SchedulerType.None,
},
});
this.backend = undefined;
return net;
}
Expand Down
28 changes: 24 additions & 4 deletions src/backends/gpu/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ import { dlopen, FetchOptions } from "../../../deps.ts";
import { GPUBackend } from "./backend.ts";
import { NoBackendError } from "../../core/api/error.ts";
import { BackendLoader, Engine } from "../../core/engine.ts";
import { Backend, BackendType, Cost, NetworkConfig } from "../../core/types.ts";
import {
Backend,
BackendType,
Cost,
NetworkConfig,
SchedulerType,
} from "../../core/types.ts";
import { Sequential } from "../../core/mod.ts";

const options: FetchOptions = {
name: "netsaur_gpu",
url: new URL(import.meta.url).protocol !== "file:"
? new URL(
"https://github.com/denosaurs/netsaur/releases/download/0.2.13/",
"https://github.com/denosaurs/netsaur/releases/download/0.2.14/",
import.meta.url,
)
: "./target/release/",
Expand Down Expand Up @@ -78,14 +84,28 @@ export class GPUBackendLoader implements BackendLoader {

load(buffer: Uint8Array): Sequential {
this.backend = GPUBackend.load(buffer, GPUInstance.library!);
const net = new Sequential({ size: [0], layers: [], cost: Cost.MSE });
const net = new Sequential({
size: [0],
layers: [],
cost: Cost.MSE,
scheduler: {
type: SchedulerType.None,
},
});
this.backend = undefined;
return net;
}

loadFile(path: string): Sequential {
this.backend = GPUBackend.loadFile(path, GPUInstance.library!);
const net = new Sequential({ size: [0], layers: [], cost: Cost.MSE });
const net = new Sequential({
size: [0],
layers: [],
cost: Cost.MSE,
scheduler: {
type: SchedulerType.None,
},
});
this.backend = undefined;
return net;
}
Expand Down
28 changes: 24 additions & 4 deletions src/backends/wasm/mod.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { WASMBackend } from "./backend.ts";
import { NoBackendError } from "../../core/api/error.ts";
import { BackendLoader, Engine } from "../../core/engine.ts";
import { Backend, BackendType, Cost, NetworkConfig } from "../../core/types.ts";
import {
Backend,
BackendType,
Cost,
NetworkConfig,
SchedulerType,
} from "../../core/types.ts";
import { instantiate } from "./lib/netsaur.generated.js";
import { Sequential } from "../../core/mod.ts";

Expand All @@ -16,7 +22,7 @@ export class WASMInstance {
await instantiate({
url: new URL(import.meta.url).protocol !== "file:"
? new URL(
"https://github.com/denosaurs/netsaur/releases/download/0.2.13/netsaur_bg.wasm",
"https://github.com/denosaurs/netsaur/releases/download/0.2.14/netsaur_bg.wasm",
import.meta.url,
)
: undefined,
Expand Down Expand Up @@ -51,14 +57,28 @@ export class WASMBackendLoader implements BackendLoader {

load(buffer: Uint8Array): Sequential {
this.backend = WASMBackend.load(buffer);
const net = new Sequential({ size: [0], layers: [], cost: Cost.MSE });
const net = new Sequential({
size: [0],
layers: [],
cost: Cost.MSE,
scheduler: {
type: SchedulerType.None,
},
});
this.backend = undefined;
return net;
}

loadFile(path: string): Sequential {
this.backend = WASMBackend.loadFile(path);
const net = new Sequential({ size: [0], layers: [], cost: Cost.MSE });
const net = new Sequential({
size: [0],
layers: [],
cost: Cost.MSE,
scheduler: {
type: SchedulerType.None,
},
});
this.backend = undefined;
return net;
}
Expand Down

0 comments on commit f607e46

Please sign in to comment.