Skip to content

Commit

Permalink
* Map c10::ArrayRef<at::Tensor>(std::vector<at::Tensor>&) construc…
Browse files Browse the repository at this point in the history
…tor from PyTorch for convenience (discussion #1128)
  • Loading branch information
saudet committed Jan 20, 2022
1 parent 50f602f commit eeee3e7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Map `c10::ArrayRef<at::Tensor>(std::vector<at::Tensor>&)` constructor from PyTorch for convenience ([discussion #1128](https://github.com/bytedeco/javacpp-presets/discussions/1128))
* Add `long rs2_get_frame_data_address()` to reduce garbage for real-time applications using librealsense2 ([discussion bytedeco/javacpp#532](https://github.com/bytedeco/javacpp/discussions/532))
* Add to `torch.Tensor` convenient `create()`, `createBuffer()`, and `createIndexer()` factory methods for PyTorch
* Upgrade requirements to Android 7.0 for camera support in OpenCV and FFmpeg ([issue bytedeco/javacv#1692](https://github.com/bytedeco/javacv/issues/1692))
Expand Down
2 changes: 2 additions & 0 deletions pytorch/src/gen/java/org/bytedeco/pytorch/TensorArrayRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public class TensorArrayRef extends Pointer {
// The enable_if stuff here makes sure that this isn't used for
// std::vector<bool>, because ArrayRef can't work on a std::vector<bool>
// bitfield.
public TensorArrayRef(@ByRef TensorVector Vec) { super((Pointer)null); allocate(Vec); }
private native void allocate(@ByRef TensorVector Vec);

/** Construct an ArrayRef from a std::array */

Expand Down
7 changes: 5 additions & 2 deletions pytorch/src/main/java/org/bytedeco/pytorch/presets/torch.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Samuel Audet, Eduardo Gonzalez
* Copyright (C) 2020-2022 Samuel Audet, Eduardo Gonzalez
*
* Licensed either under the Apache License, Version 2.0, or (at your option)
* under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -743,7 +743,7 @@ public void map(InfoMap infoMap) {
.put(new Info("std::vector<c10::TensorImpl*>").pointerTypes("TensorImplVector").define())
.put(new Info("std::vector<torch::autograd::Edge>", "torch::autograd::edge_list")
.valueTypes("@Cast({\"\", \"std::vector<torch::autograd::Edge>\"}) @StdMove EdgeVector").pointerTypes("EdgeVector").define())
.put(new Info("std::vector<at::Tensor>", "std::vector<torch::autograd::Variable>", "torch::autograd::variable_list")
.put(new Info("std::vector<at::Tensor>", "std::vector<at::Tensor,A>", "std::vector<torch::autograd::Variable>", "torch::autograd::variable_list")
.valueTypes("@Cast({\"\", \"std::vector<at::Tensor>\"}) @StdMove TensorVector").pointerTypes("TensorVector").define())
.put(new Info("std::vector<at::indexing::TensorIndex>", "std::vector<at::indexing::TensorIndex,A>").pointerTypes("TensorIndexVector").define())
.put(new Info("std::vector<c10::optional<torch::autograd::Variable> >").pointerTypes("TensorOptionalVector").define())
Expand Down Expand Up @@ -957,6 +957,9 @@ public void map(InfoMap infoMap) {
.put(new Info("c10::ArrayRef<at::Scalar>", "at::ArrayRef<at::Scalar>").pointerTypes("ScalarArrayRef"))
.put(new Info("c10::ArrayRef<at::Scalar>::iterator", "c10::ArrayRef<at::Scalar>::const_iterator").cast().pointerTypes("Scalar"))
.put(new Info("c10::ArrayRef<at::Tensor>", "at::ArrayRef<at::Tensor>", "at::TensorList").pointerTypes("TensorArrayRef"))
.put(new Info("c10::ArrayRef<at::Tensor>(std::vector<at::Tensor,A>&)").javaText(
"public TensorArrayRef(@ByRef TensorVector Vec) { super((Pointer)null); allocate(Vec); }\n"
+ "private native void allocate(@ByRef TensorVector Vec);"))
.put(new Info("c10::ArrayRef<at::Tensor>::iterator", "c10::ArrayRef<at::Tensor>::const_iterator").cast().pointerTypes("Tensor"))
.put(new Info("c10::ArrayRef<at::TensorArg>", "at::ArrayRef<at::TensorArg>").pointerTypes("TensorArgArrayRef"))
.put(new Info("c10::ArrayRef<at::TensorArg>::iterator", "c10::ArrayRef<at::TensorArg>::const_iterator").cast().pointerTypes("TensorArg"))
Expand Down

0 comments on commit eeee3e7

Please sign in to comment.