|
|
|
@ -95,6 +95,19 @@ MSTensor *DETensor::CreateTensor(const std::string &path) {
|
|
|
|
|
return new DETensor(std::move(t));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MSTensor *DETensor::CreateFromMemory(TypeId data_type, const std::vector<int> &shape, void *data) {
|
|
|
|
|
std::shared_ptr<dataset::Tensor> t;
|
|
|
|
|
// prepare shape info
|
|
|
|
|
std::vector<dataset::dsize_t> t_shape;
|
|
|
|
|
|
|
|
|
|
std::transform(shape.begin(), shape.end(), std::back_inserter(t_shape),
|
|
|
|
|
[](int s) -> dataset::dsize_t { return static_cast<dataset::dsize_t>(s); });
|
|
|
|
|
|
|
|
|
|
(void)dataset::Tensor::CreateFromMemory(dataset::TensorShape(t_shape), MSTypeToDEType(data_type),
|
|
|
|
|
static_cast<uchar *>(data), &t);
|
|
|
|
|
return new DETensor(std::move(t));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DETensor::DETensor(TypeId data_type, const std::vector<int> &shape) {
|
|
|
|
|
std::vector<dataset::dsize_t> t_shape;
|
|
|
|
|
t_shape.reserve(shape.size());
|
|
|
|
|