Comments (3)
Hi @cenwangumass, it depends on how you allocate the tensor. If t
was allocated using the standard way:
auto t = make_tensor<float>({10});
For example, then the default is to use managed memory. Managed memory is available on both host and device with the same pointer. You could them do something like:
std::vector<float> vec(10);
auto t = make_tensor<float>({10});
// Do some work on t
memcpy(vec.data(), t.Data(), t.Bytes());
// Or
for (int i = 0; i < vec.size(); i++) {
vec(i) = t(i);
}
The same thing applies to an Eigen vector/tensor. Keep in mind that this will only work as above is the tensor is contiguous. If you have strided data (not compact) then you will need to either make a copy into a contiguous tensor first, or manually copy each element. Does that make sense?
from matx.
Technically you can also create a tensor and point it at vector memory:
std::vector<float> vec(10);
auto t2 = make_tensor<float>(vec.data(), {10});
auto t = make_tensor<float>({10});
(t2 = t).run(matx::HostExecutor{});
This should work too if you prefer that method.
from matx.
Thanks! I was already doing that. I was just looking for maybe a function or a method in matx.
from matx.
Related Issues (20)
- [QST] Cannot call device executor using host compiler HOT 7
- print on diag operator appears broken [BUG] HOT 3
- [FEA] Add vector and matrix norm operators
- [BUG] Renamed `rmax`/`rmin`
- [DOC] Document enumerated types
- [DOC] Add host/cuda support to docs
- [FEA] Consider custom reduction if using non-contiguous stride
- [FEA] Add support for mdspan
- [FEA] Add support to extract the exponents of tensor with float / complex values HOT 1
- [BUG] `cmake_sample_project` cannot build when setting `MATX_EN_CUTLASS=ON` HOT 6
- [BUG] `cmake_sample_project` cannot build when setting `MATX_EN_PYBIND11=ON` on Python >= 3.11 HOT 6
- [FEA] cuTENSOR 2.0 support HOT 9
- [BUG] `clone(slice(diag(A)))` failed HOT 1
- [BUG] Simple einsum program failed to compile HOT 4
- [FEA] Add a `find_peaks` function
- [BUG] Compilation error with MATX_ENABLE_CUTLASS in transforms/matmul.h HOT 3
- [BUG]: #define print replaces print functions in other libraries HOT 3
- [BUG] Clang cannot compile as a host compiler
- [BUG] Conversion issue with matxBf16 and logical > with float literal HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from matx.