Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

How to copy the data from the Tensor 'src' to the crop of Tensor 'dst'? #686

Closed
tornadomeet opened this issue Nov 23, 2015 · 3 comments
Closed

Comments

@tornadomeet
Copy link
Contributor

Hello, all,
I'm writing one operator in c++ side, but encountered some difficulties .
Suppose that we have 2 Tensors: src and dst , both with the format Tensor<xpu, 4, real_t>, the shape of src is (1, 128, 300, 300), and the shape of dst is (1, 128, 400, 400), now i want to copy the data of src to the subspace of dst, with its range (1,128,50:350,50:350); how to do that?

The simplest way is using 'for' loop, and for each element in the corresponding dst, we use "=" assigning its value form src; but when xpu is gpu, this is not allowable; i want to use the crop op in mshdow, but it seems that when cropping a tensor, it returns CroppingExp, and we can only use this in right side of "="; (Another way maybe the Copy fun in mshadow can do it, but i try it not successfuly.);

thanks~

@tqchen
Copy link
Member

tqchen commented Nov 23, 2015

Let us move this issue to https://github.com/dmlc/mshadow

We can update the CropExp to support RValue evaluation, reference slice expression https://github.com/dmlc/mshadow/blob/master/mshadow/extension/slice.h So you can use it at right side of assignment

@tqchen
Copy link
Member

tqchen commented Nov 23, 2015

Let us know if you are interested in contributing this.

@tornadomeet
Copy link
Contributor Author

@tqchen , yes ,i'll try this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants