MCPcopy Create free account
hub / github.com/alibaba/MNN / createTensorFromData

Function createTensorFromData

test/backend/cpu/compute/BlstmComputerTest.cpp:23–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21
22namespace BlstmComputerTest {
23shared_ptr<Tensor> createTensorFromData(const vector<int> &shape, float *data, Tensor::DimensionType dimType,
24 CPUBackend *bn) {
25 auto srcTensor = shared_ptr<Tensor>(Tensor::create(shape, halide_type_of<float>(), data, Tensor::CAFFE));
26 auto tgtTensor = shared_ptr<Tensor>(Tensor::createDevice<float>(shape, dimType));
27 bn->onAcquireBuffer(tgtTensor.get(), Backend::DYNAMIC);
28 bn->onCopyBuffer(srcTensor.get(), tgtTensor.get());
29 return tgtTensor;
30}
31
32shared_ptr<Tensor> createAndRun(int timesteps, int batch, int inDim, int stateDim, bool bidirectional, float *input,
33 float *weights, float *initH, float *initC, vector<int> lengths,

Callers 1

createAndRunFunction · 0.85

Calls 4

onAcquireBufferMethod · 0.80
createFunction · 0.50
getMethod · 0.45
onCopyBufferMethod · 0.45

Tested by

no test coverage detected