Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to convert lib.Ctensor to Tensor outside the tensor package? #58

Closed
FelixHo opened this issue Sep 11, 2021 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@FelixHo
Copy link

FelixHo commented Sep 11, 2021

when ForwardIs returns a pytorch Tensor type from the PyTorch JIT model , according to the code below,
https://github.com/sugarme/gotch/blob/master/tensor/jit.go#L449-L457

tensor := lib.AtiToTensor(cval.civalue) // <-----lib.Ctensor
if err := TorchErr(); err != nil {
	return nil, err
}
return &IValue{
	value: tensor, // ---> It might be better to change this to x Tensor{tensor} 
	kind:  TensorVal,
	name:  "Tensor",
}, nil

the value of IValue is the lib.Ctensor type , as far as I know (im new to golang), I cannot convert it to Tensor type outside the tensor package because the ctensor of type Tensor is not exported.

type Tensor struct {
	ctensor lib.Ctensor
}
@sugarme
Copy link
Owner

sugarme commented Sep 15, 2021

Hi @FelixHo,

Thanks for pointing it out. I'll fix it shortly.

@sugarme sugarme added the bug Something isn't working label Sep 15, 2021
sugarme added a commit that referenced this issue Sep 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants