1 #pragma once 2 3 #include <torch/csrc/Export.h> 4 #include <cstddef> 5 #include <cstdint> 6 7 namespace torch::jit { 8 9 // Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 10 // 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Python Software 11 // Foundation; All Rights Reserved 12 // 13 // Stolen (with appropriate modifications) by @agolynski 14 // (https://github.com/pytorch/pytorch/pull/33019) from cpython repo 15 // Objects/sliceobject.c with comment: this is harder to get right than you 16 // might think 17 // 18 // This adjusts indexes according to python list semantics and returns number 19 // of elements in the resulting list. 20 TORCH_API int64_t slice_indices_adjust( 21 int64_t length, 22 int64_t* start, 23 int64_t* stop, 24 int64_t step); 25 26 } // namespace torch::jit 27