-
Notifications
You must be signed in to change notification settings - Fork 750
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
Calling methods on pytorch Generator causes segfault #1259
Comments
That looks like an abstract class. Did you try to create an instance of a subclass instead? |
It looks like the way to create a Generator is with make_generator(), so we should work on mapping that, I guess? |
Thanks for having a look and apologies, I missed your first response. In the meantime I also realized that functions like But being able to call |
I'd like to get back into getting this in. template<class Impl, class... Args>
Generator make_generator(Args&&... args) {
return Generator(c10::make_intrusive<Impl>(std::forward<Args>(args)...));
} Do we need additional mapping infos because it is a template function? |
Yes, we need explicit infos to instantiate the function template. |
Yes that'd be great. In the Python impl, the if (device.type() == at::kCPU) {
self->cdata = make_generator<CPUGeneratorImpl>();
}
#ifdef USE_CUDA
else if (device.type() == at::kCUDA) {
self->cdata = make_generator<CUDAGeneratorImpl>(device.index());
}
#elif USE_MPS
else if (device.type() == at::kMPS) {
self->cdata = make_generator<MPSGeneratorImpl>();
} So if we have the cpu and cuda variants (and mps in the future as well once we support building against mps), it should be straightforward to do it in a similar way. Out of curiosity, is the new version of the presets you are working on a major overhaul? |
There will be 4 variants: @Namespace("at") public static native @ByVal @Name("make_generator<at::CUDAGeneratorImpl>") Generator make_generator_cuda();
@Namespace("at") public static native @ByVal @Name("make_generator<at::CUDAGeneratorImpl,int8_t>") Generator make_generator_cuda(@Const byte device_index);
@Namespace("at") public static native @ByVal @Name("make_generator<at::CPUGeneratorImpl>") Generator make_generator_cpu();
@Namespace("at") public static native @ByVal @Name("make_generator<at::CPUGeneratorImpl,uint64_t>") Generator make_generator_cpu(long seed_in);
Yes. Hopefully coming soon as a PR. |
Looking forward to it.
None that I know of yet. Right now I'm just curious how this might affect the Scala bindings I'm working on. |
With #1360 merged, we can now use the |
Something seems odd with the mapping of Generator. Calling seed and state related methods on a
Generator
instance triggers a segfault.For instance running this snippet:
Any ideas what could be wrong here?
The text was updated successfully, but these errors were encountered: