JuliaTorch icon indicating copy to clipboard operation
JuliaTorch copied to clipboard

Don't we need a return statement in forward method?

Open pranaymodukuru opened this issue 6 years ago • 7 comments

I am new to Julia, but use Pytorch in python

I notice there is no return statement at the end of forward method, is it so in Julia? Please correct me if I am wrong

Just wanted to know how efficient is Calling Pytorch in Julia? Is it fast enough?

pranaymodukuru avatar Dec 19 '19 00:12 pranaymodukuru

I notice there is no return statement at the end of forward method, is it so in Julia?

Yes, all expressions have default values in Julia and the return keyword is optional.

Just wanted to know how efficient is Calling Pytorch in Julia?

In most cases, the overhead of calling PyTorch is quite low in Julia. The bottleneck lies in the GPU memory management, which we have to release manually right now.

boathit avatar Dec 19 '19 01:12 boathit

I suppose we cannot slice index pytorch tensors from Julia as of yet.. May I know when or wether this option would be available?

pranaymodukuru avatar Dec 19 '19 07:12 pranaymodukuru

Yes, that's correct. So we have to resort to the API like index_select by now.

boathit avatar Dec 20 '19 09:12 boathit

Yes, that's correct. So we have to resort to the API like index_select by now.

Could you please give an example for that.

pranaymodukuru avatar Dec 20 '19 11:12 pranaymodukuru

I think these examples show selecting only a single value from a tensor, but I would like to select a slice of a tensor.

For example: a = torch.rand(1,2,28,28)

a[0,1, 3:5, 3:5]

Gives me a small part of the 28x28 image let us say.

pranaymodukuru avatar Dec 20 '19 13:12 pranaymodukuru

It seems we cannot slice a tensor along multiple dimensions simultaneously so far.

boathit avatar Dec 20 '19 13:12 boathit