diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8fc59dc..0000000 --- a/.travis.yml +++ /dev/null @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 12f10bb..ac0c78d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` diff --git a/tensor/tensor.go b/tensor/tensor.go index d0f0eff..37317dc 100644 --- a/tensor/tensor.go +++ b/tensor/tensor.go @@ -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