Skip to content
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
2 changes: 1 addition & 1 deletion tfjs-node/binding/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ inline std::vector<const char *> splitStringByComma(const std::string &str) {
std::string token = str.substr(prev, pos - prev);
if (!token.empty()) {
char *cstr = new char[str.length() + 1];
std::strcpy(cstr, str.c_str());
std::strcpy(cstr, token.c_str());
tokens.push_back(cstr);
}
prev = pos + 1;
Expand Down
19 changes: 19 additions & 0 deletions tfjs-node/src/saved_model_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,4 +428,23 @@ describe('SavedModel', () => {
model1.dispose();
model2.dispose();
});

it('execute model with multiple inputs and outputs', async () => {
const model = await tf.node.loadSavedModel(
'./test_objects/saved_model/model_multi_output', ['serve'],
'serving_default');
const input1 = tf.tensor1d([1, 2, 3], 'int32');
const input2 = tf.tensor1d([1, 2, 3], 'int32');
const output =
model.predict({'x': input1, 'y': input2}) as tf.NamedTensorMap;
const output1 = output['output_0'];
const output2 = output['output_1'];
expect(output1.shape).toEqual(input1.shape);
expect(output1.dtype).toBe(input1.dtype);
expect(output2.shape).toEqual(input2.shape);
expect(output2.dtype).toBe(input2.dtype);
test_util.expectArraysClose(await output1.data(), [2, 4, 6]);
test_util.expectArraysClose(await output2.data(), [1, 2, 3]);
model.dispose();
});
});
Binary file not shown.
Binary file not shown.
Binary file not shown.