MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / SplitOneOutput

Function SplitOneOutput

serving/processor/serving/model_message.cc:47–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45
46template<typename T>
47void SplitOneOutput(Response& batched_response,
48 int index, int call_num, std::vector<Tensor>& ret) {
49 Tensor& batched_tensor = batched_response.outputs[index];
50 auto batched_tensor_shape = batched_tensor.shape();
51 auto batched_flat = batched_tensor.flat<T>();
52 size_t current_pos = 0;
53
54 size_t single_output_size = 1;
55 TensorShape tensor_shape;
56 for (int j = 1; j < batched_tensor_shape.dims(); ++j) {
57 tensor_shape.AddDim(batched_tensor_shape.dim_size(j));
58 single_output_size *= batched_tensor_shape.dim_size(j);
59 }
60 for (int i = 0; i < call_num; ++i) {
61 Tensor t(batched_tensor.dtype(), tensor_shape);
62 auto flat = t.flat<T>();
63
64 memcpy(flat.data(), batched_flat.data() + current_pos,
65 single_output_size);
66 current_pos += single_output_size;
67 ret[i] = t;
68 }
69}
70}
71
72Status BatchCall::BatchRequest() {

Callers

nothing calls this directly

Calls 6

shapeMethod · 0.45
dimsMethod · 0.45
AddDimMethod · 0.45
dim_sizeMethod · 0.45
dtypeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected