Skip to content

Commit

Permalink
Ensure the const-ness of the data member in cpp/custom-dataset (#1215)
Browse files Browse the repository at this point in the history
  • Loading branch information
lancerts authored Jan 23, 2024
1 parent 42b3bda commit b2832cc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cpp/custom-dataset/custom-dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using Data = std::vector<std::pair<std::string, long>>;
class CustomDataset : public torch::data::datasets::Dataset<CustomDataset> {
using Example = torch::data::Example<>;

Data data;
const Data data;

public:
CustomDataset(const Data& data) : data(data) {}
Expand Down Expand Up @@ -198,7 +198,7 @@ int main() {
std::cout << "Running on: "
<< (options.device == torch::kCUDA ? "CUDA" : "CPU") << std::endl;

auto data = readInfo();
const auto data = readInfo();

auto train_set =
CustomDataset(data.first).map(torch::data::transforms::Stack<>());
Expand Down

0 comments on commit b2832cc

Please sign in to comment.