fixed tensor.OfSlice() and removed TravisCI config for now

This commit is contained in:
sugarme 2022-02-24 10:47:15 +11:00
parent 66cea05f28
commit 47c6c60561
3 changed files with 16 additions and 54 deletions

View File

@ -1,52 +0,0 @@
language: go
go:
- 1.14.x
env:
- GO111MODULE=on
branches:
only:
- master
dist: bionic
before_install:
- ls -la
- sudo apt-get install clang-tools-9
- export GOTCH=$TRAVIS_BUILD_DIR
- export LIBTORCH_VERSION=${LIBTORCH_VER:-1.5.1}
- export LIBTORCH=${GOTCH}/libtch/libtorch
- export LIBRARY_PATH=${LIBTORCH}/lib
- export CPATH=${LIBTORCH}/lib:${LIBTORCH}/include:${LIBTORCH}/include/torch/csrc:${LIBTORCH}/include/torch/csrc/api/include
- export LD_LIBRARY_PATH=${LIBTORCH}/lib
- export CUDA_VER=cpu &&
wget https://raw.githubusercontent.com/sugarme/gotch/master/setup-libtorch.sh
chmod +x setup-libtorch.sh
# Precompiled libtorch
- sudo rm -rf $LIBTORCH
- sudo mkdir -p $LIBTORCH
- bash setup-libtorch.sh
- wget -O /tmp/libtorch-cxx11-abi-shared-with-deps-${LIBTORCH_VERSION}+cpu.zip https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-${LIBTORCH_VERSION}%2Bcpu.zip
- sudo unzip /tmp/libtorch-cxx11-abi-shared-with-deps-${LIBTORCH_VERSION}+cpu.zip -d ${GOTCH}/libtch
- sudo rm ${GOTCH}/libtch/lib.go
- sudo cp ${GOTCH}/libtch/lib.go.cpu ${GOTCH}/libtch/lib.go
- sudo mv ${GOTCH}/libtch/dummy_cuda_dependency.cpp ${GOTCH}/libtch/dummy_cuda_dependency.cpp.gpu
- sudo mv ${GOTCH}/libtch/fake_cuda_dependency.cpp.cpu ${GOTCH}/libtch/fake_cuda_dependency.cpp
- cd $GOTCH
- go install
script:
- printenv
- export GOTCH=$TRAVIS_BUILD_DIR
- export LIBTORCH_VERSION=${LIBTORCH_VER:-1.5.1}
- export LIBTORCH=${GOTCH}/libtch/libtorch
- export LIBRARY_PATH=${LIBTORCH}/lib
- export CPATH=${LIBTORCH}/lib:${LIBTORCH}/include:${LIBTORCH}/include/torch/csrc:${LIBTORCH}/include/torch/csrc/api/include
- export LD_LIBRARY_PATH=${LIBTORCH}/lib
- go test -v github.com/sugarme/gotch/tensor
- go test -v github.com/sugarme/gotch/nn
- go test -v github.com/sugarme/gotch/vision

View File

@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
- Remove Travis CI for now.
- fixed `tensor.OfSlice()` throw error due to "Unsupported Go type" (e.g. []float32)
- added `nn.Path.Paths()` method
- added `nn.VarStore.Summary()` method
- fixed incorrect tensor method `ts.Meshgrid` -> `Meshgrid`

View File

@ -169,11 +169,23 @@ func OfSlice(data interface{}) (*Tensor, error) {
data = sliceIntToInt32(data.([]int))
}
typ, dataLen, err := DataCheck(data)
if err != nil {
/*
typ, dataLen, err := DataCheck(data)
if err != nil {
return nil, err
}
*/
v := reflect.ValueOf(data)
kind := v.Kind().String()
if kind != "slice" && kind != "array" {
err := fmt.Errorf("Expected slice data. Got %q", kind)
return nil, err
}
typ := reflect.TypeOf(data).Elem()
dataLen := v.Len()
dtype, err := gotch.ToDType(typ)
if err != nil {
return nil, err