Skip to content
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

Update code editor sample to the latest implementation #193

Merged
merged 1 commit into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions code/samples/matmul.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ const context = await navigator.ml.createContext();
// The following code multiplies matrix a [3, 4] with matrix b [4, 3]
// into matrix c [3, 3].
const builder = new MLGraphBuilder(context);
const descA = {type: 'float32', dataType: 'float32', dimensions: [3, 4]};
const descA = {dataType: 'float32', dimensions: [3, 4]};
const a = builder.input('a', descA);
const descB = {type: 'float32', dataType: 'float32', dimensions: [4, 3]};
const descB = {dataType: 'float32', dimensions: [4, 3]};
const bufferB = new Float32Array(sizeOfShape(descB.dimensions)).fill(0.5);
const b = builder.constant(descB, bufferB);
const c = builder.matmul(a, b);
const c = builder.gemm(a, b);

const graph = await builder.build({c});
const bufferA = new Float32Array(sizeOfShape(descA.dimensions)).fill(0.5);
Expand Down
5 changes: 3 additions & 2 deletions code/samples/mul_add.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const operandType = {type: 'float32', dataType: 'float32', dimensions: [2, 2]};
const operandType = {dataType: 'float32', dimensions: [2, 2]};
const context = await navigator.ml.createContext();
const builder = new MLGraphBuilder(context);
// 1. Create a computational graph 'C = 0.2 * A + B'.
const constant = builder.constant(0.2);
const constant = builder.constant(
{dataType: 'float32'}, new Float32Array([0.2]));
const A = builder.input('A', operandType);
const B = builder.input('B', operandType);
const C = builder.add(builder.mul(A, constant), B);
Expand Down
28 changes: 0 additions & 28 deletions code/samples/optional_outputs.js

This file was deleted.

2 changes: 1 addition & 1 deletion code/samples/simple_graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const TENSOR_SIZE = 8;
const builder = new MLGraphBuilder(context);

// Create MLOperandDescriptor object.
const desc = {type: 'float32', dataType: 'float32', dimensions: TENSOR_DIMS};
const desc = {dataType: 'float32', dimensions: TENSOR_DIMS};

// constant1 is a constant MLOperand with the value 0.5.
const constantBuffer1 = new Float32Array(TENSOR_SIZE).fill(0.5);
Expand Down
1 change: 0 additions & 1 deletion code/samples_repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const samples = [
'mul_add.js',
'simple_graph.js',
'matmul.js',
'optional_outputs.js',
];

class SamplesRepository {
Expand Down